Quellcode durchsuchen

Show the version number in About, with the commit separately

About showed the commit id because no tag exists yet. Stamp the version
from APP_VERSION in the Taskfile and the commit on its own Build line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude vor 1 Tag
Ursprung
Commit
94ff09cd3c

+ 1 - 1
README.md

@@ -40,7 +40,7 @@ wails3 build       # builds bin/mpckit (bin\mpckit.exe on Windows)
 
 The first run installs the frontend packages and generates `frontend/bindings` from the Go service.
 
-`wails3 build` stamps the version from the latest git tag (`git describe`), so a build of the `v0.5.0` tag shows "Version v0.5.0" in About. Builds of other commits show the tag plus the commit, and `wails3 dev` shows "dev".
+`wails3 build` stamps the version (`APP_VERSION` in `Taskfile.yml`, kept in step with `version` in `build/config.yml`) and the commit it was built from, so About shows "Version 0.5.0" and "Build 2354f57" ("-dirty" if there were uncommitted changes). `wails3 dev` shows "dev".
 
 The app icon is drawn by `go run ./tools/icon build/appicon.png`. The Windows and macOS icon files are generated from that PNG during the build.
 

+ 6 - 4
Taskfile.yml

@@ -2,10 +2,12 @@ version: '3'
 
 vars:
   APP_NAME: "mpckit"
-  # Shown in the About dialog of production builds: the git tag (v0.5.0) on
-  # a tagged commit, otherwise the tag plus commits since and the commit id.
-  VERSION:
-    sh: git describe --tags --always --dirty 2>/dev/null || echo dev
+  # Shown in the About dialog of production builds: the version, and the
+  # commit it was built from ("-dirty" if there were uncommitted changes).
+  # Keep APP_VERSION in step with `version` in build/config.yml.
+  APP_VERSION: "0.5.0"
+  COMMIT:
+    sh: git describe --always --dirty --exclude "*" 2>/dev/null || echo unknown
   BIN_DIR: "bin"
   PACKAGE_MANAGER: '{{.PACKAGE_MANAGER | default "npm"}}'
   VITE_PORT: '{{.WAILS_VITE_PORT | default 9245}}'

+ 1 - 1
build/darwin/Taskfile.yml

@@ -47,7 +47,7 @@ tasks:
       - wails3 tool prepare-macos-output --dir "{{.BIN_DIR}}"
       - '{{if eq .OBFUSCATED "true"}}garble {{.GARBLE_ARGS}} build{{else}}go build{{end}} {{.BUILD_FLAGS}} -o "{{.OUTPUT}}"'
     vars:
-      BUILD_FLAGS: '{{if eq .DEV "true"}}{{if or .EXTRA_TAGS (eq .OBFUSCATED "true")}}-tags {{if eq .OBFUSCATED "true"}}wails_obfuscated{{if .EXTRA_TAGS}},{{end}}{{end}}{{.EXTRA_TAGS}} {{end}}-buildvcs=false -gcflags=all="-l"{{else}}-tags production{{if eq .OBFUSCATED "true"}},wails_obfuscated{{end}}{{if .EXTRA_TAGS}},{{.EXTRA_TAGS}}{{end}} -trimpath -buildvcs=false -ldflags="-w -s -X git.monoexp.com/bajdev/mpckit/internal/app.Version={{.VERSION}}"{{end}}'
+      BUILD_FLAGS: '{{if eq .DEV "true"}}{{if or .EXTRA_TAGS (eq .OBFUSCATED "true")}}-tags {{if eq .OBFUSCATED "true"}}wails_obfuscated{{if .EXTRA_TAGS}},{{end}}{{end}}{{.EXTRA_TAGS}} {{end}}-buildvcs=false -gcflags=all="-l"{{else}}-tags production{{if eq .OBFUSCATED "true"}},wails_obfuscated{{end}}{{if .EXTRA_TAGS}},{{.EXTRA_TAGS}}{{end}} -trimpath -buildvcs=false -ldflags="-w -s -X git.monoexp.com/bajdev/mpckit/internal/app.Version={{.APP_VERSION}} -X git.monoexp.com/bajdev/mpckit/internal/app.Commit={{.COMMIT}}"{{end}}'
       DEFAULT_OUTPUT: '{{.BIN_DIR}}/{{.APP_NAME}}'
       OUTPUT: '{{ .OUTPUT | default .DEFAULT_OUTPUT }}'
     env:

+ 1 - 1
build/linux/Taskfile.yml

@@ -59,7 +59,7 @@ tasks:
     cmds:
       - '{{if eq .OBFUSCATED "true"}}garble {{.GARBLE_ARGS}} build{{else}}go build{{end}} {{.BUILD_FLAGS}} -o {{.OUTPUT}}'
     vars:
