cmd/release: don't include godoc in releases in Go 1.13+
Tested that it's still present in Go 1.12:
$ release -version=go1.12.999 -target=linux-amd64 -watch -skip_tests -rev=release-branch.go1.12 -tools=release-branch.go1.12 -net=release-branch.go1.12
...
$ ls -lh go1.12.999.linux-amd64.tar.gz
-rw-r--r-- 1 bradfitz bradfitz 122M Apr 29 19:28 go1.12.999.linux-amd64.tar.gz
$ tar -ztf go1.12.999.linux-amd64.tar.gz | grep godoc
go/bin/godoc
go/src/cmd/vendor/github.com/google/pprof/profile/testdata/go.godoc.thread
go/src/cmd/vendor/github.com/google/pprof/profile/testdata/go.godoc.thread.string
But not with Go 1.13:
$ release -version=go1.13beta0 -target=linux-amd64 -watch -skip_tests -rev=8c1f78524e421ac01e35e8805dd7a45bf98c2a79
...
$ ls -lh go1.13beta0.linux-amd64.tar.gz
-rw-r--r-- 1 bradfitz bradfitz 115M Apr 29 19:00 go1.13beta0.linux-amd64.tar.gz
$ tar -ztf go1.13beta0.linux-amd64.tar.gz | grep godoc
$
Fixes golang/go#30029
Updates golang/go#27151
Change-Id: I9ac5c1b2bc76f184bf05fdcac86bb2e37b57c77c
Reviewed-on: https://go-review.googlesource.com/c/build/+/174322
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/cmd/release/release.go b/cmd/release/release.go
index a6fae05..af05eb7 100644
--- a/cmd/release/release.go
+++ b/cmd/release/release.go
@@ -72,13 +72,13 @@
}
if (*rev == "" && *tarball == "") || (*rev != "" && *tarball != "") {
- log.Fatal("must specify one of -rev and -tarball")
- }
- if *toolsRev == "" {
- log.Fatal("must specify -tools flag")
+ log.Fatal("must specify one of -rev or -tarball")
}
if *version == "" {
- log.Fatal("must specify -version flag")
+ log.Fatal(`must specify -version flag (such as "go1.12" or "go1.13beta1")`)
+ }
+ if *toolsRev == "" && (versionIncludesGodoc(*version) || versionIncludesTour(*version)) {
+ log.Fatal("must specify -tools flag")
}
coordClient = coordinatorClient()
@@ -317,6 +317,9 @@
if r.repo == "tour" && !versionIncludesTour(*version) {
continue
}
+ if (r.repo == "net" || r.repo == "tools") && !versionIncludesGodoc(*version) {
+ continue
+ }
dir := goPath + "/src/golang.org/x/" + r.repo
tar := "https://go.googlesource.com/" + r.repo + "/+archive/" + r.rev + ".tar.gz"
if err := client.PutTarFromURL(tar, dir); err != nil {
@@ -442,15 +445,18 @@
}
}
- toolPaths := []string{
- "golang.org/x/tools/cmd/godoc",
+ var toolPaths []string
+ if versionIncludesGodoc(*version) {
+ toolPaths = append(toolPaths, "golang.org/x/tools/cmd/godoc")
}
if versionIncludesTour(*version) {
toolPaths = append(toolPaths, "golang.org/x/tour")
}
- b.logf("Building %v.", strings.Join(toolPaths, ", "))
- if err := runGo(append([]string{"install"}, toolPaths...)...); err != nil {
- return err
+ if len(toolPaths) > 0 {
+ b.logf("Building %v.", strings.Join(toolPaths, ", "))
+ if err := runGo(append([]string{"install"}, toolPaths...)...); err != nil {
+ return err
+ }
}
// postBuildCleanFiles are the list of files to remove in the go/ directory
@@ -839,3 +845,13 @@
return strings.HasPrefix(goVer, "go1.10.") ||
strings.HasPrefix(goVer, "go1.11.")
}
+
+// versionIncludesGodoc reports whether the provided Go version (of the
+// form "go1.N" or "go1.N.M" includes the godoc binary.
+func versionIncludesGodoc(goVer string) bool {
+ // We don't do releases of Go 1.10 and earlier, so this only
+ // needs to recognize the two current past releases. From Go
+ // 1.13 and on, we won't ship the godoc binary (see Issue 30029).
+ return strings.HasPrefix(goVer, "go1.11.") ||
+ strings.HasPrefix(goVer, "go1.12.")
+}
diff --git a/cmd/release/releaselet.go b/cmd/release/releaselet.go
index b62df7b..4ab342b 100644
--- a/cmd/release/releaselet.go
+++ b/cmd/release/releaselet.go
@@ -77,7 +77,17 @@
return ""
}
+// godoc copies the godoc binary into place for Go 1.12 and earlier.
+//
+// TODO: remove this function once Go 1.14 is released (when Go 1.12
+// is no longer supported).
func godoc() error {
+ _, version, _ := environ()
+ verMajor, verMinor, _ := splitVersion(version)
+ if verMajor > 1 || verMinor >= 13 {
+ return nil // Only include the godoc binary in go1.12.x and earlier releases; Issue 30029
+ }
+
// Pre Go 1.7, the godoc binary is placed here by cmd/go.
// After Go 1.7, we need to copy the binary from GOPATH/bin to GOROOT/bin.
// TODO(cbro): Remove after Go 1.6 is no longer supported.