Compare commits
9 commits
6a3919e95e
...
4687dc966b
Author | SHA1 | Date | |
---|---|---|---|
4687dc966b | |||
7ddc620030 | |||
499840a864 | |||
89650118fd | |||
05a8701a26 | |||
2032688c1f | |||
9852f80461 | |||
467d90065c | |||
93f39507c1 |
4 changed files with 75 additions and 8 deletions
|
@ -1,10 +1,10 @@
|
||||||
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
|
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
|
||||||
|
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
|
||||||
|
|
||||||
version: 2
|
version: 2
|
||||||
|
|
||||||
before:
|
before:
|
||||||
hooks:
|
hooks:
|
||||||
- rm -fr ./dist
|
|
||||||
- go mod tidy
|
- go mod tidy
|
||||||
|
|
||||||
builds:
|
builds:
|
||||||
|
@ -15,6 +15,8 @@ builds:
|
||||||
- arm64
|
- arm64
|
||||||
env:
|
env:
|
||||||
- CGO_ENABLED=0
|
- CGO_ENABLED=0
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X {{.ModulePath}}/internal/metadata.GoTomatoVersion={{.Version}}
|
||||||
|
|
||||||
upx:
|
upx:
|
||||||
- enabled: true
|
- enabled: true
|
||||||
|
@ -22,10 +24,10 @@ upx:
|
||||||
lzma: true
|
lzma: true
|
||||||
|
|
||||||
changelog:
|
changelog:
|
||||||
sort: desc
|
use: gitea
|
||||||
filters:
|
filters:
|
||||||
exclude:
|
exclude:
|
||||||
- "bump version to"
|
- "chore: bump version to"
|
||||||
|
|
||||||
archives:
|
archives:
|
||||||
- format: binary
|
- format: binary
|
||||||
|
|
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
|
|
@ -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.Printf("Server-Version: v%s\n", metadata.GoTomatoVersion)
|
fmt.Printf("GoTomato v%s\n", metadata.GoTomatoVersion)
|
||||||
fmt.Printf("Protocol-Version: v%s\n", metadata.ProtocolVersion)
|
fmt.Printf("Protocol-Version: %s\n", metadata.ProtocolVersion)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,37 @@
|
||||||
package metadata
|
package metadata
|
||||||
|
|
||||||
import "strings"
|
import (
|
||||||
|
"os/exec"
|
||||||
|
"runtime/debug"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
const GoTomatoVersion = "0.1.1" // The GoTomato version
|
var (
|
||||||
var ProtocolVersion = strings.Split(GoTomatoVersion, ".")[0] // The protocol version
|
GoTomatoVersion = "" // The GoTomato version
|
||||||
|
ProtocolVersion = "" // The protocol version
|
||||||
|
)
|
||||||
|
|
||||||
|
func stripVersionPrefix(version string) string {
|
||||||
|
return strings.TrimLeft(version, "v")
|
||||||
|
}
|
||||||
|
|
||||||
|
func getLatestTag() string {
|
||||||
|
bytes, _ := exec.Command("git", "describe", "--tags").Output()
|
||||||
|
output := strings.TrimSpace(string(bytes))
|
||||||
|
return stripVersionPrefix(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 GoTomatoVersion == "" {
|
||||||
|
info, _ := debug.ReadBuildInfo()
|
||||||
|
if info.Main.Version != "(devel)" {
|
||||||
|
GoTomatoVersion = stripVersionPrefix(info.Main.Version)
|
||||||
|
} else {
|
||||||
|
GoTomatoVersion = getLatestTag()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ProtocolVersion = strings.Split(GoTomatoVersion, ".")[0]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue