Skip to content

Commit dee4525

Browse files
authored
Merge pull request #391 from symflower/344-release-script
Release script for tagging and updating the binary version
2 parents a734b12 + 32de99d commit dee4525

File tree

5 files changed

+165
-11
lines changed

5 files changed

+165
-11
lines changed

.github/ISSUE_TEMPLATE/3-roadmap.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ Release version of this roadmap issue:
5555
- [ ] Write the release notes:
5656
- [ ] Use the tasks that are already there for the release note outline
5757
- [ ] Add highlighted features based on the done tasks, sort by how many users would use the feature
58-
- [ ] Do the release
59-
- [ ] Update the release version string in `evaluate/version.go`
60-
- [ ] With the release notes
61-
- [ ] Set as latest release
58+
- [ ] Do the release for version X.Y.Z with a new major, minor or bugfix version
59+
- [ ] Execute `go run scripts/eval-dev-quality-release/main.go X.Y.Z`
60+
- [ ] Do release notes for version
61+
- [ ] Set release as latest release
6262
- [ ] Prepare the next roadmap
6363
- [ ] Create a milestone for the next release
6464
- [ ] Create a new roadmap issue for the next release
@@ -75,12 +75,12 @@ Release version of this roadmap issue:
7575
- [ ] Update "latest DevQualityEval deep dive" mentions
7676
- [ ] Update DevQualityEval blog series lists with new entries
7777
- [ ] Update LLM blog series lists with new entries
78-
- [ ] Update payment process for supporting DevQualityEval
79-
- [ ] New Stripe payment link for this version
80-
- [ ] Update payment logic with new Google Drive folder of the evaluation
81-
- [ ] Update payment link in this README
82-
- [ ] Update payment link on symflower.com (except for the one deep dive that mentions exactly these results)
83-
- [ ] Create an issue in the company tracker for Markus to announce the new deep dive on Twitter and LinkedIn
78+
- [ ] Update payment process for supporting DevQualityEval
79+
- [ ] New Stripe payment link for this version
80+
- [ ] Update payment logic with new Google Drive folder of the evaluation
81+
- [ ] Update payment link in this README
82+
- [ ] Update payment link on symflower.com (except for the one deep dive that mentions exactly these results)
83+
- [ ] Create an issue in the company tracker for Markus to announce the new deep dive on Twitter and LinkedIn
8484
- [ ] Close this issue
8585
- [ ] Close the current milestone
8686
- [ ] Announce release

evaluate/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package evaluate
22

33
// Version holds the current version of the evaluation benchmark.
4-
var Version = "0.6.2"
4+
var Version = "1.0.0"
55

66
// Revision holds the Git revision of the current build.
77
var Revision string

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ require (
1717
)
1818

