Skip to content

refactor(release): make the version contract single-source #238

Open

Description

@KalebCole

Problem

internal/app/buildinfo.go is the intended version source, but release work currently requires changing that value and 67 literal 3.0.x values embedded in JSON-envelope tests. The v3.0.1 release demonstrated the cost: the version bump was mechanically safe only after a broad replacement and independent review.

GoReleaser already injects the release-tag version into internal/app.Version through linker flags. Direct Go installs also carry module build information that can identify the installed tag. Source code does not need to impersonate the latest release, but direct Go installs must remain a first-class, identifiable distribution path.

Design

Adopt a GogCLI-style version-resolution contract. dev is a final fallback, not the expected value for all non-GoReleaser builds.

Resolve the reported version in this order:

  1. Explicit linker-injected version: official GoReleaser archives report the immutable release version, for example 3.0.2.
  2. Go module build information: a direct install such as go install github.com/KalebCole/partiful-cli/cmd/[email protected] reports 3.0.2 from runtime/debug.ReadBuildInfo().
  3. Project-local build metadata: the repository’s supported local build command injects git describe --tags --always --dirty, so a checkout can report an informative revision such as v3.0.2-4-gabc1234-dirty.
  4. Final fallback: a raw build with no injected or embedded metadata reports dev.

Normalize the display form so existing Partiful releases retain their current no-leading-v convention (3.0.2, not v3.0.2).

Test fixtures derive data.version and meta.cliVersion from the same in-process resolved version value rather than repeating a literal version throughout JSON expectations. The source tree must never require a global string replacement for a normal patch release.

Do not change product contract revisions as part of this issue.

Implementation outline

  1. Add a focused version-resolution helper around the existing internal/app.Version variable and runtime/debug.ReadBuildInfo().
  2. Preserve a sentinel source default such as dev; use it only when no linker value, module version, or local-build metadata exists.
  3. Add a supported local build command or script that passes git describe --tags --always --dirty through linker flags without changing release behavior.
  4. Keep GoReleaser's existing -X github.com/KalebCole/partiful-cli/internal/app.Version={{ .Version }} release injection.
  5. Introduce small test helpers for constructing version-bearing response metadata and replace literal version fragments in internal/app/execute_test.go and internal/app/guests_execute_test.go.
  6. Update README install guidance for pinned tagged Go installs, @latest, source builds, and release archives.

Acceptance criteria

  • A release-style build with linker-injected 3.0.2 reports 3.0.2 in both data.version and meta.cliVersion.
  • A build with Go module information for v3.0.2 reports normalized 3.0.2 without a GoReleaser linker injection.
  • A project-local build through the supported command reports a git describe version rather than a bare dev value when Git metadata is available.
  • A raw build with no known build metadata reports dev.
  • Version-bearing tests derive their expected value from one test/runtime source, not a repeated literal release number.
  • A future patch release does not require updating JSON snapshots across unrelated command tests.
  • go mod verify, go test ./..., go test -race ./..., go vet ./..., go build ./..., and ./scripts/verify-native-release.sh pass.
  • No release tag, GitHub Release, or public artifact is created by this issue.

Dependency

This is the prerequisite for the SVU release automation issue. It removes the need for release automation to rewrite many test fixtures or open a version-only PR while preserving meaningful version output for users who install with Go.

Activity

  1. self-assigned this
    on Sep 18, 2026
  2. added
    enhancement
    on Sep 18, 2026
  3. KalebCole commented on Nov 14, 2026

    @KalebCole
    OwnerAuthor

    Triage bot: fits the Go-only release path, no hold. Version stays single-source in internal/app/buildinfo.go with GoReleaser ldflags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions