Skip to content

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

Merged
cert-manager-prow[bot] merged 2 commits into
cert-manager:masterfrom
wallrj:embed-cloudbuild
Nov 25, 2026
Merged

cert-manager-prow[bot] merged 2 commits 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]

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the embedded Cloud Build configuration changes.

No open issues 🎉

What changed in this PR

This PR embeds Cloud Build configurations in cmrel, removing the need for a local repository checkout and keeping default configurations aligned with the installed binary.

Changes:

  • Switches all four Cloud Build commands to embedded configurations by default, while preserving explicit --cloudbuild overrides with a warning.
  • Shares YAML decoding between embedded configurations and file-based overrides.
  • Adds configuration parsing and publish pin-placeholder tests, integrates them into make test, and updates CLI documentation.
File Description
README.md Documents the embedded default and development-only override.
pkg/​gcb/​gcb.go Extracts ParseBuild for shared YAML decoding.
Makefile Adds embedded configuration tests to make test.
gcb/​embed.go Embeds the four Cloud Build configurations.
gcb/​embed_test.go Tests parsing and the publish fail-closed pin placeholder.
cmd/​cmrel/​cmd/​stage.go Defaults staging to its embedded configuration.
cmd/​cmrel/​cmd/​publish.go Uses the embedded publish configuration and adjusts the pin warning.
cmd/​cmrel/​cmd/​makestage.go Defaults make-based staging to its embedded configuration.
cmd/​cmrel/​cmd/​cloudbuild.go Adds shared loading logic, override warnings, and flag help.
cmd/​cmrel/​cmd/​bootstrap_pgp.go Defaults PGP bootstrapping to its embedded configuration.

Review effort: Balanced

@wallrj-cyberark

Copy link
Copy Markdown
Member

This PR worked in the v1.22.0-alpha.0 release. I published it with a cmrel installed by go install, with no checkout of this repository.

We tested it stacked with #377 and #431 on the branch v1.22.0-alpha.0-cmrel, so this shows the three work together, not each one alone.

Evidence from the release
  • cmrel came from go install github.com/cert-manager/release/cmd/cmrel@d17b8971b197, run from a directory with no gcb/ folder.

  • All three publish runs (dry run, first real run, rerun) logged:

    Using the cloudbuild.yaml embedded in this binary
    Pinning GCB cmrel install to cert-manager/[email protected]
    
  • The --cloudbuild override also worked. I staged with cmrel makestage --cloudbuild <file> to pass an extra make variable, and it logged WARNING: --cloudbuild set; loading cloudbuild.yaml from "makestage-alpha0.yaml" instead of the embedded config.

  • The pin works with a go installed binary. The version comes from the module pseudo-version, because a module build has no vcs.revision stamp.

What this release did not test
  • cmrel stage (the Bazel-era command) and bootstrap-pgp did not run.
  • The embedded makestage config has no serviceAccount, unlike the tag-triggered build and publish. I added one to my override file, because the default Cloud Build account probably cannot use the KMS key. That should be fixed in a follow-up.

[with Claude]

@SgtCoDFish SgtCoDFish left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

Glorious, wanted to see this for a while 🚀

@cert-manager-prow cert-manager-prow Bot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 25, 2026
wallrj and others added 2 commits November 25, 2026 12:19
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]>
- README: say that cmrel development needs --cloudbuild, because an
  installed cmrel ignores edits to the files in gcb/.
- publish: fail before submitting when --skip-cmrel-pin is set and
  _RELEASE_REPO_REF is still the placeholder. Previously the job
  failed inside GCB.
- Correct the --cloudbuild help. Only publish pins cmrel, so the help
  no longer claims that every config matches a pinned commit.
- Log when the embedded config is used, so a release log records it.
- loadCloudBuild always returns a non-nil Substitutions map. A config
  with no substitutions block used to cause a nil map panic.
- Embed the configs as strings so that importers cannot modify them.
- Say in the CloudBuildFile comments that empty means embedded.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Richard Wall <[email protected]>
@cert-manager-prow cert-manager-prow Bot removed the lgtm Indicates that a PR is ready to be merged. label Nov 25, 2026

@SgtCoDFish SgtCoDFish left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

🚀

@cert-manager-prow cert-manager-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Nov 25, 2026
@cert-manager-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SgtCoDFish

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

The pull request process is described 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

@cert-manager-prow
cert-manager-prow Bot merged commit 15e9d36 into cert-manager:master Nov 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. lgtm Indicates that a PR is ready to be merged. 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.

4 participants