Skip to content
Snippets Groups Projects
Commit abb72fab authored by Johan de Klerk's avatar Johan de Klerk
Browse files

Create release tag

parent 380e9ac8
Branches
Tags
No related merge requests found
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"os/exec" "os/exec"
"strings" "strings"
"github.com/Masterminds/semver"
) )
func HasChanges(previousCommit string, folder string) bool { func HasChanges(previousCommit string, folder string) bool {
...@@ -43,3 +44,55 @@ func CurrentCommit() string { ...@@ -43,3 +44,55 @@ func CurrentCommit() string {
} }
return string(output) return string(output)
} }
func CreateReleaseTag() {
// Get version and increase version number
previousVersion, err := semver.NewVersion(GetLatestGitTag())
if err != nil {
fmt.Println(err)
}
newVersion := previousVersion.IncMinor()
// Create git tag
newTagName := newVersion.Original()
commandArgs := []string{
`tag`,
newTagName,
}
cmd := exec.Command("git", commandArgs...)
_, err = cmd.CombinedOutput()
if err != nil {
fmt.Println(err)
}
// Push new tag
commandArgs = []string{
`push`,
`origin`,
newTagName,
}
cmd = exec.Command("git", commandArgs...)
_, err = cmd.CombinedOutput()
if err != nil {
fmt.Println(err)
}
return
}
func GetLatestGitTag() string {
commandArgs := []string{
`describe`,
`--tags`,
}
cmd := exec.Command("git", commandArgs...)
output, err := cmd.CombinedOutput()
if err != nil {
fmt.Println(err)
}
tag := string(output)
tag = strings.TrimSuffix(tag, "\n")
return tag
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment