Skip to content

Commit d9ef3ac

Browse files
authored
Merge pull request #1748 from Saadnajmi/more71
Merge up to upstream release 0.71.6 + Cherry pick publish pipeline refactor from main
2 parents b50758f + a1dd9c4 commit d9ef3ac

File tree

283 files changed

+7358
-5930
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

283 files changed

+7358
-5930
lines changed

.ado/Brewfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
brew "watchman"
22
brew "xcbeautify"
3+
# macOS 12 doesn't have `realpath` but macOS 13 does. Remove this line when Azure Pipelines supports macOS 13 images.
4+
brew "coreutils"

.ado/apple-pr.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,22 @@ jobs:
223223
- template: templates/react-native-macos-init.yml
224224
parameters:
225225
configuration: $(configuration)
226+
227+
- job: NPMPublishDryRun
228+
displayName: NPM Publish Dry Run
229+
pool:
230+
vmImage: $(VmImageApple)
231+
timeoutInMinutes: 60 # how long to run the job before automatically cancelling
232+
cancelTimeoutInMinutes: 5 # how much time to give 'run always even if cancelled tasks' before killing them
233+
steps:
234+
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
235+
clean: true # whether to fetch clean each time
236+
# fetchDepth: 2 # the depth of commits to ask Git to fetch
237+
lfs: false # whether to download Git-LFS files
238+
submodules: recursive # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules
239+
persistCredentials: true # set to 'true' to leave the OAuth token in the Git config after the initial fetch
240+
241+
- template: templates/apple-job-publish.yml
242+
parameters:
243+
build_type: 'dry-run'
244+

.ado/bumpFileVersions.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

.ado/versionUtils.js renamed to .ado/get-next-semver-version.js

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function gatherVersionInfo() {
1919
return {pkgJson, releaseVersion, branchVersionSuffix};
2020
}
2121

