From 3453c02b6a0708400dd2228eb9a192180b361caa Mon Sep 17 00:00:00 2001 From: JeffreyChen Date: Sun, 17 May 2026 20:20:55 +0800 Subject: [PATCH] Fix publish-release: getReleaseByTag does not return drafts The publish-release job's actions/github-script step called github.rest.repos.getReleaseByTag(tag='v0.1.6') and got HTTP 404 even though the draft release existed. Root cause: per https://docs.github.com/rest/releases/releases#get-a-release-by-tag-name 'You cannot get a draft release by its tag name.' The whole point of the create-draft -> build-nuitka -> publish-release pattern is that the release IS still a draft when publish-release fires; the entire pipeline broke because the lookup it relies on explicitly excludes drafts. Switch to github.paginate(github.rest.repos.listReleases) (which DOES include drafts) and find() by tag_name. Error message now includes the actual list of existing tag names so a future mismatch is easy to diagnose. Cleanup applied out-of-band: - v0.1.6 unmarked draft manually so it surfaces in the sidebar. - v0.1.3 / v0.1.4 / v0.1.5 drafts deleted (their corresponding builds had failed at earlier stages; the PyPI versions stand but the GitHub releases were stale). --- .github/workflows/release.yml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 52461c6..3edb5eb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -370,12 +370,26 @@ jobs: script: | const tag = "v${{ needs.bump-version.outputs.version }}"; const { owner, repo } = context.repo; - const release = await github.rest.repos.getReleaseByTag({ - owner, repo, tag, - }); + + // getReleaseByTag returns 404 for DRAFT releases — per + // https://docs.github.com/rest/releases/releases#get-a-release-by-tag-name + // "You cannot get a draft release by its tag name." + // Enumerate via listReleases (which DOES include drafts) + // and filter by tag name instead. + const releases = await github.paginate( + github.rest.repos.listReleases, + { owner, repo, per_page: 100 }, + ); + const release = releases.find(r => r.tag_name === tag); + if (!release) { + throw new Error( + `No release found with tag ${tag}. Existing: ` + + releases.map(r => r.tag_name).join(", "), + ); + } await github.rest.repos.updateRelease({ owner, repo, - release_id: release.data.id, + release_id: release.id, draft: false, }); - console.log(`Released ${tag} (${release.data.html_url})`); + console.log(`Released ${tag} (${release.html_url})`);