feat: split build.tmpl.yml into pure Go and CGo variants#26
Conversation
📝 WalkthroughWalkthroughThe release configuration is split into base and CGO-specific GoReleaser templates. The legacy aggregator and test configurations are updated, README guidance is expanded, and a no-CGO fixture with Docker-based validation is added. ChangesGoReleaser template split
Estimated code review effort: 4 (Complex) | ~45 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
build-base.tmpl.yml (1)
45-46: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove redundant
-tags=json1for a no-CGO build.The
static-nosqlitebuild correctly disables CGO (CGO_ENABLED=0), meaning the SQLite driver will not be compiled. Passingjson1as a build tag is redundant and can be confusing in a template dedicated to non-SQLite builds.♻️ Proposed refactor
- id: static-nosqlite - flags: - - "-tags=json1" ldflags:🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@build-base.tmpl.yml` around lines 45 - 46, Remove the redundant "-tags=json1" entry from the flags configuration in build-base.tmpl.yml, leaving the no-CGO static-nosqlite build without the SQLite-specific build tag.test/no-cgo/.goreleaser.yml (1)
1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd
version: 2to the configuration.GoReleaser v2 configurations should explicitly declare their version. Since the included
build-base.tmpl.ymlis a v2 template, declaringversion: 2at the root ensures consistent parsing and compatibility.♻️ Proposed refactor
+version: 2 + includes:🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/no-cgo/.goreleaser.yml` at line 1, Add the GoReleaser configuration version declaration at the root of the no-CGO configuration, alongside the existing includes entry, setting it to version 2 so it matches the included build-base.tmpl.yml template.test/no-cgo/.docker/Dockerfile-goreleaser (1)
5-5: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove redundant file path in
ADDinstruction.The source path
test/no-cgo/go.modis specified twice. Providing identical source arguments toADDis redundant and can be simplified.♻️ Proposed refactor
-ADD test/no-cgo/go.mod test/no-cgo/go.mod ./ +ADD test/no-cgo/go.mod ./🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/no-cgo/.docker/Dockerfile-goreleaser` at line 5, Update the Dockerfile’s ADD instruction to include test/no-cgo/go.mod only once as the source, while preserving ./ as the destination.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@build-base.tmpl.yml`:
- Line 88: Update the SBOM output filename in the CycloneDX command to remove
the `_sqlite_` segment, matching the filename expected by the subsequent hook
while preserving the existing project, version, target, and `.bom.json`
components.
---
Nitpick comments:
In `@build-base.tmpl.yml`:
- Around line 45-46: Remove the redundant "-tags=json1" entry from the flags
configuration in build-base.tmpl.yml, leaving the no-CGO static-nosqlite build
without the SQLite-specific build tag.
In `@test/no-cgo/.docker/Dockerfile-goreleaser`:
- Line 5: Update the Dockerfile’s ADD instruction to include test/no-cgo/go.mod
only once as the source, while preserving ./ as the destination.
In `@test/no-cgo/.goreleaser.yml`:
- Line 1: Add the GoReleaser configuration version declaration at the root of
the no-CGO configuration, alongside the existing includes entry, setting it to
version 2 so it matches the included build-base.tmpl.yml template.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ce470eea-fb77-438a-be2f-b333296a3c00
📒 Files selected for processing (11)
.github/workflows/docker-test.ymlREADME.mdbuild-base.tmpl.ymlbuild-cgo.tmpl.ymlbuild.tmpl.ymltest/.goreleaser.ymltest/no-cgo/.docker/Dockerfile-distroless-statictest/no-cgo/.docker/Dockerfile-goreleasertest/no-cgo/.goreleaser.ymltest/no-cgo/go.modtest/no-cgo/main.go
The base template's before hook runs 'git checkout -- go.sum go.mod', which requires a tracked go.sum even for a dependency-free module. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
build-base.tmpl.yml now ships no-CGO variants of the Homebrew formula, the Alpine Docker images, and the main :tag/:major/:minor/:patch/:latest manifests, built from the pure-Go 'default' binaries. They are gated on the internal 'cgo' variable: build-cgo.tmpl.yml sets it to true, which disables the base variants (via templated skip_upload/skip_build/skip_push) so the CGO-built ones are published instead. Including both templates therefore behaves exactly as before. Verified against goreleaser-pro 2.15.2 and 2.12.5 (the CI image version): include variables merge with later-include-wins precedence, list sections append, templated skip fields are honored, and duplicate image tags are fine when one entry's build is skipped. The Homebrew upload is also skipped when brew_name is unset. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
build-base.tmpl.yml (1)
183-270: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDedup repeated OCI label blocks and image-template lists with YAML anchors.
The four
alpine-nocgo-*dockersentries each repeat the identical 8-linebuild_flag_templateslabel block (Lines 196-203, 217-224, 239-246, 261-268), and theimage_templateslist ({{ .Tag }}-amd64/-arm64/-armv7/-armv6) is duplicated acrosstag-nocgo,major-nocgo,minor-nocgo,patch-nocgo,latest-nocgo. Since none of these blocks vary per entry, a YAML anchor/alias avoids the duplication without touching GoReleaser's schema (the alias just inlines the same list, so strict-unmarshal validation is unaffected).♻️ Example anchor-based dedup
- id: alpine-nocgo-amd64 ... - build_flag_templates: + build_flag_templates: &oci_labels - "--label=org.opencontainers.image.title={{ .ProjectName }}" - "--label=org.opencontainers.image.vendor=Ory" - "--label=org.opencontainers.image.version={{ .Version }}" - "--label=org.opencontainers.image.created={{ .Date }}" - "--label=org.opencontainers.image.source={{ .GitURL }}" - "--label=org.opencontainers.image.revision={{ .FullCommit }}" - "--label=org.opencontainers.image.url=https://www.ory.sh" - "--label=org.opencontainers.image.documentation=https://www.ory.sh/docs" - "--platform=linux/amd64"- id: alpine-nocgo-arm64 ... - build_flag_templates: - - "--label=org.opencontainers.image.title={{ .ProjectName }}" - - "--label=org.opencontainers.image.vendor=Ory" - - "--label=org.opencontainers.image.version={{ .Version }}" - - "--label=org.opencontainers.image.created={{ .Date }}" - - "--label=org.opencontainers.image.source={{ .GitURL }}" - - "--label=org.opencontainers.image.revision={{ .FullCommit }}" - - "--label=org.opencontainers.image.url=https://www.ory.sh" - - "--label=org.opencontainers.image.documentation=https://www.ory.sh/docs" - - "--platform=linux/arm64/v8" + build_flag_templates: + - *oci_labels + - "--platform=linux/arm64/v8"(similarly for the
armv7/armv6entries, and for the repeatedimage_templateslist indocker_manifests)Since GoReleaser's config parser is external, please confirm anchors/aliases parse cleanly with the pinned
goreleaserversion before adopting.Also applies to: 271-318
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@build-base.tmpl.yml` around lines 183 - 270, Deduplicate the repeated OCI label blocks in the four alpine-nocgo entries and the shared image_templates list across the nocgo docker_manifests using YAML anchors and aliases. Define each anchor once and reference it from the relevant build_flag_templates or image_templates fields without changing GoReleaser’s schema or per-architecture values; validate that the pinned GoReleaser version parses the anchored configuration successfully.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/no-cgo/.docker/Dockerfile-alpine`:
- Line 1: Update the base image in the Dockerfile’s FROM directive from obsolete
Alpine 3.12 to a supported release, using Alpine 3.21 or newer.
---
Nitpick comments:
In `@build-base.tmpl.yml`:
- Around line 183-270: Deduplicate the repeated OCI label blocks in the four
alpine-nocgo entries and the shared image_templates list across the nocgo
docker_manifests using YAML anchors and aliases. Define each anchor once and
reference it from the relevant build_flag_templates or image_templates fields
without changing GoReleaser’s schema or per-architecture values; validate that
the pinned GoReleaser version parses the anchored configuration successfully.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a872b8af-943d-421b-826e-e6fc6201c41c
⛔ Files ignored due to path filters (1)
test/no-cgo/go.sumis excluded by!**/*.sum
📒 Files selected for processing (6)
README.mdbuild-base.tmpl.ymlbuild-cgo.tmpl.ymltest/no-cgo/.docker/Dockerfile-alpinetest/no-cgo/.docker/Dockerfile-goreleasertest/no-cgo/.goreleaser.yml
🚧 Files skipped from review as they are similar to previous changes (3)
- test/no-cgo/.goreleaser.yml
- README.md
- build-cgo.tmpl.yml
| @@ -0,0 +1,5 @@ | |||
| FROM alpine:3.12 | |||
There was a problem hiding this comment.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
alpine:3.12 is obsolete. Bump this fixture to a supported Alpine release such as 3.21+.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@test/no-cgo/.docker/Dockerfile-alpine` at line 1, Update the base image in
the Dockerfile’s FROM directive from obsolete Alpine 3.12 to a supported
release, using Alpine 3.21 or newer.
What
Splits the monolithic
build.tmpl.yml(600 lines) into two composable templates, keeping the original filename as a backward-compatible aggregator:build-base.tmpl.yml— shared infrastructure (variables, cosign signing, checksum, release, changelog) plus theCGO_ENABLED=0builds (default,static-nosqlite), their archives, the distroless Docker images, and the*-distrolessmanifests. Needs no C toolchain.build-cgo.tmpl.yml— the seven CGO builds (macOS, glibc/musl Linux amd64/arm64/arm, Windows mingw), their archives,universal_binaries, Homebrew, Scoop, the Alpine Docker images, and the:tag/:major/:minor/:patch/:latestmanifests.build.tmpl.yml— now a thin aggregator that pulls in both via nestedfrom_urlincludes. Existing consumers need no changes.Why
Projects without SQLite/HSM (e.g.
ory/cli) can now include onlybuild-base.tmpl.ymland drop the entire CGO build matrix — no cross-compilers, much faster releases — while still publishing distroless images and manifests.Verification
builds/archives/docker_manifestsdiffers, which does not affect produced artifacts).test/.goreleaser.ymlnow includes both files, so the existing CI docker test validates the full-matrix merge path (a list overwrite instead of append would fail the run via the danglingstatic-nosqlitebuild id reference).test/no-cgo/mini-project exercises the base-only path end to end; wired into the CI workflow as a second step.Notes for reviewers
includesrequires GoReleaser Pro, which the image already ships (2.12.5). Docs state files are "included recursively", which the aggregator relies on.from_urlchain cannot be tested pre-merge (its URLs point atmaster, where the new files don't exist yet), making the switchover atomic at merge time. Recommend a manualgoreleaser check/snapshot against the real URL chain after merge, before cutting a downstream release.🤖 Generated with Claude Code
Summary by CodeRabbit