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

prepare rules_go release 0.51.0-rc2 #4183

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions go/def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ _TOOLS_NOGO = [
# new analyses may discover issues in existing builds.
TOOLS_NOGO = [str(Label(l)) for l in _TOOLS_NOGO]

# Current version or next version to be tagged. Gazelle and other tools may
# check this to determine compatibility.
RULES_GO_VERSION = "0.51.0-rc1"
# Deprecated field previously used for version detection. This will not be
# updated for new releases, use bazel_dep in MODULE.bazel to specify a minimum
# version of rules_go instead.
RULES_GO_VERSION = "0.50.0"

go_context = _go_context
gomock = _gomock
Expand Down
28 changes: 2 additions & 26 deletions go/tools/releaser/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ with review. Specifically, prepare does the following:
* Creates the release branch if it doesn't exist locally. Release branches
have names like "release-X.Y" where X and Y are the major and minor version
numbers.
* Checks that RULES_GO_VERSION is set in go/def.bzl on the local release branch
for the minor version being released. RULES_GO_VERSION must be a sematic
version without the "v" prefix that Go uses, like "1.2.4". It must match
the -version flag, which does require the "v" prefix.
* Creates an archive zip file from the tip of the local release branch.
* Creates or updates a draft GitHub release with the given release notes.
http_archive boilerplate is generated and appended to the release notes.
Expand Down Expand Up @@ -109,10 +105,9 @@ func runPrepare(ctx context.Context, stderr io.Writer, args []string) error {
return fmt.Errorf("release %s was already published", version)
}

// Check that RULES_GO_VERSION is set correctly on the release branch.
// If this is a minor release (x.y.0), create the release branch if it
// does not exist.
fmt.Fprintf(stderr, "checking RULES_GO_VERSION...\n")
fmt.Fprintf(stderr, "verifying release branch...\n")
rootDir, err := repoRoot()
if err != nil {
return err
Expand All @@ -125,19 +120,12 @@ func runPrepare(ctx context.Context, stderr io.Writer, args []string) error {
branchName := "release-" + majorMinor[len("v"):]
if !gitBranchExists(ctx, rootDir, branchName) {
if !isMinorRelease {
return fmt.Errorf("release branch %q does not exist locally. Fetch it, set RULES_GO_VERSION, add commits, and run this command again.", branchName)
}
if err := checkRulesGoVersion(ctx, rootDir, "HEAD", version); err != nil {
return err
return fmt.Errorf("release branch %q does not exist locally. Fetch it, add commits, and run this command again.", branchName)
}
fmt.Fprintf(stderr, "creating branch %s...\n", branchName)
if err := gitCreateBranch(ctx, rootDir, branchName, "HEAD"); err != nil {
return err
}
} else {
if err := checkRulesGoVersion(ctx, rootDir, branchName, version); err != nil {
return err
}
}

// Create an archive.
Expand Down Expand Up @@ -239,15 +227,3 @@ Release %s has been prepared and uploaded.

return nil
}

func checkRulesGoVersion(ctx context.Context, dir, refName, version string) error {
data, err := gitCatFile(ctx, dir, refName, "go/def.bzl")
if err != nil {
return err
}
rulesGoVersionStr := []byte(fmt.Sprintf(`RULES_GO_VERSION = "%s"`, version[len("v"):]))
if !bytes.Contains(data, rulesGoVersionStr) {
return fmt.Errorf("RULES_GO_VERSION was not set to %q in go/def.bzl. Set it, add commits, and run this command again.", version)
}
return nil
}