Skip to content

Commit f98274d

Browse files
authored
Merge pull request #123 from vitessio/post-v21-rc1-misc1
Add vitess releaser items specified in vitessio/vitess#16795 (comment)
2 parents 4c82173 + 7767db3 commit f98274d

File tree

11 files changed

+192
-13
lines changed

11 files changed

+192
-13
lines changed

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# build local vitess-releaser for development purposes
1516
build:
1617
go build -o vitess-releaser ./main.go
1718
./vitess-releaser -v
19+
20+
# install the released vitess-releaser package, for production use
21+
install:
22+
go install github.com/vitessio/vitess-releaser@latest
23+
24+
# serves for local testing with mods, as well as quick documentation on how to use the tool
25+
test: build
26+
./vitess-releaser --date 2024-10-23 --rc 2 -r 21 # --live --vtop-release 2.14

go/cmd/cmd.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434
"github.com/vitessio/vitess-releaser/go/releaser/utils"
3535
)
3636

37-
const VERSION = "v1.0.2"
37+
const VERSION = "v1.0.3"
3838

3939
var (
4040
releaseVersion string
@@ -223,7 +223,9 @@ func getGitRepos() (vitessRepo, vtopRepo string) {
223223
}
224224

225225
func printVersionAndExit() {
226-
fmt.Printf("Version: %s\n", VERSION)
226+
fmt.Printf("\nvitess-releaser Version: %s\n", VERSION)
227+
msg, _ := getGitCommit()
228+
fmt.Printf("\nLast Commit: %s\n", msg)
227229
os.Exit(0)
228230
}
229231

go/interactive/main_menu.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ import (
2929
"github.com/vitessio/vitess-releaser/go/interactive/ui"
3030
"github.com/vitessio/vitess-releaser/go/releaser"
3131
"github.com/vitessio/vitess-releaser/go/releaser/github"
32+
postreleaselogic "github.com/vitessio/vitess-releaser/go/releaser/post_release"
33+
prereleaselogic "github.com/vitessio/vitess-releaser/go/releaser/pre_release"
34+
releaselogic "github.com/vitessio/vitess-releaser/go/releaser/release"
35+
"github.com/vitessio/vitess-releaser/go/releaser/steps"
3236
)
3337

3438
func blankLineMenu() *ui.MenuItem {
@@ -66,6 +70,7 @@ func MainScreen(ctx context.Context, state *releaser.State) {
6670
pre_release.CreateReleasePRMenuItem(ctx),
6771
pre_release.VtopUpdateGolangMenuItem(ctx),
6872
createBlogPostPRMenuItem(ctx),
73+
simpleMenuItem(ctx, "UpdateCobraDocs", prereleaselogic.CobraDocs(state), steps.UpdateCobraDocs, false),
6974
)
7075

7176
releaseMenu := ui.NewMenu(
@@ -83,6 +88,7 @@ func MainScreen(ctx context.Context, state *releaser.State) {
8388
benchmarkedItem(ctx),
8489
dockerImagesItem(ctx),
8590
release.CloseMilestoneItem(ctx),
91+
simpleMenuItem(ctx, "ReleaseArtifacts", releaselogic.CheckArtifacts(state), steps.ReleaseArtifacts, false),
8692
)
8793
releaseMenu.Sequential = true
8894

@@ -91,6 +97,7 @@ func MainScreen(ctx context.Context, state *releaser.State) {
9197
"Post Release",
9298
slackAnnouncementMenuItem(ctx, slackAnnouncementPostRelease),
9399
twitterMenuItem(ctx),
100+
simpleMenuItem(ctx, "RemoveBypassProtection", postreleaselogic.RemoveByPassProtectionRules(), steps.RemoveBypassProtection, false),
94101
post_release.CloseIssueItem(ctx),
95102
)
96103

go/interactive/menu_item_constructors.go

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ package interactive
1818

1919
import (
2020
"context"
21-
21+
"fmt"
2222
"github.com/vitessio/vitess-releaser/go/interactive/ui"
2323
"github.com/vitessio/vitess-releaser/go/releaser"
2424
"github.com/vitessio/vitess-releaser/go/releaser/code_freeze"
2525
"github.com/vitessio/vitess-releaser/go/releaser/post_release"
2626
"github.com/vitessio/vitess-releaser/go/releaser/prerequisite"
2727
"github.com/vitessio/vitess-releaser/go/releaser/release"
2828
"github.com/vitessio/vitess-releaser/go/releaser/steps"
29+
"github.com/vitessio/vitess-releaser/go/releaser/utils"
30+
"reflect"
2931
)
3032

3133
func checkSummaryMenuItem(ctx context.Context) *ui.MenuItem {
@@ -98,7 +100,7 @@ func dockerImagesItem(ctx context.Context) *ui.MenuItem {
98100
state := releaser.UnwrapState(ctx)
99101
return newBooleanMenu(
100102
ctx,
101-
release.CheckDockerMessage(state.VitessRelease.MajorReleaseNb, state.VitessRelease.Repo, state.VtOpRelease.Repo),
103+
release.CheckDockerMessage(state),
102104
steps.DockerImages,
103105
func() { state.Issue.DockerImages = !state.Issue.DockerImages },
104106
state.Issue.DockerImages,
@@ -137,3 +139,42 @@ func mergeBlogPostPRMenuItem(ctx context.Context) *ui.MenuItem {
137139
state.Issue.MergeBlogPostPR,
138140
!state.Issue.GA)
139141
}
142+
143+
func simpleMenuItem(ctx context.Context, issueFieldName string, msgs []string, stepName string, onlyGA bool) *ui.MenuItem {
144+
state := releaser.UnwrapState(ctx)
145+
logMsg := fmt.Sprintf("Menu item %s", stepName)
146+
147+
fieldVal := getFieldVal(&state.Issue, issueFieldName, logMsg)
148+
149+
ignore := false
150+
if onlyGA {
151+
ignore = !state.Issue.GA
152+
}
153+
154+
return newBooleanMenu(
155+
ctx,
156+
msgs,
157+
stepName,
158+
func() {
159+
fieldVal.SetBool(!fieldVal.Bool())
160+
},
161+
fieldVal.Bool(),
162+
ignore,
163+
)
164+
}
165+
166+
func getFieldVal(issue *releaser.Issue, issueFieldName string, logMsg string) reflect.Value {
167+
v := reflect.ValueOf(issue).Elem()
168+
fieldVal := v.FieldByName(issueFieldName)
169+
if !fieldVal.IsValid() {
170+
utils.BailOut(fmt.Errorf("no such field: %s", issueFieldName), logMsg)
171+
}
172+
if fieldVal.Kind() != reflect.Bool {
173+
utils.BailOut(fmt.Errorf("field %s is not of type bool", issueFieldName), logMsg)
174+
}
175+
176+
if !fieldVal.CanSet() {
177+
utils.BailOut(fmt.Errorf("cannot set field: %s", issueFieldName), logMsg)
178+
}
179+
return fieldVal
180+
}

go/releaser/issue.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const (
7979
vtopUpdateGoItem = "Update vitess-operator Golang version."
8080
vtopUpdateCompTableItem = "Update vitess-operator compatibility table."
8181
createBlogPostPRItem = "Open a Pull Request on the website repository for the blog post."
82+
UpdateCobraDocs = "Update Cobra Docs."
8283

8384
// Release
8485
mergeReleasePRItem = "Merge the Release PR."
@@ -95,10 +96,12 @@ const (
9596
dockerImagesItem = "Docker Images available on DockerHub."
9697
closeMilestoneItem = "Close current GitHub Milestone."
9798
mergeBlogPostItem = "Merge the blog post Pull Request on the website repository."
99+
ReleaseArtifactsItem = "Check that release artifacts were generated."
98100

99101
// Post-Release
100102
postSlackAnnouncementItem = "Notify the community on Slack for the new release."
101103
twitterItem = "Twitter announcement."
104+
RemoveBypassProtection = "Remove bypass branch protection rules, if required."
102105
closeReleaseItem = "Close this Issue."
103106
)
104107

@@ -151,6 +154,7 @@ type (
151154
VtopCreateReleasePR ItemWithLinks
152155
VtopManualUpdate bool
153156
CreateBlogPostPR bool
157+
UpdateCobraDocs bool
154158

155159
// Release
156160
MergeReleasePR ItemWithLink
@@ -165,11 +169,13 @@ type (
165169
Benchmarked bool
166170
DockerImages bool
167171
CloseMilestone ItemWithLink
172+
ReleaseArtifacts bool
168173

169174
// Post-Release
170-
SlackPostRelease bool
171-
Twitter bool
172-
CloseIssue bool
175+
SlackPostRelease bool
176+
Twitter bool
177+
CloseIssue bool
178+
RemoveBypassProtection bool
173179
}
174180
)
175181

@@ -257,6 +263,7 @@ const (
257263
{{- if .GA }}
258264
- [{{fmtStatus .CreateBlogPostPR}}] Open a Pull Request on the website repository for the blog post.
259265
{{- end }}
266+
- [{{fmtStatus .UpdateCobraDocs}}] Update Cobra Docs.
260267
261268
### Release _({{fmtShortDate .Date }})_
262269
@@ -298,12 +305,14 @@ const (
298305
- {{ .CloseMilestone.URL }}
299306
{{- end }}
300307
{{- end }}
301-
308+
- [{{fmtStatus .ReleaseArtifacts}}] Check that release artifacts were generated.
302309
303310
### Post-Release _({{fmtShortDate .Date }})_
304311
- [{{fmtStatus .SlackPostRelease}}] Notify the community on Slack for the new release.
305312
- [{{fmtStatus .Twitter}}] Twitter announcement.
313+
- [{{fmtStatus .RemoveBypassProtection}}] Remove bypass branch protection rules, if required.
306314
- [{{fmtStatus .CloseIssue}}] Close this Issue.
315+
307316
`
308317
)
309318

@@ -497,6 +506,12 @@ func (s *State) LoadIssue() {
497506
newIssue.MergeBlogPostPR = strings.HasPrefix(line, markdownItemDone)
498507
case strings.Contains(line, javaRelease):
499508
newIssue.JavaRelease = strings.HasPrefix(line, markdownItemDone)
509+
case strings.Contains(line, UpdateCobraDocs):
510+
newIssue.UpdateCobraDocs = strings.HasPrefix(line, markdownItemDone)
511+
case strings.Contains(line, ReleaseArtifactsItem):
512+
newIssue.ReleaseArtifacts = strings.HasPrefix(line, markdownItemDone)
513+
case strings.Contains(line, RemoveBypassProtection):
514+
newIssue.RemoveBypassProtection = strings.HasPrefix(line, markdownItemDone)
500515
}
501516
case stateReadingGeneral:
502517
newIssue.General.Items = append(newIssue.General.Items, handleNewListItem(lines, i, &st))
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Copyright 2024 The Vitess Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package post_release
18+
19+
func RemoveByPassProtectionRules() []string {
20+
return []string{
21+
"In branch protection for current branch, confirm 'Do not allow bypassing the above settings' is checked.",
22+
"",
23+
}
24+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Copyright 2024 The Vitess Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package pre_release
18+
19+
import (
20+
"fmt"
21+
22+
"github.com/vitessio/vitess-releaser/go/releaser"
23+
)
24+
25+
func CobraDocs(state *releaser.State) []string {
26+
return []string{
27+
"Regenerate cobra cli docs by running the following in the root of the website repo:\n",
28+
fmt.Sprintf("\t$> export COBRADOC_VERSION_PAIRS=\"v%s:%s.0\"",
29+
releaser.RemoveRCFromReleaseTitle(state.VitessRelease.Release), state.VitessRelease.MajorRelease),
30+
fmt.Sprintf("\t$> make generated-docs"),
31+
"",
32+
}
33+
}

go/releaser/release/artifacts.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
Copyright 2024 The Vitess Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package release
18+
19+
import (
20+
"fmt"
21+
22+
"github.com/vitessio/vitess-releaser/go/releaser"
23+
)
24+
25+
func CheckArtifacts(state *releaser.State) []string {
26+
return []string{
27+
fmt.Sprintf("Check that release artifacts were generated: at bottom of https://github.com/vitessio/vitess/releases/tag/%s.", state.GetTag()),
28+
"",
29+
}
30+
}

go/releaser/release/docker.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@ limitations under the License.
1616

1717
package release
1818

19-
import "fmt"
19+
import (
20+
"fmt"
21+
"github.com/vitessio/vitess-releaser/go/releaser"
22+
"strings"
23+
)
2024

21-
func CheckDockerMessage(majorRelease int, repo string, vtopRepo string) []string {
25+
func CheckDockerMessage(state *releaser.State) []string {
26+
majorRelease := state.VitessRelease.MajorReleaseNb
27+
repo := state.VitessRelease.Repo
28+
vtopRepo := state.VtOpRelease.Repo
29+
release := strings.ToLower(state.VitessRelease.Release)
2230
msg := []string{
2331
"Make sure the Docker Images are being built by GitHub Actions.",
2432
"This can be done by visiting the following links, our new release should appear in either green (done) or yellow (building / pending build):",
@@ -38,6 +46,7 @@ func CheckDockerMessage(majorRelease int, repo string, vtopRepo string) []string
3846
} else {
3947
// this links to the newer GitHub Actions workflow that was introduced in v21 by https://github.com/vitessio/vitess/pull/16339
4048
msg = append(msg, fmt.Sprintf("\t- https://github.com/%s/vitess/actions/workflows/build_docker_images.yml", repo))
49+
msg = append(msg, fmt.Sprintf("\nCheck that the vttestserver image is pushed at https://hub.docker.com/r/vitess/vttestserver/tags?name=%s.", release))
4150
}
4251

4352
if vtopRepo != "" {

go/releaser/state.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ package releaser
1818

1919
import (
2020
"context"
21+
"fmt"
2122
"path"
23+
"strings"
2224
"syscall"
2325

2426
"github.com/vitessio/vitess-releaser/go/releaser/utils"
@@ -87,6 +89,10 @@ func (s *State) GoToVtOp() {
8789
changeDir(p)
8890
}
8991

92+
func (s *State) GetTag() string {
93+
return fmt.Sprintf("v%s", strings.ToLower(s.VitessRelease.Release))
94+
}
95+
9096
func changeDir(p string) {
9197
cwd, err := syscall.Getwd()
9298
if err != nil {

0 commit comments

Comments
 (0)