Compare commits
2 commits
5e269a6209
...
4d21e3c789
Author | SHA1 | Date | |
---|---|---|---|
4d21e3c789 | |||
8c88ec0b50 |
3 changed files with 19 additions and 8 deletions
|
@ -15,8 +15,6 @@ builds:
|
||||||
- arm64
|
- arm64
|
||||||
env:
|
env:
|
||||||
- CGO_ENABLED=0
|
- CGO_ENABLED=0
|
||||||
ldflags:
|
|
||||||
- -s -w -X git.smsvc.net/pomodoro/GoTomato/internal/metadata.GoTomatoVersion={{.Version}}
|
|
||||||
|
|
||||||
upx:
|
upx:
|
||||||
- enabled: true
|
- enabled: true
|
||||||
|
|
|
@ -28,8 +28,8 @@ func Start() {
|
||||||
|
|
||||||
// show server and protocl version and exit
|
// show server and protocl version and exit
|
||||||
if *showVersionFlag {
|
if *showVersionFlag {
|
||||||
fmt.Println("Server-Version:", metadata.GoTomatoVersion)
|
fmt.Printf("GoTomato v%s\n", metadata.GoTomatoVersion)
|
||||||
fmt.Println("Protocol-Version:", metadata.ProtocolVersion)
|
fmt.Printf("Protocol-Version: %s\n", metadata.ProtocolVersion)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,20 @@
|
||||||
package metadata
|
package metadata
|
||||||
|
|
||||||
import "strings"
|
import (
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
// This will be overwritten by goreleaser on build
|
var (
|
||||||
var GoTomatoVersion = "devel" // The GoTomato version
|
GoTomatoVersion = "" // The GoTomato version
|
||||||
var ProtocolVersion = strings.Split(GoTomatoVersion, ".")[0] // The protocol version
|
ProtocolVersion = "" // The protocol version
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
if GoTomatoVersion == "" {
|
||||||
|
output, _ := exec.Command("git", "describe", "--tags").Output()
|
||||||
|
trimmed_output := strings.TrimSpace(string(output)) // strip newlines
|
||||||
|
GoTomatoVersion = strings.Replace(trimmed_output, "v", "", 1) // strip leading "v"
|
||||||
|
}
|
||||||
|
ProtocolVersion = strings.Split(GoTomatoVersion, ".")[0] // The protocol version
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue