Skip to content

Commit a103a08

Browse files
authored
prepare rules_go release 0.51.0-rc2 (#4183)
**What type of PR is this?** Bug fix **What does this PR do? Why is it needed?** Deprecates the `RULES_GO_VERSION` constant in favor of `bazel_dep` and keeps it at `0.50.0` for legacy consumers that may not be able to parse RC suffixes. **Which issues(s) does this PR fix?** **Other notes for review**
1 parent e8adba2 commit a103a08

File tree

2 files changed

+6
-29
lines changed

2 files changed

+6
-29
lines changed

go/def.bzl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,10 @@ _TOOLS_NOGO = [
123123
# new analyses may discover issues in existing builds.
124124
TOOLS_NOGO = [str(Label(l)) for l in _TOOLS_NOGO]
125125

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

130131
go_context = _go_context
131132
gomock = _gomock

go/tools/releaser/prepare.go

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

112-
// Check that RULES_GO_VERSION is set correctly on the release branch.
113108
// If this is a minor release (x.y.0), create the release branch if it
114109
// does not exist.
115-
fmt.Fprintf(stderr, "checking RULES_GO_VERSION...\n")
110+
fmt.Fprintf(stderr, "verifying release branch...\n")
116111
rootDir, err := repoRoot()
117112
if err != nil {
118113
return err
@@ -125,19 +120,12 @@ func runPrepare(ctx context.Context, stderr io.Writer, args []string) error {
125120
branchName := "release-" + majorMinor[len("v"):]
126121
if !gitBranchExists(ctx, rootDir, branchName) {
127122
if !isMinorRelease {
128-
return fmt.Errorf("release branch %q does not exist locally. Fetch it, set RULES_GO_VERSION, add commits, and run this command again.", branchName)
129-
}
130-
if err := checkRulesGoVersion(ctx, rootDir, "HEAD", version); err != nil {
131-
return err
123+
return fmt.Errorf("release branch %q does not exist locally. Fetch it, add commits, and run this command again.", branchName)
132124
}
133125
fmt.Fprintf(stderr, "creating branch %s...\n", branchName)
134126
if err := gitCreateBranch(ctx, rootDir, branchName, "HEAD"); err != nil {
135127
return err
136128
}
137-
} else {
138-
if err := checkRulesGoVersion(ctx, rootDir, branchName, version); err != nil {
139-
return err
140-
}
141129
}
142130

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

240228
return nil
241229
}
242-
243-
func checkRulesGoVersion(ctx context.Context, dir, refName, version string) error {
244-
data, err := gitCatFile(ctx, dir, refName, "go/def.bzl")
245-
if err != nil {
246-
return err
247-
}
248-
rulesGoVersionStr := []byte(fmt.Sprintf(`RULES_GO_VERSION = "%s"`, version[len("v"):]))
249-
if !bytes.Contains(data, rulesGoVersionStr) {
250-
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)
251-
}
252-
return nil
253-
}

0 commit comments

Comments
 (0)