diff --git a/go/cmd/cmd.go b/go/cmd/cmd.go index 7ab5a41..1c6fc63 100644 --- a/go/cmd/cmd.go +++ b/go/cmd/cmd.go @@ -34,7 +34,7 @@ import ( "github.com/vitessio/vitess-releaser/go/releaser/utils" ) -const VERSION = "v1.0.2" +const VERSION = "v1.0.3" var ( releaseVersion string diff --git a/go/interactive/main_menu.go b/go/interactive/main_menu.go index 20dd2a8..35dc6e2 100644 --- a/go/interactive/main_menu.go +++ b/go/interactive/main_menu.go @@ -29,6 +29,7 @@ import ( "github.com/vitessio/vitess-releaser/go/interactive/ui" "github.com/vitessio/vitess-releaser/go/releaser" "github.com/vitessio/vitess-releaser/go/releaser/github" + "github.com/vitessio/vitess-releaser/go/releaser/steps" ) func blankLineMenu() *ui.MenuItem { @@ -66,6 +67,7 @@ func MainScreen(ctx context.Context, state *releaser.State) { pre_release.CreateReleasePRMenuItem(ctx), pre_release.VtopUpdateGolangMenuItem(ctx), createBlogPostPRMenuItem(ctx), + simpleMenuItem(ctx, "UpdateCobraDocs", []string{releaser.UpdateCobraDocsItem}, steps.UpdateCobraDocs, false), ) releaseMenu := ui.NewMenu( @@ -83,6 +85,8 @@ func MainScreen(ctx context.Context, state *releaser.State) { benchmarkedItem(ctx), dockerImagesItem(ctx), release.CloseMilestoneItem(ctx), + simpleMenuItem(ctx, "VtTestServer", []string{releaser.VttestServerItem}, steps.VtTestServer, false), + simpleMenuItem(ctx, "ReleaseArtifacts", []string{releaser.ReleaseArtifactsItem}, steps.ReleaseArtifacts, false), ) releaseMenu.Sequential = true @@ -92,6 +96,7 @@ func MainScreen(ctx context.Context, state *releaser.State) { slackAnnouncementMenuItem(ctx, slackAnnouncementPostRelease), twitterMenuItem(ctx), post_release.CloseIssueItem(ctx), + simpleMenuItem(ctx, "RemoveBypassProtection", []string{releaser.RemoveBypassProtection}, steps.RemoveBypassProtection, false), ) menuTitle := fmt.Sprintf("Main Menu (%s)", github.CurrentUser()) diff --git a/go/interactive/menu_item_constructors.go b/go/interactive/menu_item_constructors.go index e693e73..97dd1df 100644 --- a/go/interactive/menu_item_constructors.go +++ b/go/interactive/menu_item_constructors.go @@ -18,7 +18,7 @@ package interactive import ( "context" - + "fmt" "github.com/vitessio/vitess-releaser/go/interactive/ui" "github.com/vitessio/vitess-releaser/go/releaser" "github.com/vitessio/vitess-releaser/go/releaser/code_freeze" @@ -26,6 +26,8 @@ import ( "github.com/vitessio/vitess-releaser/go/releaser/prerequisite" "github.com/vitessio/vitess-releaser/go/releaser/release" "github.com/vitessio/vitess-releaser/go/releaser/steps" + "github.com/vitessio/vitess-releaser/go/releaser/utils" + "reflect" ) func checkSummaryMenuItem(ctx context.Context) *ui.MenuItem { @@ -137,3 +139,42 @@ func mergeBlogPostPRMenuItem(ctx context.Context) *ui.MenuItem { state.Issue.MergeBlogPostPR, !state.Issue.GA) } + +func simpleMenuItem(ctx context.Context, issueFieldName string, msgs []string, stepName string, onlyGA bool) *ui.MenuItem { + state := releaser.UnwrapState(ctx) + logMsg := fmt.Sprintf("Menu item %s", stepName) + + fieldVal := getFieldVal(&state.Issue, issueFieldName, logMsg) + + ignore := false + if onlyGA { + ignore = !state.Issue.GA + } + + return newBooleanMenu( + ctx, + msgs, + stepName, + func() { + fieldVal.SetBool(!fieldVal.Bool()) + }, + fieldVal.Bool(), + ignore, + ) +} + +func getFieldVal(issue *releaser.Issue, issueFieldName string, logMsg string) reflect.Value { + v := reflect.ValueOf(issue).Elem() + fieldVal := v.FieldByName(issueFieldName) + if !fieldVal.IsValid() { + utils.BailOut(fmt.Errorf("no such field: %s", issueFieldName), logMsg) + } + if fieldVal.Kind() != reflect.Bool { + utils.BailOut(fmt.Errorf("field %s is not of type bool", issueFieldName), logMsg) + } + + if !fieldVal.CanSet() { + utils.BailOut(fmt.Errorf("cannot set field: %s", issueFieldName), logMsg) + } + return fieldVal +} diff --git a/go/releaser/issue.go b/go/releaser/issue.go index 416d30e..5790840 100644 --- a/go/releaser/issue.go +++ b/go/releaser/issue.go @@ -79,6 +79,7 @@ const ( vtopUpdateGoItem = "Update vitess-operator Golang version." vtopUpdateCompTableItem = "Update vitess-operator compatibility table." createBlogPostPRItem = "Open a Pull Request on the website repository for the blog post." + UpdateCobraDocsItem = "Update Cobra Docs" // Release mergeReleasePRItem = "Merge the Release PR." @@ -95,13 +96,18 @@ const ( dockerImagesItem = "Docker Images available on DockerHub." closeMilestoneItem = "Close current GitHub Milestone." mergeBlogPostItem = "Merge the blog post Pull Request on the website repository." + VttestServerItem = "Check vttestserver image is pushed" + ReleaseArtifactsItem = "Check that release artifacts were generated" // Post-Release postSlackAnnouncementItem = "Notify the community on Slack for the new release." twitterItem = "Twitter announcement." closeReleaseItem = "Close this Issue." + RemoveBypassProtection = "Remove bypass protection for release branch" ) +var simpleItems = []string{UpdateCobraDocsItem, VttestServerItem} + type ( ItemWithLink struct { Done bool @@ -151,6 +157,7 @@ type ( VtopCreateReleasePR ItemWithLinks VtopManualUpdate bool CreateBlogPostPR bool + UpdateCobraDocs bool // Release MergeReleasePR ItemWithLink @@ -165,11 +172,13 @@ type ( Benchmarked bool DockerImages bool CloseMilestone ItemWithLink - + VtTestServer bool + ReleaseArtifacts bool // Post-Release - SlackPostRelease bool - Twitter bool - CloseIssue bool + SlackPostRelease bool + Twitter bool + CloseIssue bool + RemoveBypassProtection bool } ) @@ -257,6 +266,7 @@ const ( {{- if .GA }} - [{{fmtStatus .CreateBlogPostPR}}] Open a Pull Request on the website repository for the blog post. {{- end }} +- [{{fmtStatus .UpdateCobraDocs}}] Update Cobra Docs ### Release _({{fmtShortDate .Date }})_ @@ -298,12 +308,15 @@ const ( - {{ .CloseMilestone.URL }} {{- end }} {{- end }} - +- [{{fmtStatus .VtTestServer}}] Check vttestserver image is pushed. +- [{{fmtStatus .ReleaseArtifacts}}] Check that release artifacts were generated. ### Post-Release _({{fmtShortDate .Date }})_ - [{{fmtStatus .SlackPostRelease}}] Notify the community on Slack for the new release. - [{{fmtStatus .Twitter}}] Twitter announcement. +- [{{fmtStatus .RemoveBypassProtection}}] Remove bypass protection for release branch. - [{{fmtStatus .CloseIssue}}] Close this Issue. + ` ) @@ -497,6 +510,14 @@ func (s *State) LoadIssue() { newIssue.MergeBlogPostPR = strings.HasPrefix(line, markdownItemDone) case strings.Contains(line, javaRelease): newIssue.JavaRelease = strings.HasPrefix(line, markdownItemDone) + case strings.Contains(line, UpdateCobraDocsItem): + newIssue.UpdateCobraDocs = strings.HasPrefix(line, markdownItemDone) + case strings.Contains(line, VttestServerItem): + newIssue.VtTestServer = strings.HasPrefix(line, markdownItemDone) + case strings.Contains(line, ReleaseArtifactsItem): + newIssue.ReleaseArtifacts = strings.HasPrefix(line, markdownItemDone) + case strings.Contains(line, RemoveBypassProtection): + newIssue.RemoveBypassProtection = strings.HasPrefix(line, markdownItemDone) } case stateReadingGeneral: newIssue.General.Items = append(newIssue.General.Items, handleNewListItem(lines, i, &st)) diff --git a/go/releaser/steps/steps.go b/go/releaser/steps/steps.go index 24dfffd..b8ac1a5 100644 --- a/go/releaser/steps/steps.go +++ b/go/releaser/steps/steps.go @@ -39,6 +39,7 @@ const ( CreateReleasePR = "Create Release PR" CreateMilestone = "Create Milestone" VtopUpdateGolang = "Update Go version in vitess-operator" + UpdateCobraDocs = "Update Cobra Docs" // Release MergeReleasePR = "Merge Release PR" @@ -55,9 +56,12 @@ const ( Benchmarked = "Benchmarks" DockerImages = "Docker Images" CloseMilestone = "Close Milestone" + VtTestServer = "VtTestServer" + ReleaseArtifacts = "Release Artifacts" // Post-Release - SlackAnnouncementPost = "Slack Announcement Post-Release" - Twitter = "Twitter" - CloseIssue = "Close Issue" + SlackAnnouncementPost = "Slack Announcement Post-Release" + Twitter = "Twitter" + CloseIssue = "Close Issue" + RemoveBypassProtection = "Remove Bypass Protection" )