diff --git a/scripts/release.js b/scripts/release.js index 406f35f..f36aa07 100755 --- a/scripts/release.js +++ b/scripts/release.js @@ -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;