From 21004d8faf53474d7a9d84376d03af51e66f5e31 Mon Sep 17 00:00:00 2001 From: Sutu Sebastian Date: Sat, 18 Jul 2026 01:18:54 +0300 Subject: [PATCH] fix: create git tags in release.ts for changesets/action Print New tag: only after an annotated tag exists so the Release workflow can push tags and open GitHub Releases instead of failing on missing refspecs. --- scripts/release.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/release.ts b/scripts/release.ts index 51513ac..04e1790 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -4,7 +4,8 @@ import { join } from "node:path"; // Bun cannot perform npm OIDC publishing. Pack with Bun to resolve `workspace:*`, // then publish the tarball with npm for OIDC authentication and provenance. -// `New tag: @` is consumed by changesets/action. +// Create an annotated git tag, then print `New tag: @` so +// changesets/action can push the tag and open a GitHub Release. // Existing registry versions are skipped so partial releases can be retried. import { $ } from "bun"; @@ -19,6 +20,14 @@ async function isAlreadyPublished( return res.exitCode === 0; } +async function ensureReleaseTag(tag: string): Promise { + const exists = await $`git rev-parse -q --verify ${`refs/tags/${tag}`}` + .quiet() + .nothrow(); + if (exists.exitCode === 0) return; + await $`git tag -a ${tag} -m ${tag}`; +} + let published = 0; for (const entry of readdirSync(PACKAGES_DIR, { withFileTypes: true })) { if (!entry.isDirectory()) continue; @@ -48,7 +57,9 @@ for (const entry of readdirSync(PACKAGES_DIR, { withFileTypes: true })) { } await $`npm publish ${tarball} --provenance --access public`.cwd(dir); - console.log(`New tag: ${pkg.name}@${pkg.version}`); + const tag = `${pkg.name}@${pkg.version}`; + await ensureReleaseTag(tag); + console.log(`New tag: ${tag}`); published++; }