forked from toolshed/abra
refactor(recipe): use template for ssh url
This commit is contained in:
@ -20,6 +20,7 @@ import (
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
"github.com/distribution/reference"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@ -62,6 +63,7 @@ your SSH keys configured on your account.
|
||||
BashComplete: autocomplete.RecipeNameComplete,
|
||||
Action: func(c *cli.Context) error {
|
||||
recipe := internal.ValidateRecipe(c)
|
||||
r := recipePkg.Get2(recipe.Name)
|
||||
|
||||
imagesTmp, err := getImageVersions(recipe)
|
||||
if err != nil {
|
||||
@ -90,7 +92,7 @@ your SSH keys configured on your account.
|
||||
}
|
||||
|
||||
if tagString != "" {
|
||||
if err := createReleaseFromTag(recipe, tagString, mainAppVersion); err != nil {
|
||||
if err := createReleaseFromTag(r, tagString, mainAppVersion); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
@ -121,14 +123,14 @@ your SSH keys configured on your account.
|
||||
}
|
||||
|
||||
if len(tags) > 0 {
|
||||
log.Warnf("previous git tags detected, assuming this is a new semver release")
|
||||
if err := createReleaseFromPreviousTag(tagString, mainAppVersion, recipe, tags); err != nil {
|
||||
logrus.Warnf("previous git tags detected, assuming this is a new semver release")
|
||||
if err := createReleaseFromPreviousTag(tagString, mainAppVersion, r, tags); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
log.Warnf("no tag specified and no previous tag available for %s, assuming this is the initial release", recipe.Name)
|
||||
|
||||
if err := createReleaseFromTag(recipe, tagString, mainAppVersion); err != nil {
|
||||
if err := createReleaseFromTag(r, tagString, mainAppVersion); err != nil {
|
||||
if cleanUpErr := cleanUpTag(tagString, recipe.Name); err != nil {
|
||||
log.Fatal(cleanUpErr)
|
||||
}
|
||||
@ -181,7 +183,7 @@ func getImageVersions(recipe recipe.Recipe) (map[string]string, error) {
|
||||
}
|
||||
|
||||
// createReleaseFromTag creates a new release based on a supplied recipe version string
|
||||
func createReleaseFromTag(recipe recipe.Recipe, tagString, mainAppVersion string) error {
|
||||
func createReleaseFromTag(recipe recipe.Recipe2, tagString, mainAppVersion string) error {
|
||||
var err error
|
||||
|
||||
directory := path.Join(config.RECIPES_DIR, recipe.Name)
|
||||
@ -245,7 +247,7 @@ func getTagCreateOptions(tag string) (git.CreateTagOptions, error) {
|
||||
|
||||
// addReleaseNotes checks if the release/next release note exists and moves the
|
||||
// file to release/<tag>.
|
||||
func addReleaseNotes(recipe recipe.Recipe, tag string) error {
|
||||
func addReleaseNotes(recipe recipe.Recipe2, tag string) error {
|
||||
repoPath := path.Join(config.RECIPES_DIR, recipe.Name)
|
||||
tagReleaseNotePath := path.Join(repoPath, "release", tag)
|
||||
if _, err := os.Stat(tagReleaseNotePath); err == nil {
|
||||
@ -319,20 +321,20 @@ func addReleaseNotes(recipe recipe.Recipe, tag string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func commitRelease(recipe recipe.Recipe, tag string) error {
|
||||
func commitRelease(recipe recipe.Recipe2, tag string) error {
|
||||
if internal.Dry {
|
||||
log.Debugf("dry run: no changes committed")
|
||||
return nil
|
||||
}
|
||||
|
||||
isClean, err := gitPkg.IsClean(recipe.Dir())
|
||||
isClean, err := gitPkg.IsClean(recipe.Dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if isClean {
|
||||
if !internal.Dry {
|
||||
return fmt.Errorf("no changes discovered in %s, nothing to publish?", recipe.Dir())
|
||||
return fmt.Errorf("no changes discovered in %s, nothing to publish?", recipe.Dir)
|
||||
}
|
||||
}
|
||||
|
||||
@ -372,7 +374,7 @@ func tagRelease(tagString string, repo *git.Repository) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func pushRelease(recipe recipe.Recipe, tagString string) error {
|
||||
func pushRelease(recipe recipe.Recipe2, tagString string) error {
|
||||
if internal.Dry {
|
||||
log.Info("dry run: no changes published")
|
||||
return nil
|
||||
@ -401,7 +403,7 @@ func pushRelease(recipe recipe.Recipe, tagString string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func createReleaseFromPreviousTag(tagString, mainAppVersion string, recipe recipe.Recipe, tags []string) error {
|
||||
func createReleaseFromPreviousTag(tagString, mainAppVersion string, recipe recipe.Recipe2, tags []string) error {
|
||||
directory := path.Join(config.RECIPES_DIR, recipe.Name)
|
||||
repo, err := git.PlainOpen(directory)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user