Skip to content

Commit af9b8d3

Browse files
committed
Load version automatically
1 parent 54fea9d commit af9b8d3

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ NAME = rymdport
55
PREFIX ?= /usr
66

77
release:
8-
go build -tags no_emoji,no_metadata,migrated_fynedo -trimpath -ldflags="-s -w" -buildvcs=false -o $(NAME)
8+
go build -tags no_emoji,no_metadata,migrated_fynedo -trimpath -ldflags="-s -w" -o $(NAME)
99
.PHONY: release
1010

1111
debug:

internal/ui/about.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ui
22

33
import (
44
"net/url"
5+
"runtime/debug"
56

67
"fyne.io/fyne/v2"
78
"fyne.io/fyne/v2/container"
@@ -13,16 +14,20 @@ import (
1314
)
1415

1516
func newAboutTab(app fyne.App) *container.TabItem {
16-
const version = "v3.9.2"
17-
1817
repoURL := util.URLToGitHubProject("")
1918
icon := newClickableIcon(app.Icon(), repoURL, app)
2019

2120
nameLabel := newBoldLabel("Rymdport")
2221
spacerLabel := newBoldLabel("-")
2322

24-
releaseURL := util.URLToGitHubProject("/releases/tag/" + version)
25-
hyperlink := &widget.Hyperlink{Text: version, URL: releaseURL, TextStyle: fyne.TextStyle{Bold: true}}
23+
var hyperlink fyne.CanvasObject
24+
version := getVersion(app)
25+
if version[0] == 'v' {
26+
releaseURL := util.URLToGitHubProject("/releases/tag/" + version)
27+
hyperlink = &widget.Hyperlink{Text: version, URL: releaseURL, TextStyle: fyne.TextStyle{Bold: true}}
28+
} else {
29+
hyperlink = &widget.Label{Text: version, TextStyle: fyne.TextStyle{Bold: true}}
30+
}
2631

2732
spacer := &layout.Spacer{}
2833
content := container.NewVBox(
@@ -69,3 +74,11 @@ func (c *clickableIcon) MinSize() fyne.Size {
6974
func newClickableIcon(res fyne.Resource, url *url.URL, app fyne.App) *clickableIcon {
7075
return &clickableIcon{Icon: widget.Icon{Resource: res}, app: app, url: url}
7176
}
77+
78+
func getVersion(app fyne.App) string {
79+
info, ok := debug.ReadBuildInfo()
80+
if !ok {
81+
return app.Metadata().Version
82+
}
83+
return info.Main.Version
84+
}

0 commit comments

Comments
 (0)