diff --git a/.gitea/workflows/pull-request-ci.yaml b/.gitea/workflows/pull-request-ci.yaml index 557094a..60e9651 100644 --- a/.gitea/workflows/pull-request-ci.yaml +++ b/.gitea/workflows/pull-request-ci.yaml @@ -95,7 +95,7 @@ jobs: - name: Build for linux run: | - fyne build --os=${GOOS} --metadata Build=${BUILD} -o bin/swiped-mod-switcher-${VERSION#v}.${BUILD}-${GOOS}-${GOARCH} + fyne build --os=${GOOS} --metadata BuildVersion=${VERSION} --metadata BuildNumber=${BUILD} -o bin/swiped-mod-switcher-${VERSION}.${BUILD}-${GOOS}-${GOARCH} env: VERSION: ${{github.ref_name}} BUILD: ${{github.run_number}} @@ -107,7 +107,7 @@ jobs: - name: Build for windows run: | - fyne build --os=${GOOS} --metadata Build=${BUILD} -o bin/swiped-mod-switcher-${VERSION#v}.${BUILD}-${GOOS}-${GOARCH}.exe + fyne build --os=${GOOS} --metadata BuildVersion=${VERSION} --metadata BuildNumber=${BUILD} -o bin/swiped-mod-switcher-${VERSION}.${BUILD}-${GOOS}-${GOARCH}.exe env: VERSION: ${{github.ref_name}} BUILD: ${{github.run_number}} diff --git a/.gitea/workflows/push-ci.yaml b/.gitea/workflows/push-ci.yaml index 8187c99..6ef8b0c 100644 --- a/.gitea/workflows/push-ci.yaml +++ b/.gitea/workflows/push-ci.yaml @@ -91,7 +91,7 @@ jobs: - name: Build for linux run: | - fyne build --os=${GOOS} --metadata Build=${BUILD} -o bin/swiped-mod-switcher-${VERSION#v}.${BUILD}-${GOOS}-${GOARCH} + fyne build --os=${GOOS} --metadata BuildVersion=${VERSION} --metadata BuildNumber=${BUILD} -o bin/swiped-mod-switcher-${VERSION}.${BUILD}-${GOOS}-${GOARCH} ls bin env: VERSION: ${{github.ref_name}} @@ -103,7 +103,7 @@ jobs: - name: Build for windows run: | - fyne build --os=${GOOS} --metadata Build=${BUILD} -o bin/swiped-mod-switcher-${VERSION#v}.${BUILD}-${GOOS}-${GOARCH}.exe + fyne build --os=${GOOS} --metadata BuildVersion=${VERSION} --metadata BuildNumber=${BUILD} -o bin/swiped-mod-switcher-${VERSION}.${BUILD}-${GOOS}-${GOARCH}.exe ls bin env: VERSION: ${{github.ref_name}} diff --git a/.gitea/workflows/tag-release.yaml b/.gitea/workflows/tag-release.yaml index bdffbe6..5fa4b7a 100644 --- a/.gitea/workflows/tag-release.yaml +++ b/.gitea/workflows/tag-release.yaml @@ -87,7 +87,7 @@ jobs: - name: Build for linux run: | - fyne build --os=${GOOS} --metadata Build=${BUILD} -o bin/swiped-mod-switcher-${VERSION#v}.${BUILD}-${GOOS}-${GOARCH} + fyne build --os=${GOOS} --metadata BuildVersion=${VERSION} --metadata BuildNumber=${BUILD} -o bin/swiped-mod-switcher-${VERSION#v}.${BUILD}-${GOOS}-${GOARCH} env: VERSION: ${{github.ref_name}} BUILD: ${{github.run_number}} @@ -99,7 +99,7 @@ jobs: - name: Build for windows run: | - fyne build --os=${GOOS} --metadata Build=${BUILD} -o bin/swiped-mod-switcher-${VERSION#v}.${BUILD}-${GOOS}-${GOARCH}.exe + fyne build --os=${GOOS} --metadata BuildVersion=${VERSION} --metadata BuildNumber=${BUILD} -o bin/swiped-mod-switcher-${VERSION#v}.${BUILD}-${GOOS}-${GOARCH}.exe env: VERSION: ${{github.ref_name}} BUILD: ${{github.run_number}} diff --git a/main.go b/main.go index 4c9b2f3..135c6bd 100644 --- a/main.go +++ b/main.go @@ -4,9 +4,9 @@ import ( "fmt" "os" "path/filepath" + "runtime/debug" "s1d3sw1ped/swipedmodswitcher/admin" "slices" - "strconv" "strings" "fyne.io/fyne/v2" @@ -72,7 +72,31 @@ func main() { cfg = loadConfig() ap := app.New() - wp := ap.NewWindow(ap.Metadata().Name + " v" + ap.Metadata().Version + "." + strconv.Itoa(ap.Metadata().Build)) + + commithash := func() string { + if info, ok := debug.ReadBuildInfo(); ok { + for _, setting := range info.Settings { + if setting.Key == "vcs.revision" { + return setting.Value + } + } + } + return "" + }() + + buildversion := ap.Metadata().Custom["BuildVersion"] + if buildversion == "" { + buildversion = "" + } + + buildnumber := ap.Metadata().Custom["BuildNumber"] + if buildnumber == "" { + buildnumber = "commit " + commithash + } else { + buildnumber = "build " + buildnumber + } + + wp := ap.NewWindow(ap.Metadata().Name + " " + buildversion + " " + buildnumber) wp.Resize(fyne.NewSize(600, 1)) wp.CenterOnScreen()