feat(update): authenticate self-update downloads for private GitHub releases - #6
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📜 Recent review details🔇 Additional comments (6)
📝 WalkthroughWalkthroughThis PR implements authenticated GitHub asset downloads by centralizing HTTP header management in a ChangesAuthenticated GitHub Asset Downloads
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes self-update and .pkg installation failures for private GitHub releases by ensuring the configured GitHub token is used not only for release metadata fetches, but also for the actual asset download. When a token is present, downloads are performed via the GitHub Release Asset API URL with the required headers so GitHub can return a signed redirect to the artifact; without a token, the existing public browser_download_url path remains unchanged.
Changes:
- Add an authenticated asset download request builder (
Accept: application/octet-stream+Authorization: Bearer …) and decode each asset’s API URL (url) alongsidebrowser_download_url. - Route both the self-updater and
Pkg(.gitHub(...))installer through request-based downloads, including HTTP status checks. - Extend
ReleaseDescriptorto carry download headers and provide amakeDownloadRequest()helper; add targeted tests for decoding and request construction (including token trimming).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
Tests/AstrolabeTests/UpdateConfigurationTests.swift |
Adds tests for asset decoding, authenticated vs unauthenticated download request construction, and ReleaseDescriptor request building. |
Sources/Astrolabe/Update/UpdateSource.swift |
Extends ReleaseDescriptor with downloadHeaders and a helper to build a URLRequest. |
Sources/Astrolabe/Update/UpdateLoop.swift |
Switches updater download to use ReleaseDescriptor.makeDownloadRequest() so headers can be applied. |
Sources/Astrolabe/Update/GitHubReleaseSource.swift |
Builds the release descriptor using the shared authenticated download request builder (URL + headers). |
Sources/Astrolabe/Steps/Pkg/GitHubReleaseFetcher.swift |
Adds makeAssetDownloadRequest, trims tokens via a shared normalization helper, and decodes asset API URL from url. |
Sources/Astrolabe/Steps/Pkg/GitHubPackage.swift |
Uses authenticated download requests for .pkg installation and verifies HTTP status codes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
.githubToken(token)already flowed through to release-metadata fetches, but the actual asset download still hitbrowser_download_urlunauthenticated — so private repos returned 404 and the self-updater silently failed at the download step. This wires the token through the download path too.For private releases we now hit the release-asset API URL (
https://api.github.com/repos/{owner}/{repo}/releases/assets/{id}) withAccept: application/octet-stream+Authorization: Bearer <token>. GitHub responds with a signed redirect to the actual artifact. Public releases (no token) keep usingbrowser_download_urlunchanged.Changes
Steps/Pkg/GitHubReleaseFetcher.swiftmakeAssetDownloadRequest(asset:token:)builds the auth'd request; decodeurlfrom the asset payload intoapiURL; whitespace-trim tokens via sharednormalizedTokenhelper.Steps/Pkg/GitHubPackage.swiftPkg(.gitHub(...))uses the new request builder and checks the HTTP status on download.Update/GitHubReleaseSource.swiftReleaseDescriptornow carries the auth'd URL + headers built from the same helper.Update/UpdateSource.swiftReleaseDescriptorgainsdownloadHeadersand amakeDownloadRequest()convenience. Existing initializer stays source-compatible (headers default to[:]).Update/UpdateLoop.swiftTests/AstrolabeTests/UpdateConfigurationTests.swiftReleaseDescriptor.makeDownloadRequest()propagates headers.Test plan
swift test --filter UpdateConfigurationTests.githubToken(...)configured downloads and installs the.pkgNeed help on this PR? Tag
@codesmithwith what you need. Autofix is disabled.Summary by CodeRabbit
Bug Fixes
Tests