diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42f83f02..4c980b28 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,8 @@ name: CI on: push: + branches: + - main pull_request: permissions: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 05f46080..a3b7b8af 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,6 +46,11 @@ jobs: echo "Release tag must be semantic and start with v: $RELEASE_TAG" >&2 exit 1 fi + source_version=$(tr -d '\r\n' < internal/version/VERSION) + if [[ "$RELEASE_TAG" != "v$source_version" ]]; then + echo "Release tag $RELEASE_TAG does not match source version v$source_version" >&2 + exit 1 + fi git show-ref --verify --quiet "refs/tags/$RELEASE_TAG" git fetch --no-tags origin main if ! git merge-base --is-ancestor "$RELEASE_TAG^{commit}" FETCH_HEAD; then diff --git a/README.md b/README.md index 2086fc8c..8925cad0 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ opening `/status` in your working Codex session. ```text █▀▀ █▀█ █▀▄ █▀▀ ▀▄▀ █▀█ █▀▄▀█ █▀▀ ▀█▀ █▀▀ █▀█ █▄▄ █▄█ █▄▀ ██▄ █ █ █▄█ █ ▀ █ ██▄ █ ██▄ █▀▄ -◉ QUOTA TELEMETRY CONSOLE · VERSION 0.10.0 +◉ QUOTA TELEMETRY CONSOLE · VERSION ``` ![Codexometer Hacker theme showing quota and reset-cycle gauges](assets/codexometer.png) @@ -117,8 +117,9 @@ curl -fsSL https://raw.githubusercontent.com/merefield/codexometer/main/install- CODEXOMETER_BIN_DIR="$HOME/.local/bin" sh ``` -To install a specific release, add `CODEXOMETER_VERSION=v0.10.0` beside the -bin-directory setting or download the script and pass `--version v0.10.0`. +To install a specific release, replace `vX.Y.Z` with its tag and add +`CODEXOMETER_VERSION=vX.Y.Z` beside the bin-directory setting, or download the +script and pass `--version vX.Y.Z`. On Windows, download and run the PowerShell installer: @@ -134,7 +135,7 @@ The execution-policy override applies only to that PowerShell process. Inspect the downloaded script before running it if required by your security policy. It installs into `%LOCALAPPDATA%\Programs\codexometer\bin` by default. Override -that with `CODEXOMETER_BIN_DIR` or `-BinDir`; use `-Version v0.10.0` to select a +that with `CODEXOMETER_BIN_DIR` or `-BinDir`; use `-Version vX.Y.Z` to select a release. Both installers print a reminder if the destination is not already on `PATH`. Re-running the same command safely upgrades or reinstalls Codexometer. @@ -1286,10 +1287,10 @@ remain unchanged between validation and publication. ## Versioning -Codexometer follows semantic versioning; the current source version is -`v0.10.0`. The Git tag is the release source of truth. Go automatically embeds -that tag in binaries built with -`go install github.com/merefield/codexometer@v0.10.0`. +Codexometer follows semantic versioning. The maintained source version lives in +[`internal/version/VERSION`](internal/version/VERSION), and the release workflow +requires its Git tag to match. Go automatically embeds an exact tag in binaries +built with `go install github.com/merefield/codexometer@vX.Y.Z`. The resolver uses the first version available in this order: @@ -1297,11 +1298,11 @@ The resolver uses the first version available in this order: `make build`; 2. Go's embedded module version—an exact tag for a release build or, when Go supplies one, a pseudo-version such as - `0.10.1-0.-[+dirty]`; + `X.Y.Z-0.-[+dirty]`; 3. for a local checkout whose module version is `(devel)`, a VCS fallback in - the explicit form `0.10.0-dev+[.dirty]`; -4. the maintained source version, `0.10.0`, when no build or VCS identity is - available. + the explicit form `-dev+[.dirty]`; +4. the maintained value in `internal/version/VERSION` when no build or VCS + identity is available. The leading `v` used by Git tags and Go module versions is removed in every case. The VCS fallback is a Codexometer development identity, not a Go @@ -1319,7 +1320,7 @@ codexometer --version Release automation can override the source-build fallback without editing code: ```sh -go build -ldflags="-s -w -X github.com/merefield/codexometer/internal/version.buildVersion=v0.10.0" . +go build -ldflags="-s -w -X github.com/merefield/codexometer/internal/version.buildVersion=vX.Y.Z" . ``` ## How refresh works diff --git a/internal/ui/view_test.go b/internal/ui/view_test.go index 04e25f5c..3392920c 100644 --- a/internal/ui/view_test.go +++ b/internal/ui/view_test.go @@ -136,7 +136,7 @@ func TestStatusAndFooterKeepOnlyEssentialMetadata(t *testing.T) { snapshot: codex.DemoSnapshot(), nextRefresh: time.Now().Add(time.Minute), meterView: viewBars, - appVersion: "0.10.0-dev+abc123.dirty", + appVersion: "1.2.3-dev+abc123.dirty", } colors := paletteFor(themeHacker) account := ansi.Strip(model.renderAccount(colors)) @@ -153,7 +153,7 @@ func TestStatusAndFooterKeepOnlyEssentialMetadata(t *testing.T) { if !strings.HasSuffix(headerLines[len(headerLines)-1], "ACCOUNT // PLUS") { t.Fatalf("account is not aligned with the subtitle: %q", headerLines[len(headerLines)-1]) } - if !strings.Contains(headerLines[len(headerLines)-1], "VERSION 0.10.0-DEV+ABC123.DIRTY") { + if !strings.Contains(headerLines[len(headerLines)-1], "VERSION 1.2.3-DEV+ABC123.DIRTY") { t.Fatalf("resolved build version is absent from the masthead: %q", headerLines[len(headerLines)-1]) } footer := ansi.Strip(model.renderFooter(100, colors)) diff --git a/internal/version/VERSION b/internal/version/VERSION new file mode 100644 index 00000000..d9df1bbc --- /dev/null +++ b/internal/version/VERSION @@ -0,0 +1 @@ +0.11.0 diff --git a/internal/version/version.go b/internal/version/version.go index 6ebbd14f..0339a070 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -2,13 +2,17 @@ package version import ( + _ "embed" "runtime/debug" "strings" ) -// Version is the source fallback. Tagged module installs and builds made with -// an injected buildVersion use their embedded version instead. -const Version = "0.10.0" +// sourceVersion is the single maintained release value for source builds. +// Tagged module installs and builds made with an injected buildVersion use +// their embedded version instead. +// +//go:embed VERSION +var sourceVersion string // buildVersion may be populated at link time from the nearest Git tag. var buildVersion string @@ -28,7 +32,7 @@ func Current() string { return value } } - return Version + return maintainedVersion() } // vcsFallback identifies a local checkout when Go reports Main.Version as @@ -51,13 +55,17 @@ func vcsFallback(settings []debug.BuildSetting) string { if len(revision) > 12 { revision = revision[:12] } - value := Version + "-dev+" + revision + value := maintainedVersion() + "-dev+" + revision if modified { value += ".dirty" } return value } +func maintainedVersion() string { + return normalize(sourceVersion) +} + func normalize(value string) string { value = strings.TrimSpace(value) if value == "" || value == "(devel)" { diff --git a/internal/version/version_test.go b/internal/version/version_test.go index c0f8d5f3..1c3eb5e6 100644 --- a/internal/version/version_test.go +++ b/internal/version/version_test.go @@ -7,11 +7,11 @@ import ( func TestCurrentUsesBuildOverride(t *testing.T) { previous := buildVersion - buildVersion = "v0.10.0" + buildVersion = "v1.2.3" t.Cleanup(func() { buildVersion = previous }) - if got := Current(); got != "0.10.0" { - t.Fatalf("Current() = %q, want 0.10.0", got) + if got := Current(); got != "1.2.3" { + t.Fatalf("Current() = %q, want 1.2.3", got) } } @@ -32,8 +32,9 @@ func TestVCSFallbackIncludesRevisionAndDirtyState(t *testing.T) { {Key: "vcs.revision", Value: "0123456789abcdef"}, {Key: "vcs.modified", Value: "true"}, }) - if got != "0.10.0-dev+0123456789ab.dirty" { - t.Fatalf("vcsFallback() = %q", got) + want := maintainedVersion() + "-dev+0123456789ab.dirty" + if got != want { + t.Fatalf("vcsFallback() = %q, want %q", got, want) } }