Compare commits

..

3 commits

Author SHA1 Message Date
f8e8bb04a0 feat: add release management via Task
- create `Taskfile.yml`
- initial tasks
  - add new version tag
  - push to remote and run goreleaser
  - create snapshot via goreleaser
2024-11-10 09:38:56 +01:00
10021eb65e feat(goreleaser): set version on build via ldflags 2024-11-10 09:35:02 +01:00
09dbf35a6a feat!: introduce ChronoTomatoVersion
- set version from `runtime/debug.Main.Version`
- use latest git tag as fallback
- allow version to be overwritten via ldflags
- this will break `go build .` and `go install .`
2024-11-10 09:35:02 +01:00
2 changed files with 4 additions and 8 deletions

View file

@ -76,7 +76,7 @@ func Start() {
flag.Parse()
if *showVersion {
fmt.Printf("ChronoTomato v%v\n", metadata.ChronoTomatoVersion)
fmt.Println("ChronoTomato", metadata.ChronoTomatoVersion)
os.Exit(0)
}

View file

@ -6,16 +6,12 @@ import (
"strings"
)
var ChronoTomatoVersion = "" // The GoTomato version
func stripVersionPrefix(version string) string {
return strings.TrimLeft(version, "v")
}
var ChronoTomatoVersion = ""
func getLatestTag() string {
bytes, _ := exec.Command("git", "describe", "--tags").Output()
output := strings.TrimSpace(string(bytes))
return stripVersionPrefix(output)
return output
}
// set GoTomatoVersion from runtime/debug.Main.Version
@ -25,7 +21,7 @@ func init() {
if ChronoTomatoVersion == "" {
info, _ := debug.ReadBuildInfo()
if info.Main.Version != "(devel)" {
ChronoTomatoVersion = stripVersionPrefix(info.Main.Version)
ChronoTomatoVersion = info.Main.Version
} else {
ChronoTomatoVersion = getLatestTag()
}