Skip to content

Commit

Permalink
mageutils:feat - Adding new method to add/remove tag (#166)
Browse files Browse the repository at this point in the history
In this commit I added the new method CreateAndPushTag for create and
up new tag. And other new method RemoveTag for delete local and in
origin tag.

Signed-off-by: Wilian Gabriel <wilian.silva@zup.com.br>
  • Loading branch information
wiliansilvazup authored Feb 22, 2022
1 parent 568a7a0 commit 4f0f347
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/utils/mageutils/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4f0f347

Please sign in to comment.