22-
function updateVersionsInFiles(patchVersionPrefix) {
22+
function getNextVersion(patchVersionPrefix) {
2323

2424
let {pkgJson, releaseVersion, branchVersionSuffix} = gatherVersionInfo();
2525

@@ -42,34 +42,9 @@ function updateVersionsInFiles(patchVersionPrefix) {
4242
}
4343

4444
pkgJson.version = releaseVersion;
45-
console.log(`Bumping files to version ${releaseVersion}`);
46-
execSync(`node ./scripts/set-rn-version.js --rnmpublish --to-version ${releaseVersion}`, {stdio: 'inherit', env: process.env});
4745

4846
return {releaseVersion, branchVersionSuffix};
4947
}
5048

51-
const workspaceJsonPath = path.resolve(require('os').tmpdir(), 'rnpkg.json');
52-
53-
function removeWorkspaceConfig() {
54-
let {pkgJson} = gatherVersionInfo();
55-
fs.writeFileSync(workspaceJsonPath, JSON.stringify(pkgJson, null, 2));
56-
delete pkgJson.private;
57-
delete pkgJson.workspaces;
58-
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
59-
console.log(`Removing workspace config from package.json to prepare to publish.`);
60-
}
61-
62-
function restoreWorkspaceConfig() {
63-
let pkgJson = JSON.parse(fs.readFileSync(workspaceJsonPath, "utf8"));
64-
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
65-
console.log(`Restoring workspace config from package.json`);
66-
}
67-
68-
module.exports = {
69-
gatherVersionInfo,
70-
publishBranchName,
71-
pkgJsonPath,
72-
removeWorkspaceConfig,
73-
restoreWorkspaceConfig,
74-
updateVersionsInFiles
75-
}
49+
const nextVersion = getNextVersion().releaseVersion;
50+
console.log(nextVersion);

.ado/gitTagRelease.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

.ado/publish.yml

Lines changed: 21 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# It is expected that a `latestStableBranch` variable is set in the pipeline's settings:
2-
# https://dev.azure.com/office/ISS/_apps/hub/ms.vss-build-web.ci-designer-hub?pipelineId=18541
3-
41
# This file defines the build steps to publish a release
52
name: $(Date:yyyyMMdd).$(Rev:.r)
63

@@ -9,7 +6,7 @@ trigger:
96
branches:
107
include:
118
- main
12-
- 0.68-stable
9+
- '*-stable'
1310
paths:
1411
exclude:
1512
- package.json
@@ -25,16 +22,14 @@ variables:
2522

2623
jobs:
2724
- job: RNGithubNpmJSPublish
28-
displayName: React-Native GitHub Publish to npmjs.org
25+
displayName: NPM Publish React-native-macos
2926
pool:
3027
vmImage: $(VmImageApple)
3128
variables:
3229
- name: BUILDSECMON_OPT_IN
3330
value: true
3431
timeoutInMinutes: 90 # how long to run the job before automatically cancelling
3532
cancelTimeoutInMinutes: 5 # how much time to give 'run always even if cancelled tasks' before killing them
36-
dependsOn:
37-
- Compliance
3833
steps:
3934
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
4035
clean: true # whether to fetch clean each time
@@ -43,54 +38,21 @@ jobs:
4338
submodules: recursive # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules
4439
persistCredentials: true # set to 'true' to leave the OAuth token in the Git config after the initial fetch
4540

46-
- script: exit 1
47-
displayName: Validate variables
48-
condition: eq(variables.latestStableBranch, '')
49-
50-
- bash: echo "##vso[task.setvariable variable=npmDistTag]latest"
51-
displayName: Set dist-tag to latest
52-
condition: eq(variables['Build.SourceBranchName'], variables.latestStableBranch)
53-
54-
- bash: echo "##vso[task.setvariable variable=npmDistTag]canary"
55-
displayName: Set dist-tag to canary
56-
condition: eq(variables['Build.SourceBranchName'], 'main')
57-
58-
- bash: echo "##vso[task.setvariable variable=npmDistTag]v${{variables['Build.SourceBranchName']}}"
59-
displayName: Set dist-tag to v0.x-stable
60-
condition: and(ne(variables['Build.SourceBranchName'], 'main'), ne(variables['Build.SourceBranchName'], variables.latestStableBranch))
61-
62-
- template: templates/apple-tools-setup.yml
63-
64-
- task: CmdLine@2
65-
displayName: yarn install
66-
inputs:
67-
script: yarn install --frozen-lockfile
68-
69-
- task: CmdLine@2
70-
displayName: Bump stable package version
71-
inputs:
72-
script: node .ado/bumpFileVersions.js
73-
condition: and(succeeded(), ne(variables['Build.SourceBranchName'], 'main'))
74-
75-
- task: CmdLine@2
76-
displayName: pod update React-TurboModuleCxx-RNW
77-
inputs:
78-
script: |
79-
cd packages/rn-tester
80-
pod update React-TurboModuleCxx-RNW
81-
condition: and(succeeded(), ne(variables['Build.SourceBranchName'], 'main'))
82-
83-
- task: CmdLine@2
84-
displayName: Set canary package version
85-
inputs:
86-
script: node scripts/set-rn-version.js --nightly --autogenerateVersionNumber
87-
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'main'))
88-
89-
# Publish will fail if package.json is marked as private
90-
- task: CmdLine@2
91-
displayName: Remove workspace config from package.json
92-
inputs:
93-
script: node .ado/removeWorkspaceConfig.js
41+
- ${{ if eq(variables['isMain'], true) }}:
42+
- template: templates/apple-job-publish.yml
43+
parameters:
44+
build_type: nightly
45+
- ${{ elseif eq(variables['isReleaseBranch'], true) }}:
46+
- template: templates/apple-job-publish.yml
47+
parameters:
48+
build_type: release
49+
- ${{ else }}:
50+
- task: CmdLine@2
51+
displayName: Unknown branch, skipping publish
52+
inputs:
53+
script: |
54+
echo "Skipping publish for branch $(Build.SourceBranchName)"
55+
exit 1
9456
9557
- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
9658
displayName: 📒 Generate Manifest
@@ -103,29 +65,8 @@ jobs:
10365
artifactName: SBom-RNGithubNpmJSPublish-$(System.JobAttempt)
10466
targetPath: $(System.DefaultWorkingDirectory)/_manifest
10567

