diff --git a/pkg/utils/mageutils/release.go b/pkg/utils/mageutils/release.go index 4079825..6fea4eb 100644 --- a/pkg/utils/mageutils/release.go +++ b/pkg/utils/mageutils/release.go @@ -44,6 +44,32 @@ func CreateLocalTag(tag string) (err error) { return sh.RunV("git", "tag", "-s", tag, "-m", "release "+tag) } +// CreateAndPushTag create and push a new given tag executing +// "git tag -s tag -m release+tag" and "git push --tags" +func CreateAndPushTag(tag string) (err error) { + mg.Deps(isGitExistent) + mg.Deps(mg.F(isValidTag, tag)) + + if err := sh.RunV("git", "tag", "-s", tag, "-m", "release "+tag); err != nil { + return err + } + + return sh.RunV("git", "push", "--tags") +} + +// RemoveTag remove tag locally and in the origin +// "git tag -d tag" and "git push --delete origin tag" +func RemoveTag(tag string) (err error) { + mg.Deps(isGitExistent) + mg.Deps(mg.F(isValidTag, tag)) + + if err := sh.RunV("git", "tag", "-d", tag); err != nil { + return err + } + + return sh.RunV("git", "push", "--delete", "origin", tag) +} + // CheckoutReleaseBranch creates if not exists a release branch and then checkout // @TODO validate release branch name with regex func CheckoutReleaseBranch(branchName string) error {