mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
chore: fail prepare package for release if tag exists (#35305)
Summary: This PR makes sure that the `preapre_package_for_release` script fail fast if there is already a tag for the desired version on github. ## Changelog [General] [Added] - Make the `prepare_package_for_release` fail if there is already a git tag with that version Pull Request resolved: https://github.com/facebook/react-native/pull/35305 Test Plan: Tested manually. The script is currently only invoked during the release process. <img width="1238" alt="Screenshot 2022-11-10 at 12 24 03" src="https://user-images.githubusercontent.com/11162307/201090947-274c1b1c-0b6a-4619-bc85-fa60e5eaeee1.png"> Reviewed By: cortinico Differential Revision: D41403159 Pulled By: cipolleschi fbshipit-source-id: fb87df345b14568c750482e5c68be53551a9acbb
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5dd0f7327b
commit
850f855eb6
@@ -21,6 +21,7 @@ const request = require('request');
|
||||
const {getBranchName, exitIfNotOnGit} = require('./scm-utils');
|
||||
|
||||
const {parseVersion, isReleaseBranch} = require('./version-utils');
|
||||
const {failIfTagExists} = require('./release-utils');
|
||||
|
||||
let argv = yargs
|
||||
.option('r', {
|
||||
@@ -75,6 +76,7 @@ async function main() {
|
||||
);
|
||||
const token = argv.token;
|
||||
const releaseVersion = argv.toVersion;
|
||||
failIfTagExists(releaseVersion);
|
||||
|
||||
const {pushed} = await inquirer.prompt({
|
||||
type: 'confirm',
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
const {echo, exec, exit} = require('shelljs');
|
||||
const yargs = require('yargs');
|
||||
const {isReleaseBranch, parseVersion} = require('./version-utils');
|
||||
const {failIfTagExists} = require('./release-utils');
|
||||
|
||||
const argv = yargs
|
||||
.option('r', {
|
||||
@@ -49,6 +50,8 @@ const releaseVersion = argv.toVersion;
|
||||
const isLatest = argv.latest;
|
||||
const isDryRun = argv.dryRun;
|
||||
|
||||
failIfTagExists(releaseVersion);
|
||||
|
||||
if (branch && !isReleaseBranch(branch) && !isDryRun) {
|
||||
console.error(`This needs to be on a release branch. On branch: ${branch}`);
|
||||
exit(1);
|
||||
|
||||
@@ -117,8 +117,27 @@ function generateiOSArtifacts(
|
||||
return tarballOutputPath;
|
||||
}
|
||||
|
||||
function failIfTagExists(version) {
|
||||
if (checkIfTagExists(version)) {
|
||||
echo(`Tag v${version} already exists.`);
|
||||
echo('You may want to rollback the last commit');
|
||||
echo('git reset --hard HEAD~1');
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
function checkIfTagExists(version) {
|
||||
const {code, stdout} = exec('git tag -l', {silent: true});
|
||||
if (code !== 0) {
|
||||
throw new Error('Failed to retrieve the list of tags');
|
||||
}
|
||||
const tags = new Set(stdout.split('\n'));
|
||||
return tags.has(`v${version}`);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
generateAndroidArtifacts,
|
||||
generateiOSArtifacts,
|
||||
publishAndroidArtifactsToMaven,
|
||||
failIfTagExists,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user