-      BUILD_FLAGS: '{{if eq .DEV "true"}}{{if or .EXTRA_TAGS (eq .OBFUSCATED "true")}}-tags {{if eq .OBFUSCATED "true"}}wails_obfuscated{{if .EXTRA_TAGS}},{{end}}{{end}}{{.EXTRA_TAGS}} {{end}}-buildvcs=false -gcflags=all="-l"{{else}}-tags production{{if eq .OBFUSCATED "true"}},wails_obfuscated{{end}}{{if .EXTRA_TAGS}},{{.EXTRA_TAGS}}{{end}} -trimpath -buildvcs=false -ldflags="-w -s -X git.monoexp.com/bajdev/mpckit/internal/app.Version={{.VERSION}}"{{end}}'
+      BUILD_FLAGS: '{{if eq .DEV "true"}}{{if or .EXTRA_TAGS (eq .OBFUSCATED "true")}}-tags {{if eq .OBFUSCATED "true"}}wails_obfuscated{{if .EXTRA_TAGS}},{{end}}{{end}}{{.EXTRA_TAGS}} {{end}}-buildvcs=false -gcflags=all="-l"{{else}}-tags production{{if eq .OBFUSCATED "true"}},wails_obfuscated{{end}}{{if .EXTRA_TAGS}},{{.EXTRA_TAGS}}{{end}} -trimpath -buildvcs=false -ldflags="-w -s -X git.monoexp.com/bajdev/mpckit/internal/app.Version={{.APP_VERSION}} -X git.monoexp.com/bajdev/mpckit/internal/app.Commit={{.COMMIT}}"{{end}}'
       DEFAULT_OUTPUT: '{{.BIN_DIR}}/{{.APP_NAME}}'
       OUTPUT: '{{ .OUTPUT | default .DEFAULT_OUTPUT }}'
     env:

+ 1 - 1
build/windows/Taskfile.yml

@@ -57,7 +57,7 @@ tasks:
       - cmd: rm -f *.syso
         platforms: [linux, darwin]
     vars:
-      BUILD_FLAGS: '{{if eq .DEV "true"}}{{if or .EXTRA_TAGS (eq .OBFUSCATED "true")}}-tags {{if eq .OBFUSCATED "true"}}wails_obfuscated{{if .EXTRA_TAGS}},{{end}}{{end}}{{.EXTRA_TAGS}} {{end}}-buildvcs=false -gcflags=all="-l"{{else}}-tags production{{if eq .OBFUSCATED "true"}},wails_obfuscated{{end}}{{if .EXTRA_TAGS}},{{.EXTRA_TAGS}}{{end}} -trimpath -buildvcs=false -ldflags="-w -s -X git.monoexp.com/bajdev/mpckit/internal/app.Version={{.VERSION}} -H windowsgui"{{end}}'
+      BUILD_FLAGS: '{{if eq .DEV "true"}}{{if or .EXTRA_TAGS (eq .OBFUSCATED "true")}}-tags {{if eq .OBFUSCATED "true"}}wails_obfuscated{{if .EXTRA_TAGS}},{{end}}{{end}}{{.EXTRA_TAGS}} {{end}}-buildvcs=false -gcflags=all="-l"{{else}}-tags production{{if eq .OBFUSCATED "true"}},wails_obfuscated{{end}}{{if .EXTRA_TAGS}},{{.EXTRA_TAGS}}{{end}} -trimpath -buildvcs=false -ldflags="-w -s -X git.monoexp.com/bajdev/mpckit/internal/app.Version={{.APP_VERSION}} -X git.monoexp.com/bajdev/mpckit/internal/app.Commit={{.COMMIT}} -H windowsgui"{{end}}'
     env:
       GOOS: windows
       CGO_ENABLED: '{{.CGO_ENABLED | default "0"}}'

+ 5 - 0
frontend/bindings/git.monoexp.com/bajdev/mpckit/internal/app/models.ts

@@ -6,6 +6,11 @@
  */
 export interface About {
     "version": string;
+
+    /**
+     * empty in dev builds
+     */
+    "commit": string;
     "license": string;
     "repo": string;
 }

+ 1 - 0
frontend/src/lib/AboutModal.svelte

@@ -32,6 +32,7 @@
     <p class="lead">A desktop project and kit editor for the MPC Sample. Build kits on your computer, then export them to the device.</p>
     <div class="facts">
       <span>Version {about?.version ?? ""}</span>