106-
- script: npm publish --tag $(npmDistTag) --registry https://registry.npmjs.org/ --//registry.npmjs.org/:_authToken=$(npmAuthToken)
107-
displayName: Publish react-native-macos to npmjs.org
108-
109-
# Put the private flag back so that the removal does not get committed by the tag release step
110-
- task: CmdLine@2
111-
displayName: Restore package.json workspace config
112-
inputs:
113-
script: node .ado/restoreWorkspaceConfig.js
114-
115-
- task: CmdLine@2
116-
displayName: 'Tag published release'
117-
inputs:
118-
script: node .ado/gitTagRelease.js
119-
env:
120-
BUILD_STAGINGDIRECTORY: $(Build.StagingDirectory)
121-
BUILD_SOURCEBRANCH: $(Build.SourceBranch)
122-
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
123-
githubApiToken: $(githubAuthToken)
124-
condition: and(succeeded(), ne(variables['Build.SourceBranchName'], 'main'))
125-
126-
12768
- job: RNMacOSInitNpmJSPublish
128-
displayName: react-native-macos-init Publish to npmjs.org
69+
displayName: NPM Publish react-native-macos-init
12970
pool: cxeiss-ubuntu-20-04-large
13071
timeoutInMinutes: 90 # how long to run the job before automatically cancelling
13172
cancelTimeoutInMinutes: 5 # how much time to give 'run always even if cancelled tasks' before killing them
@@ -140,17 +81,12 @@ jobs:
14081
submodules: recursive # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules
14182
persistCredentials: true # set to 'true' to leave the OAuth token in the Git config after the initial fetch
14283

143-
- template: templates/configure-git.yml
84+
- template: templates/apple-install-dependencies.yml
14485

145-
- task: CmdLine@2
146-
displayName: yarn install
147-
inputs:
148-
script: |
149-
cd packages/react-native-macos-init
150-
yarn install --frozen-lockfile
86+
- template: templates/apple-release-setup.yml
15187

15288
- task: CmdLine@2
153-
displayName: yarn build
89+
displayName: Build react-native-macos-init
15490
inputs:
15591
script: |
15692
cd packages/react-native-macos-init

.ado/removeWorkspaceConfig.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

.ado/restoreWorkspaceConfig.js

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
steps:
2+
- task: CmdLine@2
3+
displayName: yarn install
4+
inputs:
5+
script: yarn install --frozen-lockfile
6+
7+
- task: CmdLine@2
8+
displayName: bundle install
9+
inputs:
10+
script: |
11+
cd packages/rn-tester
12+
bundle install
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
parameters:
2+
build_type: ''
3+
4+
steps:
5+
- template: apple-tools-setup.yml
6+
7+
- template: apple-install-dependencies.yml
8+
9+
# Only set up our release environment if we're not doing a dry run
10+
- ${{ if ne( parameters['build_type'], 'dry-run') }}:
11+
- template: apple-release-setup.yml
12+
13+
- task: CmdLine@2
14+
displayName: Set build type to ${{parameters.build_type}}
15+
inputs:
16+
script: |
17+
BUILD_TYPE=${{parameters.build_type}}
18+
echo "Set build type: $BUILD_TYPE"
19+
20+
# Extra steps needed for *-stable releases
21+
- ${{ if eq( parameters['build_type'], 'release') }}:
22+
- task: CmdLine@2
23+
displayName: Set next version
24+
inputs:
25+
script: |
26+
VERSION=$(node .ado/get-next-semver-version.js)
27+
echo "Set version: $VERSION"
28+
29+
- task: CmdLine@2
30+
displayName: Set build type to ${{parameters.build_type}}
31+
inputs:
32+
script: |
33+
BUILD_TYPE=release
34+
echo "Set build type: $BUILD_TYPE"
35+
36+
- task: CmdLine@2
37+
displayName: Set latest tag
38+
inputs:
39+
script: |
40+
LATEST=true
41+
echo "Set latest to: $LATEST"
42+
43+
- task: CmdLine@2
44+
displayName: Prepare and tag package for release
45+
inputs:
46+
script: |
47+
if [[ -z "$VERSION" ]]; then
48+
VERSION=$(grep '"version"' package.json | cut -d '"' -f 4 | head -1)
49+
echo "Using the version from the package.json: $VERSION"
50+
fi
51+
node ./scripts/prepare-package-for-release.js -v "$VERSION" -l $LATEST
52+
53+
- task: CmdLine@2
54+
displayName: NPM Publish
55+
inputs:
56+
script: |
57+
node ./scripts/publish-npm.js --${{ parameters.build_type }}

0 commit comments

Comments
 (0)