Use list-releases endpoint to find draft releases by tag - #298
Merged
Conversation
The release job creates the GitHub release as a draft so assets
stay mutable until the final publish. GitHub's
GET /releases/tags/{tag} endpoint omits draft releases, so the
by-tag lookup always 404'd and publish-release could never find
the draft to flip — failing every release with "no GitHub
release found for tag".
List releases via GET /releases and match on tag_name (drafts
are only visible there), following Link-header pagination since
a fresh draft is not guaranteed to land on the first page.
https://claude.ai/code/session_01F3gFEBvZLjWfAuoqcMNoSZ
Contributor
There was a problem hiding this comment.
Pull request overview
Switches GitHub release lookup from the by-tag endpoint to the list-releases endpoint so that draft releases (which the by-tag endpoint hides) can be discovered, with Link-header pagination support to handle workspaces where the draft is not on page 1.
Changes:
- Replace
GET /releases/tags/{tag}with paginatedGET /releases?per_page=100, matching bytag_name. - Add
nextPageURL()helper to parse the RFC 5988 Link header forrel="next". - Update tests to return list responses and add coverage for pagination and Link parsing.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/release/publishrelease.go | Replaces by-tag GET with paginated list-releases lookup; adds lookupReleasePage and nextPageURL; adds TagName to releaseRef; drops net/url. |
| internal/release/publishrelease_test.go | Updates existing tests to list-shaped JSON; adds pagination and Link-header parsing tests. |
| cmd/mdsmith-release/publishrelease_test.go | Updates lookup response to list shape with tag_name. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes the release lookup logic to use the GitHub list-releases endpoint instead of the by-tag endpoint. This is necessary because the by-tag endpoint deliberately omits draft releases, but the release job creates releases as drafts to keep assets mutable until final publication.
Key Changes
/releases/tags/{tag}request with pagination through the list-releases endpointnextPageURL()helper to parse GitHub's Link header and follow pagination to find draft releases that may not appear on the first pagelookupReleasePage()to handle individual page requests and tag matchingTagNamefield to support matching releases by tag name when iterating through paginated resultsurl.PathEscape()Implementation Details
lookupReleaseRef()function now loops through paginated results, callinglookupReleasePage()for each pagelookupReleasePage()decodes a list of releases and searches for a matching tag name, returning the next page URL from the Link headernextPageURL()parses the RFC 5988 Link header format to extract therel="next"URL for paginationTestPublishReleaseFollowsPaginationToFindDraft()to verify pagination works correctlyTestNextPageURL()to unit test the Link header parsing logichttps://claude.ai/code/session_01F3gFEBvZLjWfAuoqcMNoSZ