Skip to content

Commit

Permalink
Support the --remote option in bump-oss-version.js script
Browse files Browse the repository at this point in the history
Summary:
In my RN checkout, I use "upstream" as my remote instead of "origin" -> this lets me run `scripts/bump-oss-version.js --remote upstream 0.41.1` for example.

Also made the script executable so we don't need to put `node` in front of it, and updated the Releases.md doc.
Closes facebook#12230

Differential Revision: D4515070

Pulled By: mkonicek

fbshipit-source-id: f218a6b77959588ee5f625b8589ac080dd010034
  • Loading branch information
ide authored and facebook-github-bot committed Feb 6, 2017
1 parent 242ced1 commit eb4be7a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
13 changes: 7 additions & 6 deletions Releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ Run:
git checkout -b <version_you_are_releasing>-stable
# e.g. git checkout -b 0.22-stable

node ./scripts/bump-oss-version.js <exact-version_you_are_releasing>
# e.g. node ./scripts/bump-oss-version.js 0.22.0-rc
./scripts/bump-oss-version.js <exact-version_you_are_releasing>
# e.g. ./scripts/bump-oss-version.js 0.22.0-rc
# You can use the --remote option to specify a Git remote other than the default "origin"
```

Circle CI will automatically run the tests and publish to npm with the version you have specified (e.g `0.22.0-rc`) and tag `next` meaning that this version will not be installed for users by default.
Expand Down Expand Up @@ -112,8 +113,8 @@ git cherry-pick commitHash1
If everything worked:

```bash
node ./scripts/bump-oss-version.js <exact_version_you_are_releasing>
# e.g. node ./scripts/bump-oss-version.js 0.28.0-rc.1
./scripts/bump-oss-version.js <exact_version_you_are_releasing>
# e.g. ./scripts/bump-oss-version.js 0.28.0-rc.1
````

-------------------
Expand Down Expand Up @@ -141,8 +142,8 @@ git cherry-pick commitHash1
If everything worked:

```bash
node ./scripts/bump-oss-version.js <exact_version_you_are_releasing>
# e.g. node ./scripts/bump-oss-version.js 0.22.0
./scripts/bump-oss-version.js <exact_version_you_are_releasing>
# e.g. ./scripts/bump-oss-version.js 0.22.0
```

#### Update the release notes
Expand Down
19 changes: 14 additions & 5 deletions scripts/bump-oss-version.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
Expand All @@ -17,6 +18,13 @@
/*eslint-disable no-undef */
require(`shelljs/global`);

const minimist = require('minimist');

let argv = minimist(process.argv.slice(2), {
alias: {remote: 'r'},
default: {remote: 'origin'},
});

// - check we are in release branch, e.g. 0.33-stable
let branch = exec(`git symbolic-ref --short HEAD`, {silent: true}).stdout.trim();

Expand All @@ -30,7 +38,7 @@ 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];
let version = argv._[0];
if (!version || version.indexOf(versionMajor) !== 0) {
echo(`You must pass a tag like ${versionMajor}.[X]-rc[Y] to bump a version`);
exit(1);
Expand Down Expand Up @@ -77,17 +85,18 @@ if (exec(`git tag v${version}`).code) {
}

// Push newly created tag
exec(`git push origin v${version}`);
let remote = argv.remote;
exec(`git push ${remote} v${version}`);

// Tag latest if doing stable release
if (version.indexOf(`rc`) === -1) {
exec(`git tag -d latest`);
exec(`git push origin :latest`);
exec(`git push ${remote} :latest`);
exec(`git tag latest`);
exec(`git push origin latest`);
exec(`git push ${remote} latest`);
}

exec(`git push origin ${branch} --follow-tags`);
exec(`git push ${remote} ${branch} --follow-tags`);

exit(0);
/*eslint-enable no-undef */

0 comments on commit eb4be7a

Please sign in to comment.