cmd/release: fix tour after rename, do less tour work for Go 1.12+ releases

The tour binary was renamed from gotour to tour in CL 141857 as part
of golang/go#28163, but cmd/release wasn't updated to know about the new
name. This fixes that.

Additionally, don't push tour source to the buildlet if the releaselet
isn't going to include it anyway.

Tested that running it with a Go 1.11 release includes the tour:

   $ release -rev release-branch.go1.11 -tools release-branch.go1.11 \
             -target=linux-amd64 -skip_tests -version=go1.11.99 -watch

And with Go 1.12 does not:

   $ release -rev master -tools master \
             -target=linux-amd64 -skip_tests -version=go1.12.99 -watch

Updates golang/go#28163
Updates golang/go#27151

Change-Id: I246fc274c9dea81a24d27322bcbbe5a59e682a5e
Reviewed-on: https://go-review.googlesource.com/c/143537
Reviewed-by: Katie Hockman <katie@golang.org>
diff --git a/cmd/release/release.go b/cmd/release/release.go
index ceefca3..0db915a 100644
--- a/cmd/release/release.go
+++ b/cmd/release/release.go
@@ -236,16 +236,6 @@
 	},
 }
 
-const (
-	toolsRepo = "golang.org/x/tools"
-	tourRepo  = "golang.org/x/tour"
-)
-
-var toolPaths = []string{
-	"golang.org/x/tools/cmd/godoc",
-	"golang.org/x/tour/gotour",
-}
-
 var preBuildCleanFiles = []string{
 	".gitattributes",
 	".github",
@@ -311,6 +301,9 @@
 		if b.Source && r.repo != "go" {
 			continue
 		}
+		if r.repo == "tour" && !versionIncludesTour(*version) {
+			continue
+		}
 		dir := goDir
 		if r.repo != "go" {
 			dir = goPath + "/src/golang.org/x/" + r.repo
@@ -426,6 +419,12 @@
 		}
 	}
 
+	toolPaths := []string{
+		"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
@@ -727,3 +726,13 @@
 	}
 	return append(env, wantKV)
 }
+
+// versionIncludesTour reports whether the provided Go version (of the
+// form "go1.N" or "go1.N.M" includes the Go tour binary.
+func versionIncludesTour(goVer string) bool {
+	// We don't do releases of Go 1.9 and earlier, so this only
+	// needs to recognize the two current past releases. From Go
+	// 1.12 and on, we won't ship the tour binary (see CL 131156).
+	return strings.HasPrefix(goVer, "go1.10.") ||
+		strings.HasPrefix(goVer, "go1.11.")
+}
diff --git a/cmd/release/releaselet.go b/cmd/release/releaselet.go
index 72f28fc..b62df7b 100644
--- a/cmd/release/releaselet.go
+++ b/cmd/release/releaselet.go
@@ -131,10 +131,10 @@
 		return err
 	}
 
-	// Copy gotour binary to tool directory as "tour"; invoked as "go tool tour".
+	// Copy the tour binary to the tool directory, invoked as "go tool tour".
 	return cp(
 		filepath.FromSlash("go/pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH+"/tour"+ext()),
-		filepath.FromSlash("gopath/bin/"+archDir()+"/gotour"+ext()),
+		filepath.FromSlash("gopath/bin/"+archDir()+"/tour"+ext()),
 	)
 }