diff --git a/apps/desktop/scripts/release-codeberg.mjs b/apps/desktop/scripts/release-codeberg.mjs index 0f07064791..f731925afd 100644 --- a/apps/desktop/scripts/release-codeberg.mjs +++ b/apps/desktop/scripts/release-codeberg.mjs @@ -57,6 +57,17 @@ async function api(path, init = {}) { async function getOrCreateRelease(tagName, { prerelease = false } = {}) { let res = await api(`/repos/${OWNER}/${REPO}/releases/tags/${encodeURIComponent(tagName)}`); if (res.status === 404) { + // The tag MUST already exist on the forge, arriving via the git.utn.lol + // push-mirror. If we let the release API auto-create it, the next mirror + // sync prunes the forge-only tag and Forgejo silently demotes the release + // to a hidden draft (this ate v1.0.2's release page overnight). + const tagRes = await api(`/repos/${OWNER}/${REPO}/tags/${encodeURIComponent(tagName)}`); + if (tagRes.status === 404) { + throw new Error( + `Tag ${tagName} not found on ${OWNER}/${REPO}. Push it to the source repo first ` + + `(git push origin ${tagName}) and wait for the mirror to sync.`, + ); + } res = await api(`/repos/${OWNER}/${REPO}/releases`, { method: "POST", headers: { "Content-Type": "application/json" },