File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed
Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ const request = require('request');
2121const { getBranchName, exitIfNotOnGit} = require ( './scm-utils' ) ;
2222
2323const { parseVersion, isReleaseBranch} = require ( './version-utils' ) ;
24+ const { failIfTagExists} = require ( './release-utils' ) ;
2425
2526let argv = yargs
2627 . option ( 'r' , {
@@ -75,6 +76,7 @@ async function main() {
7576 ) ;
7677 const token = argv . token ;
7778 const releaseVersion = argv . toVersion ;
79+ failIfTagExists ( releaseVersion ) ;
7880
7981 const { pushed} = await inquirer . prompt ( {
8082 type : 'confirm' ,
Original file line number Diff line number Diff line change 2121const { echo, exec, exit} = require ( 'shelljs' ) ;
2222const yargs = require ( 'yargs' ) ;
2323const { isReleaseBranch, parseVersion} = require ( './version-utils' ) ;
24+ const { failIfTagExists} = require ( './release-utils' ) ;
2425
2526const argv = yargs
2627 . option ( 'r' , {
@@ -49,6 +50,8 @@ const releaseVersion = argv.toVersion;
4950const isLatest = argv . latest ;
5051const isDryRun = argv . dryRun ;
5152
53+ failIfTagExists ( releaseVersion ) ;
54+
5255if ( branch && ! isReleaseBranch ( branch ) && ! isDryRun ) {
5356 console . error ( `This needs to be on a release branch. On branch: ${ branch } ` ) ;
5457 exit ( 1 ) ;
Original file line number Diff line number Diff line change @@ -111,8 +111,27 @@ function generateiOSArtifacts(
111111 return tarballOutputPath ;
112112}
113113
114+ function failIfTagExists ( version ) {
115+ if ( checkIfTagExists ( releaseVersion ) ) {
116+ echo ( `Tag v${ releaseVersion } already exists.` ) ;
117+ echo ( 'You may want to rollback the last commit' ) ;
118+ echo ( 'git reset --hard HEAD~1' ) ;
119+ exit ( 1 ) ;
120+ }
121+ }
122+
123+ function checkIfTagExists ( version ) {
124+ const { code, stdout} = exec ( 'git tag -l' , { silent : true } ) ;
125+ if ( code !== 0 ) {
126+ throw new Error ( 'Failed to retrieve the list of tags' ) ;
127+ }
128+ const tags = new Set ( stdout . split ( '\n' ) ) ;
129+ return tags . has ( `v${ version } ` ) ;
130+ }
131+
114132module . exports = {
115133 generateAndroidArtifacts,
116134 generateiOSArtifacts,
117135 publishAndroidArtifactsToMaven,
136+ failIfTagExists,
118137} ;
You can’t perform that action at this time.
0 commit comments