feat: set version from git tag on build
- add version variable and default it to "devel" - add ldflags to `.goreleaser.yaml` for version tagging
This commit is contained in:
parent
f058f6c6d3
commit
9247df0891
2 changed files with 13 additions and 2 deletions
|
@ -15,6 +15,8 @@ builds:
|
||||||
- arm64
|
- arm64
|
||||||
env:
|
env:
|
||||||
- CGO_ENABLED=0
|
- CGO_ENABLED=0
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X git.smsvc.net/pomodoro/ChronoTomato/cmd/client.version={{.Version}}
|
||||||
|
|
||||||
upx:
|
upx:
|
||||||
- enabled: true
|
- enabled: true
|
||||||
|
|
|
@ -2,6 +2,8 @@ package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"git.smsvc.net/pomodoro/ChronoTomato/internal/helper"
|
"git.smsvc.net/pomodoro/ChronoTomato/internal/helper"
|
||||||
"git.smsvc.net/pomodoro/ChronoTomato/internal/websocket"
|
"git.smsvc.net/pomodoro/ChronoTomato/internal/websocket"
|
||||||
|
@ -13,8 +15,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
config ChronoTomato.Config
|
version = "devel"
|
||||||
client websocket.Client
|
config ChronoTomato.Config
|
||||||
|
client websocket.Client
|
||||||
)
|
)
|
||||||
|
|
||||||
type app struct {
|
type app struct {
|
||||||
|
@ -68,9 +71,15 @@ func Start() {
|
||||||
parameter_url = flag.String("url", "", "GoTomato Server URL (eg ws://localhost:8080/ws)")
|
parameter_url = flag.String("url", "", "GoTomato Server URL (eg ws://localhost:8080/ws)")
|
||||||
parameter_password = flag.String("password", "", "Control password for pomodoro session")
|
parameter_password = flag.String("password", "", "Control password for pomodoro session")
|
||||||
parameter_configfile = flag.String("config", defaultConfigFile, "Path to config file")
|
parameter_configfile = flag.String("config", defaultConfigFile, "Path to config file")
|
||||||
|
showVersion = flag.Bool("version", false, "Show Version")
|
||||||
)
|
)
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if *showVersion {
|
||||||
|
fmt.Println("ChronoTomato", version)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
// read passed config file or try to use default config
|
// read passed config file or try to use default config
|
||||||
if *parameter_configfile != defaultConfigFile {
|
if *parameter_configfile != defaultConfigFile {
|
||||||
config = helper.ParseConfig(*parameter_configfile)
|
config = helper.ParseConfig(*parameter_configfile)
|
||||||
|
|
Loading…
Reference in a new issue