Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create tools/release.go to automate release tagging #6731

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

aarongable
Copy link
Contributor

@aarongable aarongable commented Mar 8, 2023

Create tools/release.go, a small Go script which automates the creation of release tags.

In its primary mode, it creates a new release tag pointing at the current tip of main. The script assumes that you have "github.com/letsencrypt/boulder" (i.e. this repo) set as your "origin" remote. The new tag is always of the format "v0.YYYYMMDD.0", so that the major version does not make any backwards-compatibility guarantees, the minor version continues our tradition of date-stamping our version numbers, and the patch version can be incremented by hotfix releases. It only pushes the newly-created tag if passed the "-f" flag; otherwise it just creates the new tag locally and exits, allowing the user to inspect it and push it themselves.

In its hotfix mode, it cherry-picks any number of given commits on top of a previously-tagged release, increments the patch portion of the release version number, creates a new tag with the incremented version number, and pushes the resulting tag to the "origin" remote. It also creates (or updates, if one already exists) a corresponding branch whose name is the major and minor portions of the version tag.

This tag naming system is superior to our current "release-YYYY-MM-DD[a]" system for a few reasons. First, by virtue of being a Semver, we get access to tools (like the semver library used in this script, and pkg.go.dev) which understand semver. It shortens our tags, making them easier to read in horizontally-constrained environments like github's tag dropdowns and releases sidebar. And it provides a dedicated place (the patch version) for us to indicate hotfix tags, rather than our ad-hoc letter-based suffix system.

At the current moment, this script has little safety and ergonomics built-in. For example, if one of the cherry-picks fails, it simply quits and dumps the user back into their shell, now likely in git's conflict-resolution mode. Also, because the git cherry-pick command requires that the target ref be checked out, this script changes the user's current branch and does not change it back. However, these can be added over time, as the straight-line logic and familiar Go code make it easy to hack on and improve.

Fixes #5726

@aarongable aarongable requested a review from a team as a code owner March 8, 2023 21:36
tools/release.go Outdated Show resolved Hide resolved
tools/release.go Outdated Show resolved Hide resolved
@pgporada
Copy link
Member

pgporada commented Mar 10, 2023 via email

@aarongable
Copy link
Contributor Author

That works when you're running gosec directly, but not as part of golangci-lint. No, I have no idea why it's different, but I've tripped over it multiple times.

pgporada
pgporada previously approved these changes Mar 10, 2023
tools/release.go Outdated Show resolved Hide resolved
tools/release.go Outdated Show resolved Hide resolved
tools/release.go Show resolved Hide resolved
@beautifulentropy
Copy link
Member

You've got a failing gomod vendor test.

@aarongable
Copy link
Contributor Author

Fixed go.mod and resolved merge conflicts.

}

func main() {
if len(os.Args) >= 2 && os.Args[1] == "hotfix" {
Copy link
Member

Choose a reason for hiding this comment

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

Could you add another conditional that shows the operator a basic help menu outside of flag.Parse()? Without this, they'd have to read the code to see that hotfix is an available subcommand.

Suggested change
if len(os.Args) >= 2 && os.Args[1] == "hotfix" {
if os.Args[1] == "-h" {
fmt.Println("go run release.go [hotfix] [args]\n" +
"-h : display help text")
} else if len(os.Args) >= 2 && os.Args[1] == "hotfix" {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create CLI boulder release tool
3 participants