Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLI] Prompt to add the release tag #243

Merged
merged 1 commit into from
Feb 29, 2024
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
6 changes: 3 additions & 3 deletions gbm-cli/cmd/release/prepare/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ var allCmd = &cobra.Command{

console.Info("Preparing Gutenberg for release %s", version)
build := release.Build{
Dir: gbDir,
Version: version,
UseTag: !noTag,
Dir: gbDir,
Version: version,
PromptToTag: !noTag,
Base: gh.Repo{
Ref: "trunk",
},
Expand Down
8 changes: 4 additions & 4 deletions gbm-cli/cmd/release/prepare/gb.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ var gbCmd = &cobra.Command{

defer workspace.Cleanup()
build := release.Build{
Dir: tempDir,
Version: version,
UseTag: !noTag,
Repo: "gutenberg",
Dir: tempDir,
Version: version,
PromptToTag: !noTag,
Repo: "gutenberg",
Base: gh.Repo{
Ref: "trunk",
},
Expand Down
2 changes: 1 addition & 1 deletion gbm-cli/cmd/release/prepare/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func init() {
PrepareCmd.AddCommand(gbCmd)
PrepareCmd.AddCommand(allCmd)
PrepareCmd.PersistentFlags().BoolVar(&keepTempDir, "keep", false, "Keep temporary directory after running command")
PrepareCmd.PersistentFlags().BoolVar(&noTag, "no-tag", false, "Prevent tagging the release")
PrepareCmd.PersistentFlags().BoolVar(&noTag, "no-tag", false, "Prevent tagging the release. If not set, you will be prompted to tag the release")
PrepareCmd.PersistentFlags().StringSliceVar(&prs, "prs", []string{}, "prs to include in the release. Only used with patch releases")
}

Expand Down
20 changes: 16 additions & 4 deletions gbm-cli/pkg/release/gb.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,12 @@ func CreateGbPR(build Build) (gh.PullRequest, error) {

gh.PreviewPr("gutenberg", dir, build.Base.Ref, pr)

prompt := fmt.Sprintf("\nReady to create the PR on %s/gutenberg?", org)
cont := console.Confirm(prompt)
var prompt string

if !cont {
prompt = fmt.Sprintf("\nReady to create the PR on %s/gutenberg?", org)
shouldCreatePr := console.Confirm(prompt)

if !shouldCreatePr {
return pr, fmt.Errorf("exiting before creating PR")
}

Expand All @@ -221,7 +223,17 @@ func CreateGbPR(build Build) (gh.PullRequest, error) {
return pr, fmt.Errorf("pr was not created successfully")
}

if build.UseTag {
// Only tag if we are prompting to tag
var shouldTag bool

if build.PromptToTag {
prompt = fmt.Sprintf("\nDo you want to create the release tag on %s/gutenberg?", org)
shouldTag = console.Confirm(prompt)
} else {
shouldTag = false
}

if shouldTag {
console.Info("Adding release tag")
if err := git.PushTag("rnmobile/" + version); err != nil {
console.Warn("Error tagging the release: %v", err)
Expand Down
14 changes: 7 additions & 7 deletions gbm-cli/pkg/release/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
)

type Build struct {
Version semver.SemVer
Dir string
UseTag bool
Repo string
Prs []gh.PullRequest
Base gh.Repo
Depth string
Version semver.SemVer
Dir string
PromptToTag bool
Repo string
Prs []gh.PullRequest
Base gh.Repo
Depth string
}

type ReleaseChanges struct {
Expand Down
Loading