fix: add v prefix to version in container build download URL#323
fix: add v prefix to version in container build download URL#323
Conversation
GoReleaser sets main.version without the "v" prefix (e.g. "1.2.0"), but GitHub release tags include it (e.g. "v1.2.0"). This caused container image builds to fail with "tar: invalid magic" because curl was silently downloading a 404 page instead of the tarball. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes container image builds for release versions by ensuring the GitHub release tag used in the download URL includes the expected v prefix (aligning GoReleaser main.version values like 1.2.0 with GitHub tags like v1.2.0).
Changes:
- Normalize release download tags in
pluralDownloadBlock()by adding avprefix when missing. - Add a unit test covering version strings without the
vprefix.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/container/build.go | Prefixes release version with v before constructing the GitHub release download URL. |
| internal/container/build_test.go | Adds a test case verifying that 1.2.0 becomes /download/v1.2.0/ in the generated block. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
internal/container/build.go
Outdated
| tag := version | ||
| if !strings.HasPrefix(tag, "v") { | ||
| tag = "v" + tag | ||
| } | ||
| fmt.Fprintf(&b, "RUN curl -sfL \"https://github.com/zhubert/plural/releases/download/%s/plural_Linux_%s.tar.gz\" | tar -xz -C /tmp plural && \\\n", tag, arch) |
There was a problem hiding this comment.
The curl ... | tar ... pipeline can produce misleading errors and may not clearly surface HTTP failures (e.g., 404s) because the pipeline status is driven by tar. Consider downloading to a file first (or otherwise ensuring the curl exit status is checked explicitly) so build failures point to the real download error.
Download to a temp file first so curl failures (e.g. 404) surface clearly instead of producing misleading tar errors like "invalid magic". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
main.versionwithout thevprefix (e.g.1.2.0), but GitHub release tags include it (v1.2.0)tar: invalid magicbecausecurl -sfdownloaded a 404 page instead of the tarballpluralDownloadBlock()now ensures the version has avprefix before constructing the download URLTest plan
TestPluralDownloadBlock/version_without_v_prefix_gets_v_added— new test case🤖 Generated with Claude Code