Skip to content

Commit

Permalink
Prompt to add the release tag (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnstn committed Feb 29, 2024
1 parent b491fea commit 4347b2d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 19 deletions.
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 @@ -197,10 +197,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 @@ -216,7 +218,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

0 comments on commit 4347b2d

Please sign in to comment.