Made npm deployment to be independent of git tags cache
Summary: Fixes npm deployment script as in https://circleci.com/gh/facebook/react-native/6745. Example situation: - admin is ready to release 0.26.0 - admin adds tag v0.26.0 and pushes to origin - Circle CI build fails because of code error - admin cherry-picks a fix and tags v0.26.0 again and pushes to origin - Circle does not update local tag v0.26.0 because it already has it cached, compiles the code but fails to deploy to npm because v0.26.0 is not on branch HEAD from Circle point of view The previous version of the script was checking the tags on current commit as well but it used the local branch tags. This change fetches tags from `origin` fresh and allows us to redeploy the same version multiple times. Closes https://github.com/facebook/react-native/pull/7619 Differential Revision: D3334469 fbshipit-source-id: b423fc19516dc4f5f7f2605224e62b8a378c8a7d
This commit is contained in:
parent
a3f50ec8a0
commit
5d06402b4a
|
@ -60,12 +60,17 @@ if (buildBranch.indexOf(`-stable`) !== -1) {
|
|||
exit(0);
|
||||
}
|
||||
|
||||
// ['latest', 'v0.33.0', 'v0.33.0-rc', 'v0.33.0-rc1', 'v0.33.0-rc2', 'v0.34.0', '']
|
||||
const tagsWithVersion = exec(`git tag -l --points-at HEAD`).stdout.split(/\s/)
|
||||
// ['v0.33.0', 'v0.33.0-rc', 'v0.33.0-rc1', 'v0.33.0-rc2', 'v0.34.0']
|
||||
.filter(version => !!version && version.indexOf(`v${branchVersion}`) === 0)
|
||||
// 34c034298dc9cad5a4553964a5a324450fda0385
|
||||
const currentCommit = exec(`git rev-parse HEAD`, {silent: true}).stdout.trim();
|
||||
// [34c034298dc9cad5a4553964a5a324450fda0385, refs/heads/0.33-stable, refs/tags/latest, refs/tags/v0.33.1, refs/tags/v0.34.1-rc]
|
||||
const tagsWithVersion = exec(`git ls-remote origin | grep ${currentCommit}`, {silent: true})
|
||||
.stdout.split(/\s/)
|
||||
// ['refs/tags/v0.33.0', 'refs/tags/v0.33.0-rc', 'refs/tags/v0.33.0-rc1', 'refs/tags/v0.33.0-rc2', 'refs/tags/v0.34.0']
|
||||
.filter(version => !!version && version.indexOf(`refs/tags/v${branchVersion}`) === 0)
|
||||
// ['refs/tags/v0.33.0', 'refs/tags/v0.33.0-rc', 'refs/tags/v0.33.0-rc1', 'refs/tags/v0.33.0-rc2']
|
||||
.filter(version => version.indexOf(branchVersion) !== -1)
|
||||
// ['v0.33.0', 'v0.33.0-rc', 'v0.33.0-rc1', 'v0.33.0-rc2']
|
||||
.filter(version => version.indexOf(branchVersion) !== -1);
|
||||
.map(version => version.slice(`refs/tags/`.length));
|
||||
|
||||
if (tagsWithVersion.length === 0) {
|
||||
echo(`Error: Can't find version tag in current commit. To deploy to NPM you must add tag v0.XY.Z[-rc] to your commit`);
|
||||
|
|
Loading…
Reference in New Issue