Skip to content

Embed cloudbuild.yaml in cmrel so releases need no checkout - #376

Open
wallrj wants to merge 1 commit into
cert-manager:masterfrom
wallrj:embed-cloudbuild
Open

Embed cloudbuild.yaml in cmrel so releases need no checkout#376
wallrj wants to merge 1 commit into
cert-manager:masterfrom
wallrj:embed-cloudbuild

Conversation

@wallrj

@wallrj wallrj commented Sep 11, 2026

Copy link
Copy Markdown
Member

cmrel now carries its own Cloud Build configs, so a release manager only needs go install. No checkout of this repository is required, and there is nothing to keep in sync with the binary.

Why

The four commands that submit GCB jobs (stage, makestage, publish, bootstrap-pgp) read ./gcb/<cmd>/cloudbuild.yaml from the working directory. Since #334, publish also pins the GCB cmrel install to the commit the invoking binary was built from. So the binary and the checkout must match exactly, and nothing checks that they do. The two ways to get there today both have a trap:

Documented approach What goes wrong
go install cmrel@<tag> plus git checkout <tag> Two things to keep in sync. A stale checkout submits the wrong config, silently.
git checkout master and build from it Go stamps the binary vcs.modified=true if git status shows anything, including untracked files. The pin then refuses to run.

This came out of the v1.21.2 release: cert-manager/cert-manager#9237 (comment)

What changes

  • New package gcb at the repo root embeds the four cloudbuild.yaml files with go:embed.
  • --cloudbuild defaults to empty, meaning the embedded config. Passing a path still works and logs a warning, so cmrel development against a modified YAML (for example Mint GitHub tokens for publish through octo-sts instead of a stored PAT #373) is unaffected.
  • pkg/gcb.ParseBuild is split out of LoadBuild so both paths share the decoder.
  • Two tests: every embedded config parses, and the publish config keeps the fail-closed _RELEASE_REPO_REF placeholder. make test now runs ./gcb.

The KMS-encrypted token blob in publish/cloudbuild.yaml is already public in this repository, so embedding it in the binary does not change what is exposed.

After this merges

The release process docs shrink to one line, with no clone step:

go install github.com/cert-manager/release/cmd/cmrel@master

@master resolves through the module proxy to a pseudo-version, which pkg/releaseref already accepts, so GCB installs that exact commit. I will open the website PR once this is in.

Evidence: untracked files break the build-from-checkout path

Built from a clean master checkout that had one untracked directory:

$ go build -o /tmp/cmrel ./cmd/cmrel && go version -m /tmp/cmrel | grep -E 'vcs\.(revision|modified)|^\s*mod'
	mod	github.com/cert-manager/release	v1.13.0+dirty
	build	vcs.revision=01727dcc9711d448985b9aaa129d875b323d6e74
	build	vcs.modified=true

pkg/releaseref.Resolve rejects that binary: https://github.com/cert-manager/release/blob/v1.13.0/pkg/releaseref/releaseref.go#L61-L66

Testing
$ make test
go test ./cmd/cmrel/cmd/...
ok  	github.com/cert-manager/release/cmd/cmrel/cmd	0.032s
go test ./gcb
ok  	github.com/cert-manager/release/gcb	0.015s
go test ./pkg/release
ok  	github.com/cert-manager/release/pkg/release	0.016s
go test ./pkg/release/helm
ok  	github.com/cert-manager/release/pkg/release/helm	0.007s
go test ./pkg/release/manifests
ok  	github.com/cert-manager/release/pkg/release/manifests	0.007s
go test ./pkg/sign
ok  	github.com/cert-manager/release/pkg/sign	0.022s

[Claude Fable 5.1]

cmrel stage, makestage, publish and bootstrap-pgp read their Cloud Build
config from ./gcb/<cmd>/cloudbuild.yaml, so a release manager had to run
cmrel from a checkout of this repository. Since cert-manager#334 the publish job also
pins its own cmrel install to the commit the invoking binary was built
from, which means the checkout and the binary have to match exactly, and
nothing checks that they do. A stale checkout submits the wrong config
silently. Building from the checkout instead is fragile too: Go marks the
binary as modified if git status shows anything, including untracked
files, and the pin then refuses to run.

Embed the four configs in the binary. The config is now bound to the same
commit as the pin, so `go install github.com/cert-manager/release/cmd/cmrel@<ref>`
is the whole install procedure. --cloudbuild stays as an override for
cmrel development and defaults to the embedded config.

The tests fail if an embedded config stops parsing or if the publish
config loses its fail-closed _RELEASE_REPO_REF placeholder.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Richard Wall <[email protected]>
@cert-manager-prow cert-manager-prow Bot added the dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. label Sep 11, 2026
@cert-manager-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign maelvls for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant