Skip to content

Commit 22187e0

Browse files
ci(release): repair orphaned draft tag_name on retag
When the git tag was deleted and re-created between draft creation and merge, GitHub orphaned the draft release: tag_name became "untagged-<hash>" while `name` was preserved. The finalize step looked up the draft by tag_name and threw `Draft release for <tag> not found`, blocking the release. Fall back to matching by `name` only when the candidate is the GitHub-orphaned form (tag_name matches /^untagged-/), repair the draft's tag_name via updateRelease, then publish. Hard-fail is preserved when neither lookup matches. Same failure recurred on the v1.4.1 finalize run; this commit prevents recurrence but does not auto-recover the stuck v1.4.2 draft. Assisted-By: Claude <[email protected]> Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent 92000f1 commit 22187e0

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

‎.github/workflows/pull-requests-release.yaml‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,30 @@ jobs:
159159
per_page: 100
160160
});
161161
162-
// Find draft release to publish
163-
const draft = releases.data.find(r => r.tag_name === tag && r.draft);
164-
if (!draft) throw new Error(`Draft release for ${tag} not found`);
162+
// Find draft release to publish.
163+
//
164+
// Normally the draft was created by tags.yaml with tag_name === tag.
165+
// But if the git tag was deleted and re-created between draft creation
166+
// and merge (e.g. the release branch was force-updated), GitHub orphans
167+
// the draft: tag_name becomes "untagged-<hash>" while `name` is kept.
168+
// Fall back to matching by `name` and repair the draft's tag_name
169+
// before publishing — otherwise the published release would not point
170+
// at the real git tag.
171+
let draft = releases.data.find(r => r.draft && r.tag_name === tag);
172+
if (!draft) {
173+
const orphan = releases.data.find(r =>
174+
r.draft && r.name === tag && /^untagged-/.test(r.tag_name)
175+
);
176+
if (!orphan) throw new Error(`Draft release for ${tag} not found`);
177+
console.log(`🔧 Repairing orphaned draft ${orphan.id}: tag_name '${orphan.tag_name}' -> '${tag}'`);
178+
const repaired = await github.rest.repos.updateRelease({
179+
owner: context.repo.owner,
180+
repo: context.repo.repo,
181+
release_id: orphan.id,
182+
tag_name: tag
183+
});
184+
draft = repaired.data;
185+
}
165186
166187
// Find max semver among published releases (excluding current draft)
167188
const publishedReleases = releases.data

0 commit comments

Comments
 (0)