diff --git a/cmd/soundtouch-service/main.go b/cmd/soundtouch-service/main.go
index 65d22b32..2a536473 100644
--- a/cmd/soundtouch-service/main.go
+++ b/cmd/soundtouch-service/main.go
@@ -34,10 +34,15 @@ var (
version = "dev"
commit = "unknown"
date = "unknown"
+ repoURL = "https://github.com/gesellix/bose-soundtouch"
)
func updateBuildInfo() {
if info, ok := debug.ReadBuildInfo(); ok {
+ if info.Main.Path != "" {
+ repoURL = "https://" + info.Main.Path
+ }
+
if info.Main.Version != "" && info.Main.Version != "(devel)" {
version = info.Main.Version
}
@@ -48,7 +53,7 @@ func updateBuildInfo() {
commit = setting.Value
case "vcs.time":
if t, err := time.Parse(time.RFC3339, setting.Value); err == nil {
- date = t.Format("2006-01-02_15:04:05")
+ date = t.Format("2006-01-02 15:04:05")
}
}
}
@@ -300,7 +305,7 @@ func main() {
server := handlers.NewServer(ds, sm, config.serverURL, config.redact, config.logBody, config.record)
sm.GetDNSRunning = server.GetDNSRunning
server.SetHTTPServerURL(config.httpsServerURL)
- server.SetVersionInfo(version, commit, date)
+ server.SetVersionInfo(version, commit, date, repoURL)
server.SetDiscoverySettings(config.discoveryInterval, persisted.DiscoveryEnabled)
server.SetDNSSettings(persisted.DNSEnabled, strings.Join(persisted.DNSUpstream, ","), persisted.DNSBindAddr)
server.SetMirrorSettings(persisted.MirrorEnabled, persisted.MirrorEndpoints, persisted.SkipMirrorEndpoints, persisted.PreferredSource)
diff --git a/pkg/service/handlers/handlers_setup.go b/pkg/service/handlers/handlers_setup.go
index f6379136..7bf6b9f7 100644
--- a/pkg/service/handlers/handlers_setup.go
+++ b/pkg/service/handlers/handlers_setup.go
@@ -1084,14 +1084,36 @@ func (s *Server) HandleTestConnection(w http.ResponseWriter, r *http.Request) {
// HandleGetVersionInfo returns version information for the service.
func (s *Server) HandleGetVersionInfo(w http.ResponseWriter, _ *http.Request) {
s.mu.RLock()
- defer s.mu.RUnlock()
+ version := s.Version
+ commit := s.Commit
+ date := s.Date
+ repoURL := s.RepoURL
+ s.mu.RUnlock()
w.Header().Set("Content-Type", "application/json")
+ var (
+ releaseURL string
+ commitURL string
+ )
+
+ if commit != "" && commit != "unknown" {
+ commitURL = fmt.Sprintf("%s/commit/%s", repoURL, commit)
+ }
+
+ // Release version: should point to the release, e.g. https://github.com/gesellix/Bose-SoundTouch/releases/tag/v0.58.0
+ // "dirty" versions don't get a release link (only the commit).
+ if version != "" && version != "dev" && version != "(devel)" && !strings.Contains(version, "dirty") {
+ releaseURL = fmt.Sprintf("%s/releases/tag/%s", repoURL, version)
+ }
+
if err := json.NewEncoder(w).Encode(map[string]string{
- "version": s.Version,
- "commit": s.Commit,
- "date": s.Date,
+ "version": version,
+ "commit": commit,
+ "date": date,
+ "repo_url": repoURL,
+ "release_url": releaseURL,
+ "commit_url": commitURL,
}); err != nil {
http.Error(w, "Failed to encode response", http.StatusInternalServerError)
return
diff --git a/pkg/service/handlers/server.go b/pkg/service/handlers/server.go
index d7058b3c..5fcf6a7d 100644
--- a/pkg/service/handlers/server.go
+++ b/pkg/service/handlers/server.go
@@ -50,6 +50,7 @@ type Server struct {
Version string
Commit string
Date string
+ RepoURL string
mgmtUsername string
mgmtPassword string
spotifyClientID string
@@ -96,13 +97,14 @@ func NewServer(ds *datastore.DataStore, sm *setup.Manager, serverURL string, pro
}
// SetVersionInfo sets the version information for the server.
-func (s *Server) SetVersionInfo(version, commit, date string) {
+func (s *Server) SetVersionInfo(version, commit, date, repoURL string) {
s.mu.Lock()
defer s.mu.Unlock()
s.Version = version
s.Commit = commit
s.Date = date
+ s.RepoURL = repoURL
}
// SetDiscoverySettings sets the discovery settings for the server.
diff --git a/pkg/service/handlers/web/js/script.js b/pkg/service/handlers/web/js/script.js
index 4279849d..4dd84bd9 100644
--- a/pkg/service/handlers/web/js/script.js
+++ b/pkg/service/handlers/web/js/script.js
@@ -464,7 +464,16 @@ async function fetchVersion() {
const data = await response.json();
const info = document.getElementById("version-info");
if (info && data.version) {
- info.innerText = `AfterTouch ${data.version} (${data.commit}) - ${data.date}`;
+ let versionStr = data.version;
+ if (data.release_url) {
+ versionStr = `${data.version}`;
+ }
+ let commitStr = data.commit;
+ if (data.commit_url) {
+ const shortCommit = data.commit.substring(0, 7);
+ commitStr = `${shortCommit}`;
+ }
+ info.innerHTML = `AfterTouch ${versionStr} (${commitStr}) - ${data.date}`;
}
} catch (error) {
console.error("Failed to fetch version info", error);