Compare commits
3 commits
7c2604c0bf
...
f8e8bb04a0
Author | SHA1 | Date | |
---|---|---|---|
f8e8bb04a0 | |||
10021eb65e | |||
09dbf35a6a |
4 changed files with 75 additions and 1 deletions
|
@ -1,10 +1,10 @@
|
|||
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
|
||||
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
|
||||
|
||||
version: 2
|
||||
|
||||
before:
|
||||
hooks:
|
||||
- rm -fr ./dist
|
||||
- go mod tidy
|
||||
|
||||
builds:
|
||||
|
@ -15,6 +15,8 @@ builds:
|
|||
- arm64
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
ldflags:
|
||||
- -s -w -X {{.ModulePath}}/internal/metadata.ChronoTomatoVersion={{.Version}}
|
||||
|
||||
upx:
|
||||
- enabled: true
|
||||
|
|
34
Taskfile.yml
Normal file
34
Taskfile.yml
Normal file
|
@ -0,0 +1,34 @@
|
|||
# yaml-language-server: $schema=https://taskfile.dev/schema.json
|
||||
#
|
||||
# github.com/go-task/task/v3/cmd/task@latest
|
||||
# Requirements:
|
||||
# github.com/caarlos0/svu@latest
|
||||
# github.com/goreleaser/goreleaser/v2@latest
|
||||
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
|
||||
release:
|
||||
desc: Create and publish an new release
|
||||
vars:
|
||||
RELEASE:
|
||||
sh: svu next
|
||||
BRANCH:
|
||||
sh: git branch --show-current
|
||||
COMMIT:
|
||||
sh: git rev-parse --short --verify {{.BRANCH}}
|
||||
preconditions:
|
||||
- sh: test "{{.BRANCH}}" == "main"
|
||||
msg: "You must be on the main branch to release"
|
||||
prompt: Create new release {{.RELEASE}} from {{.COMMIT}}@{{.BRANCH}}?
|
||||
cmds:
|
||||
- git tag {{.RELEASE}}
|
||||
- git push
|
||||
- git push origin tag {{.RELEASE}}
|
||||
- goreleaser release --clean
|
||||
|
||||
snapshot:
|
||||
desc: Create a local snapshot release
|
||||
cmds:
|
||||
- goreleaser release --clean --snapshot
|
|
@ -2,8 +2,11 @@ package client
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.smsvc.net/pomodoro/ChronoTomato/internal/helper"
|
||||
"git.smsvc.net/pomodoro/ChronoTomato/internal/metadata"
|
||||
"git.smsvc.net/pomodoro/ChronoTomato/internal/websocket"
|
||||
ChronoTomato "git.smsvc.net/pomodoro/ChronoTomato/pkg/models"
|
||||
GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||
|
@ -68,9 +71,15 @@ func Start() {
|
|||
parameter_url = flag.String("url", "", "GoTomato Server URL (eg ws://localhost:8080/ws)")
|
||||
parameter_password = flag.String("password", "", "Control password for pomodoro session")
|
||||
parameter_configfile = flag.String("config", defaultConfigFile, "Path to config file")
|
||||
showVersion = flag.Bool("version", false, "Show Version")
|
||||
)
|
||||
flag.Parse()
|
||||
|
||||
if *showVersion {
|
||||
fmt.Println("ChronoTomato", metadata.ChronoTomatoVersion)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// read passed config file or try to use default config
|
||||
if *parameter_configfile != defaultConfigFile {
|
||||
config = helper.ParseConfig(*parameter_configfile)
|
||||
|
|
29
internal/metadata/version.go
Normal file
29
internal/metadata/version.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package metadata
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var ChronoTomatoVersion = ""
|
||||
|
||||
func getLatestTag() string {
|
||||
bytes, _ := exec.Command("git", "describe", "--tags").Output()
|
||||
output := strings.TrimSpace(string(bytes))
|
||||
return output
|
||||
}
|
||||
|
||||
// set GoTomatoVersion from runtime/debug.Main.Version
|
||||
// use latest git tag as fallback
|
||||
// can be overwritten via ldflags (e,g. by goreleaser)
|
||||
func init() {
|
||||
if ChronoTomatoVersion == "" {
|
||||
info, _ := debug.ReadBuildInfo()
|
||||
if info.Main.Version != "(devel)" {
|
||||
ChronoTomatoVersion = info.Main.Version
|
||||
} else {
|
||||
ChronoTomatoVersion = getLatestTag()
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue