Compare commits

...

15 commits

Author SHA1 Message Date
92332fe159 feat(goreleaser): update build command to use ModulePath variable
- change hardcoded module path to dynamic reference

🤖
2024-11-09 22:37:52 +01:00
6708c43cea chore: add yaml schemas to Taskfile.yml and .goreleaser.yaml 2024-11-09 21:55:14 +01:00
9d0ad207d0 fix(goreleaser): don't force-remove ./dist 2024-11-09 21:55:14 +01:00
ffe33454b4 move varibles to relevant task 2024-11-09 21:55:14 +01:00
053e6e76de merge tasks 2024-11-09 21:46:40 +01:00
ca345e348d add requirements to Taskfile.yml 2024-11-09 21:46:40 +01:00
f26c603b19 XXX remove release:file task 2024-11-09 21:46:40 +01:00
3d8591cad6 use plain svu version (don't strip prefix) 2024-11-09 20:24:48 +01:00
5caf2f7d50 add snapshot task 2024-11-09 20:24:48 +01:00
2421a40271 only run dorelase in main branch 2024-11-09 20:24:48 +01:00
79a0905362 split tasks into indiviual units
create standalone `goreleaser` task
create standalone `dorelease` task
2024-11-09 20:24:48 +01:00
7619e35d04 add warning prompt 2024-11-09 20:24:48 +01:00
1e06a1f228 feat: add release management via taskdev
- create `Taskfile.yml`
- update version file with the new release version
- add new version tag
- push to remote and run goreleaser
2024-11-09 20:24:48 +01:00
4ed7a8f887 feat: update -version output 2024-11-09 20:24:48 +01:00
b22bc35bbd feat: retrieve version from runtime/debug.Main.Version or latest git tag
- set version from runtime/debug.Main.Version
- use latest git tag as fallback
- allow GoTomatoVersion to be overwritten via ldflags
2024-11-09 20:24:48 +01:00
4 changed files with 71 additions and 8 deletions

View file

@ -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:
@ -16,7 +16,7 @@ builds:
env: env:
- CGO_ENABLED=0 - CGO_ENABLED=0
ldflags: ldflags:
- -s -w -X git.smsvc.net/pomodoro/GoTomato/internal/metadata.GoTomatoVersion={{.Version}} - -s -w -X {{.ModulePath}}/internal/metadata.GoTomatoVersion={{.Version}}
upx: upx:
- enabled: true - enabled: true

33
Taskfile.yml Normal file
View file

@ -0,0 +1,33 @@
# yaml-language-server: $schema=https://taskfile.dev/schema.json
#
# 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

View file

@ -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)
} }

View file

@ -1,7 +1,37 @@
package metadata package metadata
import "strings" import (
"os/exec"
"runtime/debug"
"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 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 version from runtime/debug.Main.Version
// use latest git tag as fallback
// allow GoTomatoVersion to be overwritten via ldflags
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]
}