chore: derive RELEASE_VERSION from compile-time env #52

Merged
gofix merged 4 commits from chore/derive-release-version-from-env into master 2026-05-03 15:08:33 +00:00
Owner

Stacked on top of #51.

Summary

  • Replace the hand-edited RELEASE_VERSION constant in api/sdk.rs with concat!("v", env!("CARGO_PKG_VERSION"), "+", env!("PORTAL_RS_BUILD")).
  • The wire-level release_version returned by /sdk/domain now matches --version output and tracks the release tag automatically.
  • Update the fixture-shape test to override the fixture's release_version field with the runtime constant before comparing — every other field of the response is still pinned by the fixture.
  • Update fixture file's release_version to a current-convention example (v2.1.8+rs.1) so it documents the new shape; the test override means the literal value no longer affects pass/fail.
  • Note in README that releases are cut by tag push alone, no separate code-bump PR.

Why

With #51, --version output and the workspace Cargo.toml version are both build-time-driven. Leaving RELEASE_VERSION as a hand-edited constant kept two sources of truth for the same fact and forced a separate code bump PR for every release (the historical chore: bump release version to v2.1.8-rs.devN pattern). Deriving it from the same build-time inputs eliminates the bump PR and a class of "forgot to update the constant" bugs.

Test plan

  • cargo build --release succeeds.
  • cargo test --release -p portal-relay — 86 passed, 3 ignored (kernel-WG, expected).
  • PORTAL_RS_BUILD=rs.1 cargo test sdk_domain_response_matches_fixture — pass.
  • Default build: --versionportal-relay 2.1.8+rs.dev.
  • PORTAL_RS_BUILD=rs.1 build: --versionportal-relay 2.1.8+rs.1.
  • After merge, v2.1.8+rs.1 tag push → /sdk/domain returns release_version: "v2.1.8+rs.1" (verify in deployed image).
Stacked on top of #51. ## Summary - Replace the hand-edited `RELEASE_VERSION` constant in `api/sdk.rs` with `concat!("v", env!("CARGO_PKG_VERSION"), "+", env!("PORTAL_RS_BUILD"))`. - The wire-level `release_version` returned by `/sdk/domain` now matches `--version` output and tracks the release tag automatically. - Update the fixture-shape test to override the fixture's `release_version` field with the runtime constant before comparing — every other field of the response is still pinned by the fixture. - Update fixture file's `release_version` to a current-convention example (`v2.1.8+rs.1`) so it documents the new shape; the test override means the literal value no longer affects pass/fail. - Note in README that releases are cut by tag push alone, no separate code-bump PR. ## Why With #51, `--version` output and the workspace `Cargo.toml` version are both build-time-driven. Leaving `RELEASE_VERSION` as a hand-edited constant kept two sources of truth for the same fact and forced a separate code bump PR for every release (the historical `chore: bump release version to v2.1.8-rs.devN` pattern). Deriving it from the same build-time inputs eliminates the bump PR and a class of "forgot to update the constant" bugs. ## Test plan - [x] `cargo build --release` succeeds. - [x] `cargo test --release -p portal-relay` — 86 passed, 3 ignored (kernel-WG, expected). - [x] `PORTAL_RS_BUILD=rs.1 cargo test sdk_domain_response_matches_fixture` — pass. - [x] Default build: `--version` → `portal-relay 2.1.8+rs.dev`. - [x] `PORTAL_RS_BUILD=rs.1` build: `--version` → `portal-relay 2.1.8+rs.1`. - [ ] After merge, `v2.1.8+rs.1` tag push → `/sdk/domain` returns `release_version: "v2.1.8+rs.1"` (verify in deployed image).
Replace the hand-edited `RELEASE_VERSION` constant in the SDK domain API
with a `concat!(env!(...))` expression that pulls `CARGO_PKG_VERSION` and
`PORTAL_RS_BUILD` at compile time. The wire-level `release_version` field
returned by `/sdk/domain` now matches `--version` output and is driven
entirely by the workspace version + the build-arg injected from the
release tag.

Releases no longer require a separate code bump PR — pushing a tag like
`v2.1.8+rs.1` is enough; the container-image workflow extracts `rs.1`
from the ref and forwards it to the build.

The fixture-shape test now overrides the fixture's `release_version`
field with the runtime constant before comparing, so the snapshot keeps
its value as a "what a real release looks like" example without having
to be updated on every bump.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Trim the README to just what consumers of the relay image need: what it
is, the upstream compat target, how to run the published image, and how
to read the release tag scheme.

Build-time identity injection, the SemVer build-metadata mechanics, and
the rationale for the tag convention are maintainer concerns and do not
need to live on the landing page; they remain in the relevant PR
descriptions and source comments.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
gofix changed target branch from chore/adopt-k3s-style-versioning to master 2026-05-03 14:59:53 +00:00
gofix force-pushed chore/derive-release-version-from-env from 604f91d970 to feba6ffb57
Some checks failed
Rust CI / Format, lint, and test (pull_request) Failing after 3s
2026-05-03 15:01:14 +00:00
Compare
chore: prefix --version output with v to match wire format
Some checks failed
Rust CI / Format, lint, and test (pull_request) Failing after 2s
de7c2dde47
The SDK domain API exposes the relay version as `release_version` with a
leading `v` (e.g., `v2.1.8+rs.1`), matching the format used by upstream
Go and previously by the hand-edited constant. clap's default `--version`
output dropped that prefix because `CARGO_PKG_VERSION` is bare.

Add `"v"` to the front of the version string so both surfaces print
`v2.1.8+rs.1` consistently.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
chore: cargo fmt
All checks were successful
Rust CI / Format, lint, and test (pull_request) Successful in 50s
a1ff0250cf
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
gofix merged commit ab8f6127f7 into master 2026-05-03 15:08:33 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
gofix/portal-tunnel-rs!52
No description provided.