From 9faefd25922b2b7acf6c035758e9b4a07d5a6245 Mon Sep 17 00:00:00 2001 From: knoflook Date: Thu, 23 Sep 2021 18:52:21 +0200 Subject: [PATCH] feat: push the new tag with --push --- cli/recipe/release.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cli/recipe/release.go b/cli/recipe/release.go index 5dddafb8f..eb717fa4b 100644 --- a/cli/recipe/release.go +++ b/cli/recipe/release.go @@ -17,6 +17,13 @@ import ( "github.com/urfave/cli/v2" ) +var Push bool +var PushFlag = &cli.BoolFlag{ + Name: "push", + Value: false, + Destination: &Push, +} + var Dry bool var DryFlag = &cli.BoolFlag{ Name: "dry-run", @@ -59,6 +66,7 @@ var recipeReleaseCommand = &cli.Command{ PatchFlag, MinorFlag, MajorFlag, + PushFlag, }, Action: func(c *cli.Context) error { recipe := internal.ValidateRecipe(c) @@ -85,6 +93,12 @@ var recipeReleaseCommand = &cli.Command{ Message: tag, })*/ logrus.Info(fmt.Sprintf("Created tag %s at %s.", tagstring, head.Hash())) + if Push { + if err := repo.Push(&git.PushOptions{}); err != nil { + logrus.Fatal(err) + } + logrus.Info(fmt.Sprintf("Pushed tag %s to remote.", tagstring)) + } return nil } @@ -164,6 +178,12 @@ var recipeReleaseCommand = &cli.Command{ Message: tag, })*/ logrus.Info(fmt.Sprintf("Created tag %s at %s.", newTagString, head.Hash())) + if Push { + if err := repo.Push(&git.PushOptions{}); err != nil { + logrus.Fatal(err) + } + logrus.Info(fmt.Sprintf("Pushed tag %s to remote.", newTagString)) + } return nil