Skip to content

Commit ea0f1ac

Browse files
authored
Merge pull request #879 from acoates-ms/updpodlock
Fixes for publishing from stable branches
2 parents a186688 + f8cea11 commit ea0f1ac

File tree

5 files changed

+49
-16
lines changed

5 files changed

+49
-16
lines changed

.ado/gitTagRelease.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function doPublish() {
2828
exec(`git config --global user.email "53619745+rnbot@users.noreply.github.com"`);
2929
exec(`git config --global user.name "React-Native Bot"`);
3030

31-
exec(`git add ${pkgJsonPath}`);
31+
exec(`git add .`);
3232
exec(`git commit -m "Applying package update to ${releaseVersion} ***NO_CI***"`);
3333
exec(`git tag v${releaseVersion}`);
3434
exec(`git push origin HEAD:${tempPublishBranch} --follow-tags --verbose`);

.ado/npmOfficePack.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function doPublish(fakeMode) {
2828
if (!onlyTagSource) {
2929
// -------- Generating Android Artifacts with JavaDoc
3030
const depsEnvPrefix = "REACT_NATIVE_BOOST_PATH=" + path.join(process.env.BUILD_SOURCESDIRECTORY, "build_deps");
31-
const gradleCommand = path.join(process.env.BUILD_SOURCESDIRECTORY, "gradlew") + " installArchives";
31+
const gradleCommand = path.join(process.env.BUILD_SOURCESDIRECTORY, "gradlew") + " installArchives -Pparam=\"excludeLibs\"";
3232
exec( depsEnvPrefix + " " + gradleCommand );
3333

3434
// undo uncommenting javadoc setting

.ado/publish.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ trigger:
1616

1717
pr: none
1818

19+
variables:
20+
- template: variables/mac.yml
21+
1922
jobs:
2023
- job: RNGithubNpmJSPublish
2124
displayName: React-Native GitHub Publish to npmjs.org
2225
pool:
23-
vmImage: vs2017-win2016
26+
vmImage: $(VmImage)
2427
timeoutInMinutes: 90 # how long to run the job before automatically cancelling
2528
cancelTimeoutInMinutes: 5 # how much time to give 'run always even if cancelled tasks' before killing them
2629
steps:
@@ -47,6 +50,8 @@ jobs:
4750
displayName: Set dist-tag to v0.x-stable
4851
condition: and(ne(variables['Build.SourceBranchName'], 'master'), ne(variables['Build.SourceBranchName'], variables.latestStableBranch))
4952

53+
- template: templates/apple-node-setup.yml
54+
5055
- task: CmdLine@2
5156
displayName: yarn install
5257
inputs:
@@ -56,13 +61,21 @@ jobs:
5661
displayName: Bump stable package version
5762
inputs:
5863
script: node .ado/bumpFileVersions.js
59-
condition: ne(variables['Build.SourceBranchName'], 'master')
64+
condition: and(succeeded(), ne(variables['Build.SourceBranchName'], 'master'))
65+
66+
- task: CmdLine@2
67+
displayName: pod update React-TurboModuleCxx-RNW
68+
inputs:
69+
script: |
70+
cd packages/rn-tester
71+
pod update React-TurboModuleCxx-RNW
72+
condition: and(succeeded(), ne(variables['Build.SourceBranchName'], 'master'))
6073

6174
- task: CmdLine@2
6275
displayName: Bump canary package version
6376
inputs:
6477
script: node scripts/bump-oss-version.js --nightly
65-
condition: eq(variables['Build.SourceBranchName'], 'master')
78+
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'master'))
6679

6780
# Publish will fail if package.json is marked as private
6881
- task: CmdLine@2
@@ -88,7 +101,7 @@ jobs:
88101
BUILD_SOURCEBRANCH: $(Build.SourceBranch)
89102
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
90103
githubApiToken: $(githubApiToken)
91-
condition: ne(variables['Build.SourceBranchName'], 'master')
104+
condition: and(succeeded(), ne(variables['Build.SourceBranchName'], 'master'))
92105

93106

94107
- job: RNMacOSInitNpmJSPublish
@@ -149,6 +162,12 @@ jobs:
149162
inputs:
150163
script: node .ado/bumpOfficeFileVersions.js
151164

165+
# Publish will fail if package.json is marked as private
166+
- task: CmdLine@2
167+
displayName: Remove workspace config from package.json
168+
inputs:
169+
script: node .ado/removeWorkspaceConfig.js
170+
152171
- task: CmdLine@2
153172
displayName: gradlew installArchives
154173
inputs:

.ado/versionUtils.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
const fs = require("fs");
33
const path = require("path");
44
const semver = require('semver');
5+
const {execSync} = require('child_process');
56

67
const pkgJsonPath = path.resolve(__dirname, "../package.json");
78
let publishBranchName = '';
@@ -41,9 +42,9 @@ function updateVersionsInFiles(patchVersionPrefix) {
4142
}
4243

4344
pkgJson.version = releaseVersion;
44-
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
45-
console.log(`Updating package.json to version ${releaseVersion}`);
46-
45+
console.log(`Bumping files to version ${releaseVersion}`);
46+
execSync(`node ./scripts/bump-oss-version.js --rnmpublish ${releaseVersion}`, {stdio: 'inherit', env: process.env});
47+
4748
return {releaseVersion, branchVersionSuffix};
4849
}
4950

