Skip to content

Commit

Permalink
ci: bring publish pipeline updates from 0.76-stable to main (#2314)
Browse files Browse the repository at this point in the history
* ci: Enable publishing of stable releases

* ci: check publish_react_native_macos with a runtime condition

* ci: add `--verbose` flag to `nx release`

* chore: don't use `workspace:*` dependencies in react-native-macos

* ci: rename `npm-publish` to `npm-publish-steps`

* ci: move xcode-select into apple-tools-setup

* ci: switch branch before publishing artifacts (#2317)

* ci: split out `nx release publish` into a separate call

* Update npm publish template path in YAML

* back to workspace:*

* downloadAllPlatforms

---------

Co-authored-by: Tommy Nguyen <[email protected]>
  • Loading branch information
Saadnajmi and tido64 authored Jan 15, 2025
1 parent 1f83f4e commit c80cf78
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 79 deletions.
3 changes: 2 additions & 1 deletion .ado/jobs/npm-publish-dry-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ jobs:
fetchFilter: blob:none # partial clone for faster clones while maintaining history
persistCredentials: true # set to 'true' to leave the OAuth token in the Git config after the initial fetch

- template: /.ado/templates/npm-publish.yml@self
- template: /.ado/templates/npm-publish-steps.yml@self

65 changes: 1 addition & 64 deletions .ado/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,67 +71,4 @@ extends:
fetchFilter: blob:none # partial clone for faster clones while maintaining history
persistCredentials: true # set to 'true' to leave the OAuth token in the Git config after the initial fetch

- template: /.ado/templates/npm-publish.yml@self

# Set the git tag and push the version update back to Github

- template: .ado/templates/configure-git.yml@self

- task: CmdLine@2
displayName: 'Tag and push to Github'
inputs:
script: node .ado/gitTagRelease.js
env:
BUILD_STAGINGDIRECTORY: $(Build.StagingDirectory)
BUILD_SOURCEBRANCH: $(Build.SourceBranch)
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
githubAuthToken: $(githubAuthToken)
condition: and(succeeded(), ne(variables['Build.SourceBranchName'], 'main'))

- job: RNMacOSInitNpmJSPublish
displayName: NPM Publish beachball packages (e.g., react-native-macos-init)
pool:
name: cxeiss-ubuntu-20-04-large
image: cxe-ubuntu-20-04-1es-pt
os: linux
timeoutInMinutes: 90 # how long to run the job before automatically cancelling
cancelTimeoutInMinutes: 5 # how much time to give 'run always even if cancelled tasks' before killing them
templateContext:
outputs:
- output: pipelineArtifact
targetPath: $(System.DefaultWorkingDirectory)
artifactName: macos-init-npm-js-publish
steps:
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
clean: true # whether to fetch clean each time
# fetchDepth: 2 # the depth of commits to ask Git to fetch
lfs: false # whether to download Git-LFS files
submodules: recursive # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules
persistCredentials: true # set to 'true' to leave the OAuth token in the Git config after the initial fetch

- template: .ado/templates/configure-git.yml@self

- task: CmdLine@2
displayName: yarn install
inputs:
script: |
cd packages/react-native-macos-init
yarn install
- task: CmdLine@2
displayName: Build react-native-macos-init
inputs:
script: |
cd packages/react-native-macos-init
yarn build
- task: CmdLine@2
displayName: Code tested in other pipeline [test]
inputs:
script: echo "This code is tested as part of an integration test. See the 'Verify react-native-macos-init' task."

- task: CmdLine@2
displayName: "Publish beachball packages to npmjs.org"
inputs:
script: |
npx beachball publish --scope '!packages/react-native' --branch origin/$(Build.SourceBranchName) -n $(npmAuthToken) -yes -m "applying package updates ***NO_CI***" --access public
- template: /.ado/templates/npm-publish-steps.yml@self
2 changes: 1 addition & 1 deletion .ado/scripts/prepublish-check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { spawnSync } from "node:child_process";
import * as fs from "node:fs";
import * as util from "node:util";

const ADO_PUBLISH_PIPELINE = ".ado/templates/npm-publish.yml";
const ADO_PUBLISH_PIPELINE = ".ado/templates/npm-publish-steps.yml";
const NX_CONFIG_FILE = "nx.json";

const NPM_TAG_NEXT = "next";
Expand Down
9 changes: 8 additions & 1 deletion .ado/templates/apple-tools-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ steps:
brew bundle --file .ado/Brewfile
displayName: 'Install Homebrew dependencies'
- template: /.ado/templates/apple-xcode-select.yml@self
- script: |
sudo xcode-select --switch $(xcode_version)
displayName: Use $(xcode_friendly_name)
- script: |
xcodebuild -downloadAllPlatforms
sudo xcodebuild -runFirstLaunch
displayName: 'Download Xcode Platforms'
5 changes: 0 additions & 5 deletions .ado/templates/apple-xcode-select.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ parameters:
publishTag: 'next'

steps:
- template: /.ado/templates/configure-git.yml@self

- script: |
yarn install
displayName: Install npm dependencies
Expand All @@ -12,17 +14,17 @@ steps:
displayName: Verify release config
- script: |
yarn nx release --dry-run
echo Target branch: $(System.PullRequest.TargetBranch)
yarn nx release --dry-run --verbose
displayName: Version and publish packages (dry run)
condition: ${{ ne(variables['publish_react_native_macos'], '1') }}
condition: and(succeeded(), ne(variables['publish_react_native_macos'], '1'))
- script: |
# TODO: Before we can change the line below to `yarn nx release --yes` on
# `main`, we must first set up the pipeline for nightly builds. Stable
# branches should be fine.
yarn nx release --dry-run
git switch $(Build.SourceBranchName)
yarn nx release --skip-publish --verbose
yarn nx release publish --excludeTaskDependencies
env:
GITHUB_TOKEN: $(githubAuthToken)
NODE_AUTH_TOKEN: $(npmAuthToken)
displayName: Version and publish packages
condition: ${{ eq(variables['publish_react_native_macos'], '1') }}
condition: and(succeeded(), eq(variables['publish_react_native_macos'], '1'))

0 comments on commit c80cf78

Please sign in to comment.