Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: CI

on:
push:
branches:
- main
pull_request:

permissions:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ opening `/status` in your working Codex session.
```text
█▀▀ █▀█ █▀▄ █▀▀ ▀▄▀ █▀█ █▀▄▀█ █▀▀ ▀█▀ █▀▀ █▀█
█▄▄ █▄█ █▄▀ ██▄ █ █ █▄█ █ ▀ █ ██▄ █ ██▄ █▀▄
◉ QUOTA TELEMETRY CONSOLE · VERSION 0.10.0
◉ QUOTA TELEMETRY CONSOLE · VERSION <CURRENT>
```

![Codexometer Hacker theme showing quota and reset-cycle gauges](assets/codexometer.png)
Expand Down Expand Up @@ -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:

Expand All @@ -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.

Expand Down Expand Up @@ -1286,22 +1287,22 @@ 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:

1. a link-time value, such as the nearest Git description injected by
`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.<timestamp>-<commit>[+dirty]`;
`X.Y.Z-0.<timestamp>-<commit>[+dirty]`;
3. for a local checkout whose module version is `(devel)`, a VCS fallback in
the explicit form `0.10.0-dev+<commit>[.dirty]`;
4. the maintained source version, `0.10.0`, when no build or VCS identity is
available.
the explicit form `<source-version>-dev+<commit>[.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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/ui/view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand Down
1 change: 1 addition & 0 deletions internal/version/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.11.0
18 changes: 13 additions & 5 deletions internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,7 +32,7 @@ func Current() string {
return value
}
}
return Version
return maintainedVersion()
}

// vcsFallback identifies a local checkout when Go reports Main.Version as
Expand All @@ -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)" {
Expand Down
11 changes: 6 additions & 5 deletions internal/version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -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)
}
}

Expand Down
Loading