1919
require (
20+
github.com/Masterminds/semver/v3 v3.3.1 // indirect
2021
github.com/davecgh/go-spew v1.1.1 // indirect
2122
github.com/google/uuid v1.6.0 // indirect
2223
github.com/kr/text v0.2.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4=
2+
github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
13
github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0=
24
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
35
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
package main
2+
3+
import (
4+
"bytes"
5+
"context"
6+
"errors"
7+
"os"
8+
"regexp"
9+
"strings"
10+
11+
"github.com/Masterminds/semver/v3"
12+
"github.com/jessevdk/go-flags"
13+
"github.com/symflower/eval-dev-quality/log"
14+
"github.com/symflower/eval-dev-quality/util"
15+
"github.com/zimmski/osutil"
16+
)
17+
18+
// Command holds the root command.
19+
type Command struct {
20+
// Positional holds positional arguments.
21+
Positional struct {
22+
// Version holds the version tag that should be released, e.g. "1.2.3".
23+
Version string `positional-arg-name:"version" description:"Tag that should be released, e.g. \"1.2.3\"." required:"true"`
24+
} `positional-args:"true"`
25+
}
26+
27+
func main() {
28+
logger := log.STDOUT()
29+
options := &Command{}
30+
31+
var parser = flags.NewNamedParser("eval-dev-quality-release", flags.Default)
32+
parser.LongDescription = "Command to do releases for DevQualityEval."
33+
if _, err := parser.AddGroup("Common command options", "", options); err != nil {
34+
logger.Panicf("could not add arguments group: %+v", err)
35+
}
36+
37+
if _, err := parser.ParseArgs(os.Args[1:]); err != nil {
38+
if e, ok := err.(*flags.Error); ok && e.Type == flags.ErrHelp {
39+
return
40+
}
41+
42+
logger.Panicf("could not parse arguments: %+v", err)
43+
}
44+
45+
version, err := semver.NewVersion(options.Positional.Version)
46+
if err != nil {
47+
logger.Panicf("cannot parse version: %+v", err)
48+
}
49+
50+
logger.Info("update repository to the latest commits")
51+
_, err = util.CommandWithResult(context.Background(), logger, &util.Command{
52+
Command: []string{
53+
"git-update-branch",
54+
},
55+
})
56+
if err != nil {
57+
logger.Info("cannot update repository to the latest commits: %+v", err)
58+
}
59+
60+
logger.Info("check that version is newer than current version")
61+
versionCurrent := "v0.6.2" // TODO
62+
versionCurrent = strings.TrimPrefix(versionCurrent, "v")
63+
vc, err := semver.NewVersion(versionCurrent)
64+
if err != nil {
65+
logger.Panicf("cannot parse current version: %+v", err)
66+
}
67+
if !version.GreaterThan(vc) {
68+
logger.Panicf("version %q must be greater than current version %q", version, vc)
69+
}
70+
71+
versionTag := "v" + version.String()
72+
73+
logger.Info("check if tag already exists")
74+
if _, err := util.CommandWithResult(context.Background(), logger, &util.Command{
75+
Command: []string{
76+
"git",
77+
"rev-parse",
78+
versionTag,
79+
},
80+
}); err == nil {
81+
logger.Info("version tag already exists")
82+
}
83+
84+
logger.Info("change version in Go code")
85+
if err := osutil.FileChange("evaluate/version.go", func(data []byte) (changed []byte, err error) {
86+
changed = regexp.MustCompile(`var Version = ".+?"`).ReplaceAll(data, []byte(`var Version = "`+version.String()+`"`))
87+
88+
if bytes.Equal(data, changed) {
89+
return nil, errors.New("could not change version")
90+
}
91+
92+
return changed, nil
93+
}); err != nil {
94+
logger.Panicf("cannot change version in Go code: %+v", err)
95+
}
96+
97+
logger.Info("create release commit")
98+
if _, err := util.CommandWithResult(context.Background(), logger, &util.Command{
99+
Command: []string{
100+
"git",
101+
"add",
102+
"evaluate/version.go",
103+
},
104+
}); err != nil {
105+
logger.Panicf(err.Error())
106+
}
107+
if _, err := util.CommandWithResult(context.Background(), logger, &util.Command{
108+
Command: []string{
109+
"git",
110+
"commit",
111+
"--message=Release version " + versionTag,
112+
},
113+
}); err != nil {
114+
logger.Panicf(err.Error())
115+
}
116+
117+
logger.Info("tag release commit")
118+
if _, err := util.CommandWithResult(context.Background(), logger, &util.Command{
119+
Command: []string{
120+
"git",
121+
"tag",
122+
"--annotate",
123+
"--message=Version " + versionTag,
124+
"--sign",
125+
versionTag,
126+
},
127+
}); err != nil {
128+
logger.Panicf(err.Error())
129+
}
130+
131+
logger.Info("push the branch and tag")
132+
if _, err := util.CommandWithResult(context.Background(), logger, &util.Command{
133+
Command: []string{
134+
"git",
135+
"push",
136+
"origin",
137+
},
138+
}); err != nil {
139+
logger.Panicf(err.Error())
140+
}
141+
if _, err := util.CommandWithResult(context.Background(), logger, &util.Command{
142+
Command: []string{
143+
"git",
144+
"push",
145+
"origin",
146+
versionTag,
147+
},
148+
}); err != nil {
149+
logger.Panicf(err.Error())
150+
}
151+
}

0 commit comments

Comments
 (0)