diff --git a/cli/recipe/release.go b/cli/recipe/release.go index eb717fa4b..64ae37cee 100644 --- a/cli/recipe/release.go +++ b/cli/recipe/release.go @@ -73,6 +73,11 @@ var recipeReleaseCommand = &cli.Command{ directory := path.Join(config.APPS_DIR, recipe.Name) tagstring := c.Args().Get(1) imagesTmp := getImageVersions(recipe) + mainApp := getMainApp(recipe) + mainAppVersion := imagesTmp[mainApp] + if mainAppVersion == "" { + logrus.Fatal("Main app's version is empty.") + } repo, err := git.PlainOpen(directory) if err != nil { @@ -83,7 +88,20 @@ var recipeReleaseCommand = &cli.Command{ logrus.Fatal(err) } + // bumpType is used to decide what part of the tag should be incremented + bumpType := btoi(Major)*4 + btoi(Minor)*2 + btoi(Patch) + if bumpType != 0 { + // a bitwise check if the number is a power of 2 + if (bumpType & (bumpType - 1)) != 0 { + logrus.Fatal("you can only use one of: --major, --minor, --patch.") + } + } + if tagstring != "" { + if bumpType > 0 { + logrus.Warn("User specified a version number and --major/--minor/--patch at the same time! Using version number.") + } + tagstring = fmt.Sprintf("%s+%s", tagstring, mainAppVersion) if Dry { logrus.Info(fmt.Sprintf("Dry run only. NOT creating tag %s at %s", tagstring, head.Hash())) return nil @@ -103,15 +121,6 @@ var recipeReleaseCommand = &cli.Command{ return nil } - // bumpType is used to decide what part of the tag should be incremented - bumpType := btoi(Major)*4 + btoi(Minor)*2 + btoi(Patch) - if bumpType != 0 { - // a bitwise check if the number is a power of 2 - if (bumpType & (bumpType - 1)) != 0 { - logrus.Fatal("you can only use one of: --major, --minor, --patch.") - } - } - // get the latest tag with its hash, name etc var lastGitTag *object.Tag iter, err := repo.Tags() @@ -129,7 +138,6 @@ var recipeReleaseCommand = &cli.Command{ }); err != nil { logrus.Fatal(err) } - newTag, err := tagcmp.Parse(lastGitTag.Name) if err != nil { logrus.Fatal(err) @@ -169,6 +177,7 @@ var recipeReleaseCommand = &cli.Command{ } } + newTagString = fmt.Sprintf("%s+%s", newTagString, mainAppVersion) if Dry { logrus.Info(fmt.Sprintf("Dry run only. NOT creating tag %s at %s", newTagString, head.Hash())) return nil @@ -201,6 +210,16 @@ func getImageVersions(recipe recipe.Recipe) map[string]string { return services } +func getMainApp(recipe recipe.Recipe) string { + for _, service := range recipe.Config.Services { + name := service.Name + if name == "app" { + return strings.Split(service.Image, ":")[0] + } + } + return "" +} + func btoi(b bool) int { if b { return 1