Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/bump-oss-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down Expand Up @@ -75,6 +76,7 @@ async function main() {
);
const token = argv.token;
const releaseVersion = argv.toVersion;
failIfTagExists(releaseVersion);

const {pushed} = await inquirer.prompt({
type: 'confirm',
Expand Down
3 changes: 3 additions & 0 deletions scripts/prepare-package-for-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down Expand Up @@ -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);
Expand Down
19 changes: 19 additions & 0 deletions scripts/release-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};