From 24882e95b46d0023e6c4dfb234b3dd57f8c1c1f6 Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Tue, 28 Dec 2021 03:40:02 +0100 Subject: [PATCH] fix: take version from sync when releasing --- cli/recipe/release.go | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/cli/recipe/release.go b/cli/recipe/release.go index 7037d012..dbd8d425 100644 --- a/cli/recipe/release.go +++ b/cli/recipe/release.go @@ -99,9 +99,9 @@ keys configured on your account. logrus.Fatal(err) } - if tagString == "" { + if tagString == "" && (!internal.Major && !internal.Minor && !internal.Patch) { var err error - tagString, err = getLabelVersion(recipe) + tagString, err = getLabelVersion(recipe, false) if err != nil { logrus.Fatal(err) } @@ -314,11 +314,13 @@ func createReleaseFromPreviousTag(tagString, mainAppVersion string, recipe recip } } - if err := internal.PromptBumpType(tagString); err != nil { - return err + var lastGitTag tagcmp.Tag + if tagString == "" { + if err := internal.PromptBumpType(tagString); err != nil { + return err + } } - var lastGitTag tagcmp.Tag for _, tag := range tags { parsed, err := tagcmp.Parse(tag) if err != nil { @@ -359,12 +361,14 @@ func createReleaseFromPreviousTag(tagString, mainAppVersion string, recipe recip newTag.Major = strconv.Itoa(now + 1) } - newTag.Metadata = mainAppVersion - newTagString := newTag.String() + if internal.Major || internal.Minor || internal.Patch { + newTag.Metadata = mainAppVersion + tagString = newTag.String() + } if !internal.NoInput { prompt := &survey.Confirm{ - Message: fmt.Sprintf("current: %s, new: %s, correct?", lastGitTag, newTagString), + Message: fmt.Sprintf("current: %s, new: %s, correct?", lastGitTag, tagString), } var ok bool @@ -377,15 +381,15 @@ func createReleaseFromPreviousTag(tagString, mainAppVersion string, recipe recip } } - if err := commitRelease(recipe, newTagString); err != nil { + if err := commitRelease(recipe, tagString); err != nil { logrus.Fatal(err) } - if err := tagRelease(newTagString, repo); err != nil { + if err := tagRelease(tagString, repo); err != nil { logrus.Fatal(err) } - if err := pushRelease(recipe); err != nil { + if err := pushRelease(recipe, tagString); err != nil { logrus.Fatal(err) } @@ -411,7 +415,7 @@ func cleanUpTag(tag, recipeName string) error { return nil } -func getLabelVersion(recipe recipe.Recipe) (string, error) { +func getLabelVersion(recipe recipe.Recipe, prompt bool) (string, error) { initTag, err := recipePkg.GetVersionLabelLocal(recipe) if err != nil { return "", err @@ -423,7 +427,7 @@ func getLabelVersion(recipe recipe.Recipe) (string, error) { logrus.Warnf("discovered %s as currently synced recipe label", initTag) - if !internal.NoInput { + if prompt && !internal.NoInput { var response bool prompt := &survey.Confirm{Message: fmt.Sprintf("use %s as the new version?", initTag)} if err := survey.AskOne(prompt, &response); err != nil {