+      {#if about?.commit}<span>Build {about.commit}</span>{/if}
       <span>{about?.license ?? ""}</span>
       {#if about}
         <a href={about.repo} onclick={open}>{about.repo.replace("https://", "")}</a>

+ 9 - 3
internal/app/app.go

@@ -17,9 +17,13 @@ import (
 	"git.monoexp.com/bajdev/mpckit/internal/project"
 )
 
-// Version is set at build time with
-// -ldflags "-X git.monoexp.com/bajdev/mpckit/internal/app.Version=v1.0.0".
-var Version = "dev"
+// Version and Commit are set by production builds (Taskfile.yml) with
+// -ldflags "-X git.monoexp.com/bajdev/mpckit/internal/app.Version=0.5.0
+// -X git.monoexp.com/bajdev/mpckit/internal/app.Commit=2354f57".
+var (
+	Version = "dev"
+	Commit  = ""
+)
 
 // DefaultName is the name of a new project.
 const DefaultName = "NewKit"
@@ -87,6 +91,7 @@ type State struct {
 // About is the text for the About dialog.
 type About struct {
 	Version string `json:"version"`
+	Commit  string `json:"commit"` // empty in dev builds
 	License string `json:"license"`
 	Repo    string `json:"repo"`
 }
@@ -184,6 +189,7 @@ func (s *Service) Version() string { return Version }
 func (s *Service) About() About {
 	return About{
 		Version: Version,
+		Commit:  Commit,
 		License: "MIT License, copyright (c) 2026 bajdev",
 		Repo:    "https://git.monoexp.com/bajdev/mpckit",
 	}

+ 8 - 5
pull-requests/m9-packaging/m9-icon-version-and-install-notes.md

@@ -10,26 +10,29 @@ M9 is "icons, version stamping, builds for the three systems, README with instal
   - `build/windows/icon.ico` and `build/darwin/icons.icns` are generated from it, as is the macOS disk-image file icon.
   - The disk-image background (it had the Wails logo) is now plain light grey (`go run ./tools/icon -dmg …`); Finder labels icons there in dark text.
   - Removed the template's macOS Icon Composer bundle (`build/appicon.icon`) and its compiled `build/darwin/Assets.car`. Both showed the Wails logo, and `Assets.car` takes precedence over `icons.icns` on current macOS. The bundle can only be compiled on macOS 26 with Xcode 26, so the icons task now uses `appicon.png` alone.
-- **Version stamping:** production builds (`wails3 build`, `wails3 package`) set the version shown in About from `git describe --tags --always --dirty`.
-  - A build of the `v0.5.0` tag shows `v0.5.0`. Other commits show the tag plus the commit, or just the commit id while there are no tags. `wails3 dev` still shows `dev`.
+- **Version stamping:** production builds (`wails3 build`, `wails3 package`) stamp the version and the commit.
+  - About shows "Version 0.5.0" and, on the next line, "Build <commit>" (with `-dirty` if the working tree had uncommitted changes). `wails3 dev` still shows `dev`.
+  - The version comes from `APP_VERSION` in `Taskfile.yml`, kept in step with `version` in `build/config.yml`; the commit from `git describe --always --dirty --exclude "*"`. So it doesn't depend on tags.
   - The Windows file version, macOS bundle version, Linux package version and installer version are now 0.5.0 (were the template's 0.0.1).
 - **README:** what the app does, the beta note, and install notes per system. Builds are unsigned, so each system warns once: SmartScreen on Windows, "Open Anyway" in Privacy & Security on macOS, `chmod +x` and the GTK 4 / WebKitGTK 6.0 libraries on Linux. Also how versions are stamped and how the icon is made.
 - **Template leftovers:** removed the unused `build/ios` folder; filled the MSIX manifests' "My Company" / "My Product" placeholders with bajdev / mpckit.
 - **Licence:** already done (MIT, copyright 2026 bajdev). The About dialog and README already say mpckit is not affiliated with Akai.
 
+**Change after the first laptop run** (bajdev, 2026-11-12: the Windows build runs): About showed the commit id instead of 0.5.0, because the first version of the stamping used `git describe --tags` and there are no tags yet. It now shows the version from the Taskfile, with the commit on its own "Build" line.
+
 ## Testing
 
 On the server:
 - `go vet` and `go test ./...` pass.
-- The Taskfile parses (`wails3 task --list-all`). A dry run of the Windows build shows `-X …internal/app.Version=<git describe>` in the `go build` flags.
+- The Taskfile parses (`wails3 task --list-all`). A dry run of the Windows build shows `-X …internal/app.Version=0.5.0 -X …internal/app.Commit=<commit>` in the `go build` flags.
 - A Windows build with `-X …Version=v0.5.0-check` contains that string.
 - `tools/icon` regenerates `build/appicon.png` byte for byte.
 
 **On the laptop:**
 1. `wails3 build` produces `bin\mpckit.exe`. Explorer, the taskbar and the window show the new icon (Windows caches icons; if Explorer still shows the old one, rename the file or sign out and back in).
-2. Run `bin\mpckit.exe` and open About: the version is the commit id (no tags yet; after merge it becomes `v0.5.0` once tagged).
+2. Run `bin\mpckit.exe` and open About: "Version 0.5.0", then "Build <commit>".
 3. Right-click `mpckit.exe` → Properties → Details: product name mpckit, version 0.5.0, copyright (c) 2026 bajdev.
 
 ## Next (M9 part 2)
 
-After this is merged: tag `v0.5.0` on the merge commit, build from the tag on each system (Windows laptop, Linux desktop, and a Mac when one is available), and check each build runs and shows `v0.5.0` in About. That is M9's done-when. If the repo is mirrored to GitHub, an Actions workflow could build all three instead.
+After this is merged: tag `v0.5.0` on the merge commit, build from the tag on each system (Windows laptop, Linux desktop, and a Mac when one is available), and check each build runs and shows "Version 0.5.0" in About. That is M9's done-when. If the repo is mirrored to GitHub, an Actions workflow could build all three instead.