diff --git a/cli/internal/recipe.go b/cli/internal/recipe.go index 154afdcc..c75407b3 100644 --- a/cli/internal/recipe.go +++ b/cli/internal/recipe.go @@ -13,10 +13,27 @@ import ( // PromptBumpType prompts for version bump type func PromptBumpType(tagString string) error { if (!Major && !Minor && !Patch) && tagString == "" { - fmt.Printf(`semver cheat sheet (more via semver.org): - major: new features/bug fixes, backwards incompatible - minor: new features/bug fixes, backwards compatible - patch: bug fixes, backwards compatible + fmt.Printf(` +You need to make a decision about what kind of an update this new recipe +version is. If someone else performs this upgrade, do they have to do some +migration work or take care of some breaking changes? This can be signaled in +the version you specify on the recipe deploy label and is called a semantic +version. + +Here is a semver cheat sheet (more on https://semver.org): + + major: new features/bug fixes, backwards incompatible (e.g 1.0.0 -> 2.0.0). + the upgrade won't work without some preparation work and others need + to take care when performing it. "it could go wrong". + + minor: new features/bug fixes, backwards compatible (e.g. 0.1.0 -> 0.2.0). + the upgrade should Just Work and there are no breaking changes in + the app and the recipe config. "it should go fine". + + patch: bug fixes, backwards compatible (e.g. 0.0.1 -> 0.0.2). this upgrade + should also Just Work and is mostly to do with minor bug fixes + and/or security patches. "nothing to worry about". + `) var chosenBumpType string diff --git a/cli/recipe/release.go b/cli/recipe/release.go index 2a44c061..7037d012 100644 --- a/cli/recipe/release.go +++ b/cli/recipe/release.go @@ -99,6 +99,14 @@ keys configured on your account. logrus.Fatal(err) } + if tagString == "" { + var err error + tagString, err = getLabelVersion(recipe) + if err != nil { + logrus.Fatal(err) + } + } + if len(tags) > 0 { logrus.Warnf("previous git tags detected, assuming this is a new semver release") if err := createReleaseFromPreviousTag(tagString, mainAppVersion, recipe, tags); err != nil { @@ -107,32 +115,8 @@ keys configured on your account. } else { logrus.Warnf("no tag specified and no previous tag available for %s, assuming this is the initial release", recipe.Name) - initTag, err := recipePkg.GetVersionLabelLocal(recipe) - if err != nil { - logrus.Fatal(err) - } - - if initTag == "" { - logrus.Fatalf("unable to read version for %s from synced label. Did you try running \"abra recipe sync %s\" already?", recipe.Name, recipe.Name) - } - - logrus.Warnf("discovered %s as currently synced recipe label", initTag) - - prompt := &survey.Confirm{ - Message: fmt.Sprintf("use %s as the initial release?", initTag), - } - - var response bool - if err := survey.AskOne(prompt, &response); err != nil { - logrus.Fatal(err) - } - - if !response { - logrus.Fatalf("please fix your synced label for %s and re-run this command", recipe.Name) - } - - if err := createReleaseFromTag(recipe, initTag, mainAppVersion); err != nil { - if cleanUpErr := cleanUpTag(initTag, recipe.Name); err != nil { + if err := createReleaseFromTag(recipe, tagString, mainAppVersion); err != nil { + if cleanUpErr := cleanUpTag(tagString, recipe.Name); err != nil { logrus.Fatal(cleanUpErr) } logrus.Fatal(err) @@ -417,10 +401,39 @@ func cleanUpTag(tag, recipeName string) error { } if err := repo.DeleteTag(tag); err != nil { - return err + if !strings.Contains(err.Error(), "not found") { + return err + } } logrus.Debugf("removed freshly created tag %s", tag) return nil } + +func getLabelVersion(recipe recipe.Recipe) (string, error) { + initTag, err := recipePkg.GetVersionLabelLocal(recipe) + if err != nil { + return "", err + } + + if initTag == "" { + logrus.Fatalf("unable to read version for %s from synced label. Did you try running \"abra recipe sync %s\" already?", recipe.Name, recipe.Name) + } + + logrus.Warnf("discovered %s as currently synced recipe label", initTag) + + if !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 { + return "", err + } + + if !response { + return "", fmt.Errorf("please fix your synced label for %s and re-run this command", recipe.Name) + } + } + + return initTag, nil +} diff --git a/cli/recipe/sync.go b/cli/recipe/sync.go index 002759e4..63e443cd 100644 --- a/cli/recipe/sync.go +++ b/cli/recipe/sync.go @@ -61,16 +61,21 @@ local file system. if len(tags) == 0 && nextTag == "" { logrus.Warnf("no git tags found for %s", recipe.Name) fmt.Println(fmt.Sprintf(` -The following options are two types of initial version that you can pick for -the first published version of %s that will be in the recipe catalogue. This -follows the semver convention (more on semver.org), here is a short cheatsheet +The following options are two types of initial semantic version that you can +pick for %s that will be published in the recipe catalogue. This follows the +semver convention (more on https://semver.org), here is a short cheatsheet - 0.1.0 -> development release, still hacking - 1.0.0 -> public release, assumed to be working + 0.1.0: development release, still hacking. when you make a major upgrade + you increment the "y" part (i.e. 0.1.0 -> 0.2.0) and only move to + using the "x" part when things are stable. -In other words, if you want people to be able alpha test your current config -for %s but don't think it is quite ready and reliable, go with 0.1.0 and people -will know that things are likely to change. + 1.0.0: public release, assumed to be working. you already have a stable + and reliable deployment of this app and feel relatively confident + about it. + +If you want people to be able alpha test your current config for %s but don't +think it is quite reliable, go with 0.1.0 and people will know that things are +likely to change. `, recipe.Name, recipe.Name)) var chosenVersion string