Skip to content

feat(release): add create-release-branch target#4587

Open
radTuti wants to merge 1 commit intotigera:masterfrom
radTuti:maestro-v0-create-release-branch
Open

feat(release): add create-release-branch target#4587
radTuti wants to merge 1 commit intotigera:masterfrom
radTuti:maestro-v0-create-release-branch

Conversation

@radTuti
Copy link
Contributor

@radTuti radTuti commented Mar 24, 2026

Summary

  • Add release branch CLI command for automated release branch creation
  • Add create-release-branch Makefile target
  • Refactor prep command to share branch creation logic with branch via branchBeforeCommon and branchActionCommon
  • Update RELEASING.md and hack/release/README.md

Usage

make create-release-branch STREAM=v1.43 CALICO_REF=release-v3.32 ENTERPRISE_REF=release-calient-v3.22

Or directly:

release branch --stream v1.43 --calico-ref release-v3.32 --enterprise-ref release-calient-v3.22

Use --local to skip pushing to remote.

@radTuti radTuti force-pushed the maestro-v0-create-release-branch branch from 6009212 to bcd4ff3 Compare March 24, 2026 01:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new release branch subcommand (and make create-release-branch target) to automate release-branch creation, while refactoring release prep to reuse the shared branch/config/commit logic.

Changes:

  • Add release branch command to create a release branch, update version configs, commit, tag, and optionally push.
  • Refactor release prep to share common branch creation + config update logic via shared helpers.
  • Add new flags (--stream, --calico-ref, --enterprise-ref) and update release documentation.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
hack/release/branch.go New command + shared helpers for branching/config updates/commit/tag/push.
hack/release/prep.go Refactors prep to reuse shared branch/config/commit logic and uses shared cleanup.
hack/release/main.go Registers the new branch command with the CLI.
hack/release/flags.go Adds new flags for stream and component refs/prefix.
hack/release/checks.go Adds shared validation helpers for prep/branch.
hack/release/README.md Documents the new release branch command and Makefile target.
RELEASING.md Updates the release-branch preparation process docs to point at the new automation.
Makefile Adds create-release-branch target.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +14 to +15
- Creates a `release-vX.Y` branch from master
- Updates `config/calico_versions.yml` and `config/enterprise_versions.yml` to point at the given refs
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

Docs say this target "Creates a release-vX.Y branch from master", but the command currently creates the branch from whatever commit you’re on when you run it (git switch -C <branch>). Either document that you must run it from master (or fetch/checkout first), or update the command to explicitly base off master/origin/master.

Copilot uses AI. Check for mistakes.
@REPO=$(REPO) hack/bin/release prep

create-release-branch: hack/bin/release var-require-all-STREAM
RELEASE_STREAM=$(STREAM) hack/bin/release branch
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

This target only sets RELEASE_STREAM in the command environment. CALICO_REF / ENTERPRISE_REF are not passed through, so make create-release-branch STREAM=... CALICO_REF=... ENTERPRISE_REF=... (as documented) won’t actually provide those values to hack/bin/release branch unless the user separately exports them in their shell. Update the recipe to pass them (or pass --calico-ref/--enterprise-ref flags).

Suggested change
RELEASE_STREAM=$(STREAM) hack/bin/release branch
RELEASE_STREAM=$(STREAM) CALICO_REF=$(CALICO_REF) ENTERPRISE_REF=$(ENTERPRISE_REF) hack/bin/release branch

Copilot uses AI. Check for mistakes.
}

