Compare commits

..

5 commits

Author SHA1 Message Date
36dca57830 feat: add release management via taskdev
- create `Taskfile.yml`
- initial tasks
  - add new version tag
  - push to remote and run goreleaser
  - create snapshot via goreleaser
2024-11-10 09:35:02 +01:00
10021eb65e feat(goreleaser): set version on build via ldflags 2024-11-10 09:35:02 +01:00
09dbf35a6a feat!: introduce ChronoTomatoVersion
- set version from `runtime/debug.Main.Version`
- use latest git tag as fallback
- allow version to be overwritten via ldflags
- this will break `go build .` and `go install .`
2024-11-10 09:35:02 +01:00
58d658be66 feat(goreleaser): add initial configuration for GoReleaser
- add `.goreleaser.yaml` for release automation
- add `dist` to gitignore
2024-11-10 09:35:02 +01:00
05e8bf5854 feat: reconnect on disconnect (add status to TUI)
- add `Connected()` method for client
- add `LastErr` field to GoTomatoClient
  - replace error logging by updating `LastErr` field
  - modify methods to use pointer receivers for Client
- add `prevMessage` variable to store the last received server message
- show connect status in TUI
- use EnterAltScreen instead of ClearScreen
2024-11-10 09:34:55 +01:00
6 changed files with 81 additions and 18 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/ChronoTomato/cmd/client.version={{.Version}} - -s -w -X {{.ModulePath}}/internal/metadata.ChronoTomatoVersion={{.Version}}
upx: upx:
- enabled: true - enabled: true

34
Taskfile.yml Normal file
View 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

View file

@ -6,6 +6,7 @@ import (
"os" "os"
"git.smsvc.net/pomodoro/ChronoTomato/internal/helper" "git.smsvc.net/pomodoro/ChronoTomato/internal/helper"
"git.smsvc.net/pomodoro/ChronoTomato/internal/metadata"
"git.smsvc.net/pomodoro/ChronoTomato/internal/websocket" "git.smsvc.net/pomodoro/ChronoTomato/internal/websocket"
ChronoTomato "git.smsvc.net/pomodoro/ChronoTomato/pkg/models" ChronoTomato "git.smsvc.net/pomodoro/ChronoTomato/pkg/models"
GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models" GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models"
@ -15,9 +16,8 @@ import (
) )
var ( var (
version = "devel" config ChronoTomato.Config
config ChronoTomato.Config client websocket.Client
client websocket.Client
) )
type app struct { type app struct {
@ -76,7 +76,7 @@ func Start() {
flag.Parse() flag.Parse()
if *showVersion { if *showVersion {
fmt.Println("ChronoTomato", version) fmt.Println("ChronoTomato", metadata.ChronoTomatoVersion)
os.Exit(0) os.Exit(0)
} }

8
go.mod
View file

@ -3,10 +3,10 @@ module git.smsvc.net/pomodoro/ChronoTomato
go 1.23.1 go 1.23.1
require ( require (
git.smsvc.net/pomodoro/GoTomato v0.2.0 git.smsvc.net/pomodoro/GoTomato v0.0.8
github.com/alecthomas/colour v0.1.0 github.com/alecthomas/colour v0.1.0
github.com/charmbracelet/bubbles v0.20.0 github.com/charmbracelet/bubbles v0.20.0
github.com/charmbracelet/bubbletea v1.2.1 github.com/charmbracelet/bubbletea v1.1.2
github.com/charmbracelet/log v0.4.0 github.com/charmbracelet/log v0.4.0
github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4
github.com/gorilla/websocket v1.5.3 github.com/gorilla/websocket v1.5.3
@ -15,8 +15,8 @@ require (
require ( require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/lipgloss v1.0.0 // indirect github.com/charmbracelet/lipgloss v0.13.0 // indirect
github.com/charmbracelet/x/ansi v0.4.5 // indirect github.com/charmbracelet/x/ansi v0.4.0 // indirect
github.com/charmbracelet/x/term v0.2.0 // indirect github.com/charmbracelet/x/term v0.2.0 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect

16
go.sum
View file

@ -1,19 +1,19 @@
git.smsvc.net/pomodoro/GoTomato v0.2.0 h1:/Wkft5ESsKNJIKiu6OJ7sKvY8LhW6acpTcMy89DLd0s= git.smsvc.net/pomodoro/GoTomato v0.0.8 h1:ePD6T14pFtrtXybHypabpDs4MURdOnPkm8nQzzEteVA=
git.smsvc.net/pomodoro/GoTomato v0.2.0/go.mod h1:LaKrPdnFB5v4RpltExKasW67TmjJlmhDDvmoEYWv0P4= git.smsvc.net/pomodoro/GoTomato v0.0.8/go.mod h1:LaKrPdnFB5v4RpltExKasW67TmjJlmhDDvmoEYWv0P4=
github.com/alecthomas/colour v0.1.0 h1:nOE9rJm6dsZ66RGWYSFrXw461ZIt9A6+nHgL7FRrDUk= github.com/alecthomas/colour v0.1.0 h1:nOE9rJm6dsZ66RGWYSFrXw461ZIt9A6+nHgL7FRrDUk=
github.com/alecthomas/colour v0.1.0/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0= github.com/alecthomas/colour v0.1.0/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE= github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE=
github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU= github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU=
github.com/charmbracelet/bubbletea v1.2.1 h1:J041h57zculJKEKf/O2pS4edXGIz+V0YvojvfGXePIk= github.com/charmbracelet/bubbletea v1.1.2 h1:naQXF2laRxyLyil/i7fxdpiz1/k06IKquhm4vBfHsIc=
github.com/charmbracelet/bubbletea v1.2.1/go.mod h1:viLoDL7hG4njLJSKU2gw7kB3LSEmWsrM80rO1dBJWBI= github.com/charmbracelet/bubbletea v1.1.2/go.mod h1:9HIU/hBV24qKjlehyj8z1r/tR9TYTQEag+cWZnuXo8E=
github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg= github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw=
github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo= github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY=
github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM= github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM=
github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM=
github.com/charmbracelet/x/ansi v0.4.5 h1:LqK4vwBNaXw2AyGIICa5/29Sbdq58GbGdFngSexTdRM= github.com/charmbracelet/x/ansi v0.4.0 h1:NqwHA4B23VwsDn4H3VcNX1W1tOmgnvY1NDx5tOXdnOU=
github.com/charmbracelet/x/ansi v0.4.5/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/charmbracelet/x/ansi v0.4.0/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw=
github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0= github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0=
github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0= github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=

View 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()
}
}
}