Version release script
Summary:npm-publish.js is not cohesive enough: besides building and publishing it also modifies some files. It is better to have a separate script that will bump versions, make a commit and tag it. scripts/bump-oss-version.js does exactly that. This simplifies release process and allows manual release to npm if CI is not available. Closes https://github.com/facebook/react-native/pull/6625 Differential Revision: D3092849 fb-gh-sync-id: 92cf38bd3df31c8c9c433fc5f9e15c129855fe0e shipit-source-id: 92cf38bd3df31c8c9c433fc5f9e15c129855fe0e
This commit is contained in:
parent
0f62dcecf5
commit
aec90bb46b
|
@ -1,4 +1,4 @@
|
||||||
VERSION_NAME=0.12.0-SNAPSHOT
|
VERSION_NAME=0.0.1-master
|
||||||
GROUP=com.facebook.react
|
GROUP=com.facebook.react
|
||||||
|
|
||||||
POM_NAME=ReactNative
|
POM_NAME=ReactNative
|
||||||
|
|
|
@ -34,7 +34,8 @@ Run:
|
||||||
|
|
||||||
```
|
```
|
||||||
git checkout -b <version_you_are_releasing>-stable # e.g. git checkout -b 0.22-stable
|
git checkout -b <version_you_are_releasing>-stable # e.g. git checkout -b 0.22-stable
|
||||||
git tag v<version_you_are_releasing>.0-rc # e.g. git tag v0.22.0-rc
|
node ./scripts/bump-oss-version.js <exact-version_you_are_releasing> # e.g. git node ./scripts/bump-oss-version.js 0.22.0-rc
|
||||||
|
./scripts/test-manual-e2e.sh # to double check that e2e process works
|
||||||
git push origin <version_you_are_releasing>-stable --tags # e.g. git push origin 0.22-stable --tags
|
git push origin <version_you_are_releasing>-stable --tags # e.g. git push origin 0.22-stable --tags
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ git cherry-pick commitHash1
|
||||||
If everything worked:
|
If everything worked:
|
||||||
|
|
||||||
```
|
```
|
||||||
git tag v-version_you_are_releasing # e.g. git tag v0.22.0, git tag v0.22.1
|
node ./scripts/bump-oss-version.js <exact_version_you_are_releasing> # e.g. git node ./scripts/bump-oss-version.js 0.22.0
|
||||||
git tag -d latest
|
git tag -d latest
|
||||||
git push origin :latest
|
git push origin :latest
|
||||||
git tag latest # for docs [website](https://facebook.github.io/react-native) to be generated
|
git tag latest # for docs [website](https://facebook.github.io/react-native) to be generated
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2015-present, Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD-style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This script bumps a new version for open source releases.
|
||||||
|
* It updates the version in podspec/json/gradle files and makes sure they are consistent between each other
|
||||||
|
* After changing the files it makes a commit and tags it.
|
||||||
|
* All you have to do is push changes to remote and CI will make a new build.
|
||||||
|
*/
|
||||||
|
/*eslint-disable no-undef */
|
||||||
|
require(`shelljs/global`);
|
||||||
|
|
||||||
|
// - check we are in release branch, e.g. 0.33-stable
|
||||||
|
let branch = exec(`git symbolic-ref --short HEAD`, {silent: true}).stdout.trim();
|
||||||
|
|
||||||
|
if (branch.indexOf(`-stable`) === -1) {
|
||||||
|
echo(`You must be in 0.XX-stable branch to bump a version`);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// e.g. 0.33
|
||||||
|
let versionMajor = branch.slice(0, branch.indexOf(`-stable`));
|
||||||
|
|
||||||
|
// - check that argument version matches branch
|
||||||
|
// e.g. 0.33.1 or 0.33.0-rc4
|
||||||
|
let version = process.argv[2];
|
||||||
|
if (!version || version.indexOf(versionMajor) !== 0) {
|
||||||
|
echo(`You must pass a tag like ${versionMajor}.[X]-rc[Y] to bump a version`);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let packageJson = JSON.parse(cat(`package.json`));
|
||||||
|
packageJson.version = version;
|
||||||
|
JSON.stringify(packageJson, null, 2).to(`package.json`);
|
||||||
|
|
||||||
|
// - change ReactAndroid/gradle.properties
|
||||||
|
if (sed(`-i`, /^VERSION_NAME=.*/, `VERSION_NAME=${version}`, `ReactAndroid/gradle.properties`).code) {
|
||||||
|
echo(`Couldn't update version for Gradle`);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// - change React.podspec
|
||||||
|
if (sed(`-i`, /s.version\s*=.*/, `s.version = \"${version}\"`, `React.podspec`).code) {
|
||||||
|
echo(`Couldn't update version for React.podspec`);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// verify that files changed, we just do a git diff and check how many times version is added across files
|
||||||
|
let numberOfChangedLinesWithNewVersion = exec(`git diff -U0 | grep '^[+]' | grep -c ${version} `, {silent: true})
|
||||||
|
.stdout.trim();
|
||||||
|
if (+numberOfChangedLinesWithNewVersion !== 3) {
|
||||||
|
echo(`Failed to update all the files. React.podspec, package.json and gradle.properties must have versions in them`);
|
||||||
|
echo(`Fix the issue, revert and try again`);
|
||||||
|
exec(`git diff`);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// - make commit [0.21.0-rc] Bump version numbers
|
||||||
|
if (exec(`git commit -a -m "[${version}] Bump version numbers"`).code) {
|
||||||
|
echo(`failed to commit`);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// - add tag v0.21.0-rc
|
||||||
|
if (exec(`git tag v${version}`).code) {
|
||||||
|
echo(`failed to tag the commit with v${version}, are you sure this release wasn't made earlier?`);
|
||||||
|
echo(`You may want to rollback the last commit`);
|
||||||
|
echo(`git reset --hard HEAD~1`);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
/*eslint-enable no-undef */
|
|
@ -90,11 +90,6 @@ if (javaVersion.indexOf(requiredJavaVersion) === -1) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sed(`-i`, /^VERSION_NAME=[0-9\.]*-SNAPSHOT/, `VERSION_NAME=${releaseVersion}`, `ReactAndroid/gradle.properties`).code) {
|
|
||||||
echo(`Couldn't update version for Gradle`);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Uncomment Javadoc generation
|
// Uncomment Javadoc generation
|
||||||
if (sed(`-i`, `// archives androidJavadocJar`, `archives androidJavadocJar`, `ReactAndroid/release.gradle`).code) {
|
if (sed(`-i`, `// archives androidJavadocJar`, `archives androidJavadocJar`, `ReactAndroid/release.gradle`).code) {
|
||||||
echo(`Couldn't enable Javadoc generation`);
|
echo(`Couldn't enable Javadoc generation`);
|
||||||
|
@ -106,6 +101,9 @@ if (exec(`./gradlew :ReactAndroid:installArchives`).code) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// undo uncommenting javadoc setting
|
||||||
|
exec(`git checkout ReactAndroid/gradle.properties`);
|
||||||
|
|
||||||
echo("Generated artifacts for Maven");
|
echo("Generated artifacts for Maven");
|
||||||
|
|
||||||
let artifacts = ['-javadoc.jar', '-sources.jar', '.aar', '.pom'].map((suffix) => {
|
let artifacts = ['-javadoc.jar', '-sources.jar', '.aar', '.pom'].map((suffix) => {
|
||||||
|
@ -119,23 +117,6 @@ artifacts.forEach((name) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// ----------- Reverting changes to local files
|
|
||||||
|
|
||||||
exec(`git checkout ReactAndroid/gradle.properties`);
|
|
||||||
exec(`git checkout ReactAndroid/release.gradle`);
|
|
||||||
|
|
||||||
|
|
||||||
if (exec(`npm version --no-git-tag-version ${releaseVersion}`).code) {
|
|
||||||
echo(`Couldn't update version for npm`);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (sed(`-i`, `s.version = "0.0.1-master"`, `s.version = \"${releaseVersion}\"`, `React.podspec`).code) {
|
|
||||||
echo(`Couldn't update version for React.podspec`);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// shrinkwrapping without dev dependencies
|
|
||||||
exec(`npm shrinkwrap`);
|
|
||||||
if (releaseVersion.indexOf(`-rc`) === -1) {
|
if (releaseVersion.indexOf(`-rc`) === -1) {
|
||||||
// release, package will be installed by default
|
// release, package will be installed by default
|
||||||
exec(`npm publish`);
|
exec(`npm publish`);
|
||||||
|
@ -144,9 +125,6 @@ if (releaseVersion.indexOf(`-rc`) === -1) {
|
||||||
exec(`npm publish --tag next`);
|
exec(`npm publish --tag next`);
|
||||||
}
|
}
|
||||||
|
|
||||||
exec(`git checkout package.json`);
|
|
||||||
exec(`git checkout React.podspec`);
|
|
||||||
|
|
||||||
echo(`Published to npm ${releaseVersion}`);
|
echo(`Published to npm ${releaseVersion}`);
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
Loading…
Reference in New Issue