// branchBeforeCommon handles shared Before logic for both branch and prep
func branchBeforeCommon(ctx context.Context, c *cli.Command, scopeContextFn func(context.Context, *cli.Command) (context.Context, error), validateFn func(context.Context, *cli.Command) (context.Context, error)) (context.Context, error) {
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

branchCleanupFns is package-level state but isn’t cleared at the start of a command run. For consistency with buildCleanupFns (cleared in buildBefore), clear branchCleanupFns in branchBeforeCommon so stale cleanup functions can’t leak across multiple executions in the same process (e.g., tests).

Suggested change
func branchBeforeCommon(ctx context.Context, c *cli.Command, scopeContextFn func(context.Context, *cli.Command) (context.Context, error), validateFn func(context.Context, *cli.Command) (context.Context, error)) (context.Context, error) {
func branchBeforeCommon(ctx context.Context, c *cli.Command, scopeContextFn func(context.Context, *cli.Command) (context.Context, error), validateFn func(context.Context, *cli.Command) (context.Context, error)) (context.Context, error) {
branchCleanupFns = nil

Copilot uses AI. Check for mistakes.
- Updates `config/calico_versions.yml` and `config/enterprise_versions.yml` to point at the given refs
- Runs `make fix gen-versions-calico gen-versions-enterprise` to regenerate files
- Commits the changes to the release branch
- Switches back to master, creates an empty commit, and tags it `vX.Y.0-0.dev`
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

RELEASING.md describes the dev tag format as vX.Y.0-0.dev, but the CLI default dev-tag suffix is 0-dev, which would produce vX.Y.0-0-dev. Update the documented tag format (or the default suffix) so users can follow RELEASING.md without extra flags/env vars.

Suggested change
- Switches back to master, creates an empty commit, and tags it `vX.Y.0-0.dev`
- Switches back to master, creates an empty commit, and tags it `vX.Y.0-0-dev`

Copilot uses AI. Check for mistakes.

For a major or minor release, you will need to create:
For a major or minor release, you will need to create a new `release-vX.Y` branch, a dev tag on master,
and a GitHub milestone for the next release. The `create-release-branch` Makefile target automates this:
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

This paragraph says create-release-branch automates creating a dev tag on master and the next GitHub milestone. The implementation (new release branch command) creates a tag on the new release branch and does not manage milestones. Please adjust the docs to reflect actual behavior, or update the command to do what’s described.

Suggested change
and a GitHub milestone for the next release. The `create-release-branch` Makefile target automates this:
and a GitHub milestone for the next release. The `create-release-branch` Makefile target automates creating
the branch and dev tag; you will create the milestone manually in a later step:

Copilot uses AI. Check for mistakes.
return checkVersionMatchesGitVersion(ctx, c)
}

// check that at least one of the given flags is explicitly set and non-empty.
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

checkAtLeastOneOfFlags comment says it checks flags are "explicitly set", but the implementation only checks for a non-empty string value. Either update the comment to match behavior, or use the CLI API (e.g., an IsSet-style check) so defaults/non-empty values don’t count as "explicit".

Suggested change
// check that at least one of the given flags is explicitly set and non-empty.
// check that at least one of the given flags is set to a non-empty value.

Copilot uses AI. Check for mistakes.
Comment on lines +104 to +108
// We are now on the release branch with config changes committed.

// Switch back to master to create the dev tag.
// The dev tag goes on an empty commit on master so that git describe --tags
// produces sensible versions for subsequent master commits.
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

devTag is constructed using --dev-tag-suffix (default currently 0-dev), but the updated release docs describe tags like vX.Y.0-0.dev. As-is, the default tag created by this command will be vX.Y.0-0-dev, which won’t match the documented format. Align the default suffix and/or update the docs so the generated tag format is consistent.

Copilot uses AI. Check for mistakes.
release-prep: hack/bin/release hack/bin/gh var-require-all-VERSION var-require-one-of-CALICO_VERSION-ENTERPRISE_VERSION
@REPO=$(REPO) hack/bin/release prep

create-release-branch: hack/bin/release var-require-all-STREAM
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The new create-release-branch target only requires STREAM, but release branch errors unless both CALICO_REF and ENTERPRISE_REF are set (unless validations are skipped). Consider adding var-require-all-CALICO_REF-ENTERPRISE_REF (or similar) to fail fast with a Make-level error, consistent with release-prep.

Suggested change
create-release-branch: hack/bin/release var-require-all-STREAM
create-release-branch: hack/bin/release var-require-all-STREAM var-require-all-CALICO_REF-ENTERPRISE_REF

Copilot uses AI. Check for mistakes.
first release version for the new minor version.
| Env var | Flag | Description |
| --------------------------- | ------------------------- | ----------------------------------------------------------------- |
| `STREAM` (required) | `--stream` | Release stream, e.g., `v1.43` |
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The env var for --stream is RELEASE_STREAM (per the flag definition), but this table lists STREAM. STREAM is a Makefile variable, not an env var consumed by the CLI. Please change the table entry to RELEASE_STREAM to avoid confusion when calling the CLI directly.

Suggested change
| `STREAM` (required) | `--stream` | Release stream, e.g., `v1.43` |
| `RELEASE_STREAM` (required) | `--stream` | Release stream, e.g., `v1.43` |

Copilot uses AI. Check for mistakes.
Comment on lines +96 to +103
var branchAction = cli.ActionFunc(func(ctx context.Context, c *cli.Command) error {
stream := c.String(streamFlag.Name)
branchName := ctx.Value(branchNameCtxKey).(string)
remote := c.String(gitRemoteFlag.Name)

if _, err := branchActionCommon(ctx, c, fmt.Sprintf("build: update config for %s", stream)); err != nil {
return err
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

New release branch command adds non-trivial git/tag/push behavior, but there are no unit tests covering the new validation/context wiring (e.g., validateBranchRefs, branch name derivation from --stream/--release-branch-prefix, and behavior when --local is set). Since hack/release already has UTs, please add focused tests (mocking git helpers where needed) to prevent regressions.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants