Skip to content

Commit ce26ae4

Browse files
authored
feat(release): step control flags for hashrelease and release build/publish (#12615)
* feat(release): step control flags for build and publish commands Adds per-step control flags that gate logical release steps in build and publish commands. Factory flag pattern allows context-appropriate defaults and env vars per command. Mirror of calico-private changes (OSS subset). * fix(release): wire step control flags and tighten command parity - Gate updateHelmChartIndex on r.helmIndex instead of r.helmCharts - Gate buildReleaseTar on r.tarball (was unconditional) - Limit publishStepFlags to publish-only concerns, using envPublish* sources so PUBLISH_IMAGES / PUBLISH_CHARTS are honored again - Narrow OCP-bundle precheck to hashrelease, where --manifests actually gates the manifest copy step - Rename --operator env source to RELEASE_OPERATOR for consistency with other RELEASE_* step control vars - Switch hashreleasePublishFlags to productFlags and drop dead gitFlags - Register skipBranchCheckFlag on releaseBuildFlags; pass WithValidate / WithReleaseBranchValidation unconditionally in the release build action, matching hashrelease build - Drop skipValidationFlag from releasePublishFlags (unreferenced) * fix(operator): ensure correct log output for registry variables * fix(release): honor step-control flags at their actual build sites Previously most step-control flags only gated the collect-to-upload-dir step; the underlying build steps ran unconditionally, so setting --X=false did not save build time and the artifact still landed in the release tarball. Make each flag honest at the build site: - BuildHelm: gate chart build on --helm-charts; gate index build on --helm-index. Skipping charts implicitly skips the index. - buildBinaries: early-return on --binaries=false, independent of the existing --images fast-path. - buildOCPBundle: gate on --ocp-bundle. - Hashrelease windows targets in Build(): gate on --windows-archive. - buildReleaseTar: gate the manifests copy on --manifests and the binaries copy on --binaries (previously both unconditional). Refactor the hashrelease manifests/OCP dependency into a single buildManifests step. Manifests regen and OCP build now live together under one deferred resetManifests at Build() scope so downstream consumers (collectManifests, buildReleaseTar) still see the regenerated pinned manifests. resetManifests is self-guarded on r.manifests so it becomes a no-op when nothing was regenerated. Remove --helm-index from hashrelease publish: PublishRelease for hashrelease routes through publishToHashreleaseServer and never hits updateHelmChartIndex. Teach ReformatHashrelease to tolerate missing artifacts: the post-build reformatter hardcoded copies of calico-windows-*.zip, ocp.tgz, and per-chart tarballs. When step-control flags skip any of those artifacts the copy failed with open ... no such file or directory. Introduce a copyIfExists helper that skips (with an info log) when the source is missing so the reformatter follows the same honor-the-flags discipline as the build steps above. * refactor(release): switch step-control flags to BoolWithInverseFlag [DE-4116] - Default-on bool flags use cli.BoolWithInverseFlag (--no-foo form). - Skip-* flags renamed to positive: --validate, --validate-branch, --image-scan. Old SKIP_* env vars dropped. - Builders (images, archive-images, helm-charts, helm-index, windows-archive, operator) take env-var lists per command. Legacy aliases (ARCHIVE_IMAGES, UPDATE_HELM_INDEX, PUBLISH_GIT_TAG) listed first so existing CI wins precedence. - New hashrelease build gates: --e2e-binaries, --release-notes. - Cross-flag invariants on the prerequisite flag's Action. - Drop redundant archive-images runtime guard (urfave/cli v3.8.0 runs Action for env-set flags -- urfave/cli#2221). - Add release/cmd/flags_test.go. * fix(release): tighten helm-index gating and remote flag * refactor(release): tighten step-control flag wiring and tests - Rename validate/branch-check flags to match CLI names (validation, branch-check) - Restore --no-validation/--no-branch-check on release publish (regression) - Gate cross-flag Actions on hasFlag() so they don't misfire on commands missing the dependency (publish lacks archive-images, build lacks image-scan) - Add ocp-bundle requires manifests cross-flag invariant - Fix release-notes non-Calico guard (&& should be ||) - Restore image-scan info log - Add legacy env-var precedence tests (ARCHIVE_IMAGES, UPDATE_HELM_INDEX, PUBLISH_GIT_TAG) - Replace shallow option setter tests with PreBuildValidation coverage - Update README example to use new flag names * fix(release): scope ocp-bundle requires manifests to hashrelease only Move the cross-flag invariant from the manifests/ocp-bundle flag Actions into validateHashreleaseBuildFlags. Non-hashrelease builds use checked-in manifests and don't need the guard.
1 parent 27c9004 commit ce26ae4

12 files changed

Lines changed: 1349 additions & 434 deletions

File tree

‎release/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This section describes how to build a test release using the locally checked out
2626
Build the release, providing your own registry to use for the images. For example:
2727

2828
```
29-
ARCHES=amd64 ./bin/release hashrelease build --skip-validation --build-images --dev-registry <YOUR REGISTRY>
29+
ARCHS=amd64 ./bin/release hashrelease build --no-validation --images --dev-registry <YOUR REGISTRY>
3030
```
3131

3232
This may take some time, but will produce a full set of release images as well as an operator image based on the locally checked out commit. Artifacts can be found

‎release/cmd/branch.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func branchSubCommands(cfg *Config) []*cli.Command {
5050
devTagSuffixFlag,
5151
operatorBranchFlag,
5252
localFlag,
53-
skipValidationFlag,
53+
validationFlag,
5454
},
5555
Action: func(_ context.Context, c *cli.Command) error {
5656
configureLogging("branch-cut.log")
@@ -62,7 +62,7 @@ func branchSubCommands(cfg *Config) []*cli.Command {
6262
calico.WithRepoRoot(cfg.RepoRootDir),
6363
calico.WithReleaseBranchPrefix(c.String(releaseBranchPrefixFlag.Name)),
6464
calico.WithOperatorBranch(c.String(operatorBranchFlag.Name)),
65-
calico.WithValidate(!c.Bool(skipValidationFlag.Name)),
65+
calico.WithValidation(c.Bool(validationFlag.Name)),
6666
)
6767

6868
m := branch.NewManager(
@@ -72,7 +72,7 @@ func branchSubCommands(cfg *Config) []*cli.Command {
7272
branch.WithDevTagIdentifier(c.String(devTagSuffixFlag.Name)),
7373
branch.WithReleaseBranchPrefix(c.String(releaseBranchPrefixFlag.Name)),
7474
branch.WithRepoManager(calicoManager),
75-
branch.WithValidate(!c.Bool(skipValidationFlag.Name)),
75+
branch.WithValidation(c.Bool(validationFlag.Name)),
7676
branch.WithPublish(!c.Bool(localFlag.Name)))
7777
return m.CutReleaseBranch()
7878
},

0 commit comments

Comments
 (0)