scripts/bump-oss-version.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ let argv = yargs
2929
type: 'boolean',
3030
default: false,
3131
})
32+
.option('p', { // [MacOS: Used during RNM's publish pipelines
33+
alias: 'rnmpublish',
34+
type: 'boolean',
35+
default: false,
36+
})
3237
.option('n', {
3338
alias: 'nightly',
3439
type: 'boolean',
@@ -37,6 +42,7 @@ let argv = yargs
3742

3843
const nightlyBuild = argv.nightly;
3944
const ci = argv.ci;
45+
const rnmpublish = argv.rnmpublish;
4046

4147
let version, branch;
4248
if (nightlyBuild) {
@@ -45,10 +51,15 @@ if (nightlyBuild) {
4551
}).stdout.trim();
4652
version = `0.0.0-${currentCommit.slice(0, 9)}`;
4753
} else {
48-
// Check we are in release branch, e.g. 0.33-stable
49-
branch = exec('git symbolic-ref --short HEAD', {
50-
silent: true,
51-
}).stdout.trim();
54+
if (!ci && process.env.BUILD_SOURCEBRANCH) {
55+
console.log(`BUILD_SOURCEBRANCH: ${process.env.BUILD_SOURCEBRANCH}`)
56+
branch = process.env.BUILD_SOURCEBRANCH.match(/refs\/heads\/(.*)/)[1];
57+
console.log(`Identified branch: ${branch}`)
58+
} else {
59+
branch = exec('git symbolic-ref --short HEAD', {
60+
silent: true,
61+
}).stdout.trim();
62+
}
5263

5364
if (!ci && branch.indexOf('-stable') === -1) {
5465
echo('You must be in 0.XX-stable branch to bump a version');
@@ -133,8 +144,10 @@ fs.writeFileSync(
133144

134145
let packageJson = JSON.parse(cat('package.json'));
135146
packageJson.version = version;
136-
delete packageJson.workspaces;
137-
delete packageJson.private;
147+
if (!rnmpublish) {
148+
delete packageJson.workspaces;
149+
delete packageJson.private;
150+
}
138151
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2), 'utf-8');
139152

140153
// Change ReactAndroid/gradle.properties
@@ -161,7 +174,7 @@ let numberOfChangedLinesWithNewVersion = exec(
161174

162175
// Release builds should commit the version bumps, and create tags.
163176
// Nightly builds do not need to do that.
164-
if (!nightlyBuild) {
177+
if (!nightlyBuild && !rnmpublish) {
165178
if (+numberOfChangedLinesWithNewVersion !== 3) {
166179
echo(
167180
'Failed to update all the files. package.json and gradle.properties must have versions in them',

0 commit comments

Comments
 (0)