fix: take version from sync when releasing

This commit is contained in:
decentral1se 2021-12-28 03:40:02 +01:00
parent 1fd0941239
commit 24882e95b4
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
1 changed files with 17 additions and 13 deletions

View File

@ -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 {