From 45aae46925426f628c4242d245429ec2a1edae29 Mon Sep 17 00:00:00 2001 From: maze Date: Wed, 11 Mar 2026 15:50:47 +0100 Subject: [PATCH] Do not overwrite tags --- scripts/release.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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;