Do not overwrite tags

This commit is contained in:
2026-03-11 15:50:47 +01:00
parent d47007d905
commit 45aae46925

View File

@@ -55,6 +55,22 @@ function bumpSemver(current, spec) {
run(`git commit -m "chore(release): v${newVersion} - bump from v${oldVersion}"`); run(`git commit -m "chore(release): v${newVersion} - bump from v${oldVersion}"`);
committed = true; 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 // tag
run(`git tag -a v${newVersion} -m "Release v${newVersion}"`); run(`git tag -a v${newVersion} -m "Release v${newVersion}"`);
tagged = true; tagged = true;