Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions go/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package cmd

import (
"context"
"fmt"
"os"

Expand Down Expand Up @@ -61,17 +62,19 @@ func Execute() {
panic(err)
}

var ctx releaser.Context
var s releaser.State

if live {
ctx.VitessRepo = "vitessio/vitess"
s.VitessRepo = "vitessio/vitess"
} else {
ctx.VitessRepo = github.CurrentUser() + "/vitess"
s.VitessRepo = github.CurrentUser() + "/vitess"
}
ctx.MajorRelease = releaseVersion
ctx.IssueNbGH, ctx.IssueLink = github.GetReleaseIssueInfo(ctx.VitessRepo, ctx.MajorRelease)
s.MajorRelease = releaseVersion
s.IssueNbGH, s.IssueLink = github.GetReleaseIssueInfo(s.VitessRepo, s.MajorRelease)

if err := rootCmd.ExecuteContext(&ctx); err != nil {
ctx := releaser.WrapState(context.Background(), &s)

if err := rootCmd.ExecuteContext(ctx); err != nil {
fmt.Fprintf(os.Stderr, "Whoops. There was an error while executing your CLI '%s'", err)
os.Exit(1)
}
Expand Down
10 changes: 5 additions & 5 deletions go/cmd/interactive/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ package interactive

import (
"github.com/spf13/cobra"
"vitess.io/vitess-releaser/go/interactive"
"vitess.io/vitess-releaser/go/releaser"
"vitess.io/vitess-releaser/go/releaser/git"

"vitess.io/vitess-releaser/go/interactive"
)

func Command() *cobra.Command {
Expand All @@ -30,13 +29,14 @@ func Command() *cobra.Command {
Aliases: []string{"i"},
Short: "Runs the releaser in interactive mode",
Run: func(cmd *cobra.Command, args []string) {
ctx := releaser.UnwrapCtx(cmd.Context())
git.CorrectCleanRepo(ctx.VitessRepo)
ctx := cmd.Context()
state := releaser.UnwrapState(ctx)
git.CorrectCleanRepo(state.VitessRepo)

// TODO: The assumption that the Release Manager won't be
// modifying the release issue while using vitess-releaser
// is made here, perhaps there is a better way of doing it
ctx.LoadIssue()
state.LoadIssue()

interactive.MainScreen(ctx)
},
Expand Down
6 changes: 3 additions & 3 deletions go/cmd/post_release/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ var slackAnnouncement = &cobra.Command{
Use: "slack",
Short: "Prompts the Slack announcement for the post release step",
Run: func(cmd *cobra.Command, args []string) {
ctx := releaser.UnwrapCtx(cmd.Context())
ctx := releaser.UnwrapState(cmd.Context())
msg := slack.PostReleaseMessage(ctx)
fmt.Print("Please post this message in the #general and #releases channels:\n\n")
fmt.Println("\t"+msg)
fmt.Println("\t" + msg)
},
}
}
4 changes: 2 additions & 2 deletions go/cmd/pre_release/code_freeze.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ var codeFreeze = &cobra.Command{
Use: "code-freeze",
Short: "Does the code-freeze of a release",
Run: func(cmd *cobra.Command, args []string) {
ctx := releaser.UnwrapCtx(cmd.Context())
_, freeze := pre_release.CodeFreeze(ctx)
state := releaser.UnwrapState(cmd.Context())
_, freeze := pre_release.CodeFreeze(state)
out := freeze()
fmt.Println("Please force merge the Pull Request created for code freeze:", out)
},
Expand Down
4 changes: 2 additions & 2 deletions go/cmd/pre_release/milestone.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ var createMilestone = &cobra.Command{
Use: "create-milestone",
Short: "Create the next milestone for the future release.",
Run: func(cmd *cobra.Command, args []string) {
ctx := releaser.UnwrapCtx(cmd.Context())
ctx := releaser.UnwrapState(cmd.Context())
_, newMilestone := pre_release.NewMilestone(ctx)
out := newMilestone()
fmt.Println("New milestone created or found on GitHub:", out)
},
}
}
2 changes: 1 addition & 1 deletion go/cmd/prerequisite/check_and_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var checkAndAdd = &cobra.Command{
Use: "check-and-add",
Short: "Checks and adds pending Pull Request and Release Blocker Issues to the release Issue",
Run: func(cmd *cobra.Command, args []string) {
ctx := releaser.UnwrapCtx(cmd.Context())
ctx := releaser.UnwrapState(cmd.Context())
_, check := prerequisite.CheckAndAddPRsIssues(ctx)
msg := check()
fmt.Println(msg)
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/prerequisite/create_issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var createIssue = &cobra.Command{
Use: "create-issue",
Short: "Create the release issue",
Run: func(cmd *cobra.Command, args []string) {
ctx := releaser.UnwrapCtx(cmd.Context())
ctx := releaser.UnwrapState(cmd.Context())
_, createIssueFn := releaser.CreateReleaseIssue(ctx)
_, link := createIssueFn()
fmt.Println("Link to the new GitHub Issue: ", link)
Expand Down
6 changes: 3 additions & 3 deletions go/cmd/prerequisite/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ var slackAnnouncement = &cobra.Command{
Use: "slack",
Short: "Prompts the Slack announcement for the prerequisite step",
Run: func(cmd *cobra.Command, args []string) {
ctx := releaser.UnwrapCtx(cmd.Context())
ctx := releaser.UnwrapState(cmd.Context())
msg := slack.AnnouncementMessage(ctx)
fmt.Print("Please post this message in the #general and #releases channels:\n\n")
fmt.Println("\t"+msg)
fmt.Println("\t" + msg)
},
}
}
29 changes: 16 additions & 13 deletions go/interactive/check_and_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package interactive

import (
"context"

tea "github.com/charmbracelet/bubbletea"
"vitess.io/vitess-releaser/go/releaser"
"vitess.io/vitess-releaser/go/releaser/prerequisite"
Expand All @@ -25,14 +27,22 @@ import (

type checkAndAdd string

func checkAndAddMenuItem(ctx *releaser.Context) *menuItem {
func checkAndAddMenuItem(ctx context.Context) *menuItem {
state := releaser.UnwrapState(ctx)
return &menuItem{
ctx: ctx,
state: state,
name: steps.CheckAndAdd,
act: checkAndAddAct,
update: checkAndAddUpdate,
isDone: ctx.IssueNbGH != 0 && ctx.Issue.CheckBackport.Done() && ctx.Issue.ReleaseBlocker.Done(),
info: prerequisite.GetCheckAndAddInfoMsg(ctx, ctx.IssueLink),
isDone: state.IssueNbGH != 0 && state.Issue.CheckBackport.Done() && state.Issue.ReleaseBlocker.Done(),
info: "Loading ...",
init: initCheckAndAdd,
}
}

func initCheckAndAdd(mi *menuItem) tea.Cmd {
_, add := prerequisite.CheckAndAddPRsIssues(mi.state)
return func() tea.Msg {
return checkAndAdd(add())
}
}

Expand All @@ -44,13 +54,6 @@ func checkAndAddUpdate(mi *menuItem, msg tea.Msg) (*menuItem, tea.Cmd) {

outStr := string(out)
mi.info = outStr
mi.isDone = mi.ctx.Issue.CheckBackport.Done() && mi.ctx.Issue.ReleaseBlocker.Done()
mi.isDone = mi.state.Issue.CheckBackport.Done() && mi.state.Issue.ReleaseBlocker.Done()
return mi, nil
}

func checkAndAddAct(mi *menuItem) (*menuItem, tea.Cmd) {
pl, add := prerequisite.CheckAndAddPRsIssues(mi.ctx)
return mi, tea.Batch(func() tea.Msg {
return checkAndAdd(add())
}, pushDialog(newProgressDialog("Check and add pending PRs and release blocker Issues to Release Issue", pl)))
}
15 changes: 9 additions & 6 deletions go/interactive/check_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package interactive

import (
"context"

tea "github.com/charmbracelet/bubbletea"
"vitess.io/vitess-releaser/go/releaser"
"vitess.io/vitess-releaser/go/releaser/prerequisite"
Expand All @@ -25,11 +27,12 @@ import (

type checkSummary []string

func checkSummaryMenuItem(ctx *releaser.Context) *menuItem {
func checkSummaryMenuItem(ctx context.Context) *menuItem {
state := releaser.UnwrapState(ctx)
return &menuItem{
ctx: ctx,
state: state,
name: steps.CheckSummary,
isDone: ctx.Issue.CheckSummary,
isDone: state.Issue.CheckSummary,
act: checkSummaryAct,
update: checkSummaryUpdate,
}
Expand All @@ -48,9 +51,9 @@ func checkSummaryUpdate(mi *menuItem, msg tea.Msg) (*menuItem, tea.Cmd) {
if string(msg) != mi.name {
return mi, nil
}
mi.ctx.Issue.CheckSummary = !mi.ctx.Issue.CheckSummary
mi.state.Issue.CheckSummary = !mi.state.Issue.CheckSummary
mi.isDone = !mi.isDone
pl, fn := mi.ctx.UploadIssue()
pl, fn := mi.state.UploadIssue()
return mi, tea.Batch(func() tea.Msg {
fn()
return tea.Msg("")
Expand All @@ -61,6 +64,6 @@ func checkSummaryUpdate(mi *menuItem, msg tea.Msg) (*menuItem, tea.Cmd) {

func checkSummaryAct(mi *menuItem) (*menuItem, tea.Cmd) {
return mi, func() tea.Msg {
return checkSummary(prerequisite.CheckSummary(mi.ctx))
return checkSummary(prerequisite.CheckSummary(mi.state))
}
}
17 changes: 10 additions & 7 deletions go/interactive/code_freeze.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@ limitations under the License.
package interactive

import (
"context"

tea "github.com/charmbracelet/bubbletea"
"vitess.io/vitess-releaser/go/releaser"
"vitess.io/vitess-releaser/go/releaser/steps"

"vitess.io/vitess-releaser/go/releaser/pre_release"
)

func codeFreezeMenuItem(ctx *releaser.Context) *menuItem {
func codeFreezeMenuItem(ctx context.Context) *menuItem {
state := releaser.UnwrapState(ctx)
return &menuItem{
ctx: ctx,
state: state,
name: steps.CodeFreeze,
act: codeFreezeAct,
update: codeFreezeUpdate,
info: ctx.Issue.CodeFreeze.URL,
isDone: ctx.Issue.CodeFreeze.Done,
info: state.Issue.CodeFreeze.URL,
isDone: state.Issue.CodeFreeze.Done,
}
}

Expand All @@ -43,13 +46,13 @@ func codeFreezeUpdate(mi *menuItem, msg tea.Msg) (*menuItem, tea.Cmd) {
return mi, nil
}

mi.info = mi.ctx.Issue.CodeFreeze.URL
mi.isDone = mi.ctx.Issue.CodeFreeze.Done
mi.info = mi.state.Issue.CodeFreeze.URL
mi.isDone = mi.state.Issue.CodeFreeze.Done
return mi, nil
}

func codeFreezeAct(mi *menuItem) (*menuItem, tea.Cmd) {
pl, freeze := pre_release.CodeFreeze(mi.ctx)
pl, freeze := pre_release.CodeFreeze(mi.state)
return mi, tea.Batch(func() tea.Msg {
return codeFreezeUrl(freeze())
}, pushDialog(newProgressDialog("Code freeze", pl)))
Expand Down
19 changes: 11 additions & 8 deletions go/interactive/create_github_milestones.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package interactive

import (
"context"

tea "github.com/charmbracelet/bubbletea"
"vitess.io/vitess-releaser/go/releaser"
"vitess.io/vitess-releaser/go/releaser/pre_release"
Expand All @@ -25,18 +27,19 @@ import (

type createMilestone string

func createMilestoneMenuItem(ctx *releaser.Context) *menuItem {
func createMilestoneMenuItem(ctx context.Context) *menuItem {
state := releaser.UnwrapState(ctx)
act := createMilestoneAct
if ctx.Issue.NewGitHubMilestone.Done {
if state.Issue.NewGitHubMilestone.Done {
act = nil
}
return &menuItem{
ctx: ctx,
state: state,
name: steps.CreateMilestone,
act: act,
update: createMilestoneUpdate,
info: ctx.Issue.NewGitHubMilestone.URL,
isDone: ctx.Issue.NewGitHubMilestone.Done,
info: state.Issue.NewGitHubMilestone.URL,
isDone: state.Issue.NewGitHubMilestone.Done,
}
}

Expand All @@ -46,14 +49,14 @@ func createMilestoneUpdate(mi *menuItem, msg tea.Msg) (*menuItem, tea.Cmd) {
return mi, nil
}

mi.info = mi.ctx.Issue.NewGitHubMilestone.URL
mi.isDone = mi.ctx.Issue.NewGitHubMilestone.Done
mi.info = mi.state.Issue.NewGitHubMilestone.URL
mi.isDone = mi.state.Issue.NewGitHubMilestone.Done
mi.act = nil // We don't want to accidentally create a second one
return mi, nil
}

func createMilestoneAct(mi *menuItem) (*menuItem, tea.Cmd) {
pl, create := pre_release.NewMilestone(mi.ctx)
pl, create := pre_release.NewMilestone(mi.state)
return mi, tea.Batch(func() tea.Msg {
return createMilestone(create())
}, pushDialog(newProgressDialog("Creating new GitHub Milestone", pl)))
Expand Down
17 changes: 10 additions & 7 deletions go/interactive/create_release_pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@ limitations under the License.
package interactive

import (
"context"

tea "github.com/charmbracelet/bubbletea"
"vitess.io/vitess-releaser/go/releaser"
"vitess.io/vitess-releaser/go/releaser/pre_release"
"vitess.io/vitess-releaser/go/releaser/steps"
)

func createReleasePRMenuItem(ctx *releaser.Context) *menuItem {
func createReleasePRMenuItem(ctx context.Context) *menuItem {
state := releaser.UnwrapState(ctx)
return &menuItem{
ctx: ctx,
state: state,
name: steps.CreateReleasePR,
act: createReleasePRAct,
update: createReleasePRUpdate,
info: ctx.Issue.CreateReleasePR.URL,
isDone: ctx.Issue.CreateReleasePR.Done,
info: state.Issue.CreateReleasePR.URL,
isDone: state.Issue.CreateReleasePR.Done,
}
}

Expand All @@ -42,13 +45,13 @@ func createReleasePRUpdate(mi *menuItem, msg tea.Msg) (*menuItem, tea.Cmd) {
return mi, nil
}

mi.info = mi.ctx.Issue.CreateReleasePR.URL
mi.isDone = mi.ctx.Issue.CreateReleasePR.Done
mi.info = mi.state.Issue.CreateReleasePR.URL
mi.isDone = mi.state.Issue.CreateReleasePR.Done
return mi, nil
}

func createReleasePRAct(mi *menuItem) (*menuItem, tea.Cmd) {
pl, fn := pre_release.CreateReleasePR(mi.ctx)
pl, fn := pre_release.CreateReleasePR(mi.state)
return mi, tea.Batch(func() tea.Msg {
return createReleasePRUrl(fn())
}, pushDialog(newProgressDialog("Create the Release Pull Request", pl)))
Expand Down
Loading