Do not overwrite tags
This commit is contained in:
@@ -55,6 +55,22 @@ function bumpSemver(current, spec) {
|
||||
run(`git commit -m "chore(release): v${newVersion} - bump from v${oldVersion}"`);
|
||||
committed = true;
|
||||
|
||||
// ensure tag doesn't already exist locally
|
||||
let localTagExists = false;
|
||||
try {
|
||||
runOutput(`git rev-parse --verify refs/tags/v${newVersion}`);
|
||||
localTagExists = true;
|
||||
} catch (_) {
|
||||
localTagExists = false;
|
||||
}
|
||||
if (localTagExists) throw new Error(`Tag v${newVersion} already exists locally — aborting to avoid overwrite.`);
|
||||
|
||||
// ensure tag doesn't exist on remote
|
||||
const remoteTagInfo = (() => {
|
||||
try { return runOutput(`git ls-remote --tags origin v${newVersion}`); } catch (_) { return ""; }
|
||||
})();
|
||||
if (remoteTagInfo) throw new Error(`Tag v${newVersion} already exists on remote — aborting to avoid overwrite.`);
|
||||
|
||||
// tag
|
||||
run(`git tag -a v${newVersion} -m "Release v${newVersion}"`);
|
||||
tagged = true;
|
||||
|
||||
Reference in New Issue
Block a user