|
13 | 13 | * This script publishes a new version of react-native to NPM. |
14 | 14 | * It is supposed to run in CI environment, not on a developer's machine. |
15 | 15 | * |
16 | | - * To make it easier for developers it uses some logic to identify with which version to publish the package. |
| 16 | + * To make it easier for developers it uses some logic to identify with which |
| 17 | + * version to publish the package. |
17 | 18 | * |
18 | 19 | * To cut a branch (and release RC): |
19 | 20 | * - Developer: `git checkout -b 0.XY-stable` |
20 | | - * - Developer: `git tag v0.XY.0-rc` and `git push --tags` to [email protected]:facebook/react-native.git |
21 | | - * - CI: test and deploy to npm (run this script) with version 0.XY.0-rc with tag "next" |
| 21 | + * - Developer: `./scripts/bump-oss-version.js v0.XY.0-rc.0` |
| 22 | + * - CI: test and deploy to npm (run this script) with version `0.XY.0-rc.0` |
| 23 | + * with tag "next" |
22 | 24 | * |
23 | 25 | * To update RC release: |
24 | 26 | * - Developer: `git checkout 0.XY-stable` |
25 | 27 | * - Developer: cherry-pick whatever changes needed |
26 | | - * - Developer: `git tag v0.XY.0-rc1` and `git push --tags` to [email protected]:facebook/react-native.git |
27 | | - * - CI: test and deploy to npm (run this script) with version 0.XY.0-rc1 with tag "next" |
| 28 | + * - Developer: `./scripts/bump-oss-version.js v0.XY.0-rc.1` |
| 29 | + * - CI: test and deploy to npm (run this script) with version `0.XY.0-rc.1` |
| 30 | + * with tag "next" |
28 | 31 | * |
29 | 32 | * To publish a release: |
30 | 33 | * - Developer: `git checkout 0.XY-stable` |
31 | 34 | * - Developer: cherry-pick whatever changes needed |
32 | | - * - Developer: `git tag latest` |
33 | | - * - Developer: `git tag v0.XY.0` |
34 | | - * - Developer: `git push --tags` to [email protected]:facebook/react-native.git |
35 | | - * - CI: test and deploy to npm (run this script) with version 0.XY.0 with and not tag (latest is implied by npm) |
| 35 | + * - Developer: `./scripts/bump-oss-version.js v0.XY.0` |
| 36 | + * - CI: test and deploy to npm (run this script) with version `0.XY.0` |
| 37 | + * and no tag ("latest" is implied by npm) |
36 | 38 | * |
37 | 39 | * To patch old release: |
38 | 40 | * - Developer: `git checkout 0.XY-stable` |
|
43 | 45 | * there is a version higher than XY |
44 | 46 | * |
45 | 47 | * Important tags: |
46 | | - * If tag v0.XY.0-rcZ is present on the commit then publish to npm with version 0.XY.0-rcZ and tag next |
| 48 | + * If tag v0.XY.0-rc.Z is present on the commit then publish to npm with version 0.XY.0-rc.Z and tag next |
47 | 49 | * If tag v0.XY.Z is present on the commit then publish to npm with version 0.XY.Z and no tag (npm will consider it latest) |
48 | 50 | */ |
49 | 51 |
|
50 | 52 | /*eslint-disable no-undef */ |
51 | 53 | require('shelljs/global'); |
52 | 54 |
|
53 | | -const buildBranch = process.env.CIRCLE_BRANCH; |
| 55 | +const buildTag = process.env.CIRCLE_TAG; |
54 | 56 | const otp = process.env.NPM_CONFIG_OTP; |
55 | 57 |
|
56 | | -let branchVersion; |
57 | | -if (buildBranch.indexOf('-stable') !== -1) { |
58 | | - branchVersion = buildBranch.slice(0, buildBranch.indexOf('-stable')); |
59 | | -} else { |
60 | | - echo('Error: We publish only from stable branches'); |
61 | | - exit(0); |
| 58 | +if (!buildTag) { |
| 59 | + echo('Error: We publish only from git tags'); |
| 60 | + exit(1); |
| 61 | +} |
| 62 | + |
| 63 | +let match = buildTag.match(/^v(\d+\.\d+)\.\d+(?:-.+)?$/); |
| 64 | +if (!match) { |
| 65 | + echo('Error: We publish only from release version git tags'); |
| 66 | + exit(1); |
62 | 67 | } |
| 68 | +// 0.33 |
| 69 | +let [, branchVersion] = match; |
63 | 70 |
|
64 | 71 | // 34c034298dc9cad5a4553964a5a324450fda0385 |
65 | 72 | const currentCommit = exec('git rev-parse HEAD', {silent: true}).stdout.trim(); |
|
0 commit comments