Skip to content

Commit 7d4ba2f

Browse files
committed
gopls/release: remove unused functionality from release script
Narrow the scope of the release script to simply verifying that the release is ready. Remove: - checks for the release branch; the current branch doesn't matter for tagging - the -release and -remote flags, since we won't be using this script for performing the release Updates golang/go#57643 Change-Id: I80a5e367ad5b7df1d85f3af023dc10ccef242702 Reviewed-on: https://go-review.googlesource.com/c/tools/+/462815 Reviewed-by: Dylan Le <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Robert Findley <[email protected]> gopls-CI: kokoro <[email protected]>
1 parent 46b6958 commit 7d4ba2f

File tree

1 file changed

+3
-64
lines changed

1 file changed

+3
-64
lines changed

gopls/release/release.go

Lines changed: 3 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"io/ioutil"
1919
"log"
2020
"os"
21-
"os/user"
2221
"path/filepath"
2322
"strconv"
2423
"strings"
@@ -30,11 +29,7 @@ import (
3029
"golang.org/x/tools/go/packages"
3130
)
3231

33-
var (
34-
versionFlag = flag.String("version", "", "version to tag")
35-
remoteFlag = flag.String("remote", "", "remote to which to push the tag")
36-
releaseFlag = flag.Bool("release", false, "release is true if you intend to tag and push a release")
37-
)
32+
var versionFlag = flag.String("version", "", "version to tag")
3833

3934
func main() {
4035
flag.Parse()
@@ -51,13 +46,6 @@ func main() {
5146
if semver.Build(*versionFlag) != "" {
5247
log.Fatalf("unexpected build suffix: %s", *versionFlag)
5348
}
54-
if *releaseFlag && *remoteFlag == "" {
55-
log.Fatalf("must provide -remote flag if releasing")
56-
}
57-
user, err := user.Current()
58-
if err != nil {
59-
log.Fatal(err)
60-
}
6149
// Validate that the user is running the program from the gopls module.
6250
wd, err := os.Getwd()
6351
if err != nil {
@@ -66,11 +54,6 @@ func main() {
6654
if filepath.Base(wd) != "gopls" {
6755
log.Fatalf("must run from the gopls module")
6856
}
69-
// Confirm that they are running on a branch with a name following the
70-
// format of "gopls-release-branch.<major>.<minor>".
71-
if err := validateBranchName(*versionFlag); err != nil {
72-
log.Fatal(err)
73-
}
7457
// Confirm that they have updated the hardcoded version.
7558
if err := validateHardcodedVersion(*versionFlag); err != nil {
7659
log.Fatal(err)
@@ -79,52 +62,8 @@ func main() {
7962
if err := validateGoModFile(wd); err != nil {
8063
log.Fatal(err)
8164
}
82-
earlyExitMsg := "Validated that the release is ready. Exiting without tagging and publishing."
83-
if !*releaseFlag {
84-
fmt.Println(earlyExitMsg)
85-
os.Exit(0)
86-
}
87-
fmt.Println(`Proceeding to tagging and publishing the release...
88-
Please enter Y if you wish to proceed or anything else if you wish to exit.`)
89-
// Accept and process user input.
90-
var input string
91-
fmt.Scanln(&input)
92-
switch input {
93-
case "Y":
94-
fmt.Println("Proceeding to tagging and publishing the release.")
95-
default:
96-
fmt.Println(earlyExitMsg)
97-
os.Exit(0)
98-
}
99-
// To tag the release:
100-
// $ git -c [email protected] tag -a -m “<message>” gopls/v<major>.<minor>.<patch>-<pre-release>
101-
goplsVersion := fmt.Sprintf("gopls/%s", *versionFlag)
102-
cmd := exec.Command("git", "-c", fmt.Sprintf("user.email=%[email protected]", user.Username), "tag", "-a", "-m", fmt.Sprintf("%q", goplsVersion), goplsVersion)
103-
if err := cmd.Run(); err != nil {
104-
log.Fatal(err)
105-
}
106-
// Push the tag to the remote:
107-
// $ git push <remote> gopls/v<major>.<minor>.<patch>-pre.1
108-
cmd = exec.Command("git", "push", *remoteFlag, goplsVersion)
109-
if err := cmd.Run(); err != nil {
110-
log.Fatal(err)
111-
}
112-
}
113-
114-
// validateBranchName reports whether the user's current branch name is of the
115-
// form "gopls-release-branch.<major>.<minor>". It reports an error if not.
116-
func validateBranchName(version string) error {
117-
cmd := exec.Command("git", "branch", "--show-current")
118-
stdout, err := cmd.Output()
119-
if err != nil {
120-
return err
121-
}
122-
branch := strings.TrimSpace(string(stdout))
123-
expectedBranch := fmt.Sprintf("gopls-release-branch.%s", strings.TrimPrefix(semver.MajorMinor(version), "v"))
124-
if branch != expectedBranch {
125-
return fmt.Errorf("expected release branch %s, got %s", expectedBranch, branch)
126-
}
127-
return nil
65+
fmt.Println("Validated that the release is ready.")
66+
os.Exit(0)
12867
}
12968

13069
// validateHardcodedVersion reports whether the version hardcoded in the gopls

0 commit comments

Comments
 (0)