Skip to content

feat: wk update is version-aware - #17

Merged
wavekat-eason merged 1 commit into
mainfrom
feat/update-version-aware
Apr 28, 2026
Merged

feat: wk update is version-aware#17
wavekat-eason merged 1 commit into
mainfrom
feat/update-version-aware

Conversation

@wavekat-eason

Copy link
Copy Markdown
Contributor

Summary

Until now wk update piped install.sh to sh and let install.sh resolve /releases/latest itself. If that redirect was still pointing at the running version (e.g. mid release-plz promotion of the next release), install.sh would dutifully reinstall the same version and the only signal the user saw was install.sh's own `Installing wk vX` line. That looks like success but is actually a silent no-op — exactly what burned us when v0.0.8 was published: `wk update` reported `Installing wk v0.0.7` while v0.0.8 was still being promoted, with no way to tell nothing had actually changed.

This PR resolves the target tag in wk update itself, before handing off to the installer:

  • Resolve once. If --version is set, use it; otherwise read the /releases/latest redirect exactly once.
  • Short-circuit no-ops. If the resolved tag equals CARGO_PKG_VERSION, print `✓ wk X.Y.Z is the latest — nothing to do` and skip the rename-aside / installer dance entirely.
  • --force for users who want to reinstall the same tag (broken file, swapped dirs).
  • Clear before/after framing. When an update is going to happen, emit `· updating wk vA → vB` up front and `✓ wk updated to vB` on success — no more guessing whether the installer's "Installing wk vX" line means a real change.
  • Pin install.sh. Pass WK_VERSION to install.sh with the tag we just resolved so it doesn't re-resolve /releases/latest and pick a different version than the one we told the user about. (This also collapses two redirect reads into one.)

Tests cover the small v-prefix helper that builds the WK_VERSION value handed to install.sh.

Test plan

  • cargo build --release clean
  • cargo fmt --all -- --check clean
  • cargo clippy --all-targets -- -D warnings clean
  • cargo test — 32 passed (2 new)
  • wk update --help shows --force
  • wk update --check reports current vs latest
  • Verify on next release: wk update shows the vA → vB line and short-circuits cleanly when re-run after success.

Followup

This works alongside #15 (atomic draft-release promotion). With #15 merged, /releases/latest only ever points at a fully-built release, so the silent-no-op race shrinks toward zero. This PR is still worth landing for the clearer UX even after that — the no-op short-circuit and explicit version framing make the command self-explanatory.

🤖 Generated with Claude Code

Until now `wk update` piped install.sh to sh and let install.sh resolve
/releases/latest. If that redirect was still pointing at the running
version (e.g. mid release-plz promotion of the next release), install.sh
would dutifully reinstall the same version and the only signal the user
saw was install.sh's own "Installing wk vX" line — which looks like
success but is actually a silent no-op. This burned us right after
v0.0.8 was published: `wk update` printed "Installing wk v0.0.7" while
v0.0.8 was still being promoted, and there was no way to tell that
nothing had actually changed.

Resolve the target tag in `wk update` itself, before invoking the
installer:

- If pin (`--version`) is set, use it; otherwise read the redirect from
  /releases/latest exactly once.
- If the resolved version equals CARGO_PKG_VERSION, short-circuit with
  "✓ wk X.Y.Z is the latest — nothing to do" and skip the binary
  shuffle entirely. `--force` overrides for users who want to reinstall
  the same tag (broken file, swapped dirs, etc.).
- Otherwise emit a `· updating wk vA → vB` line up front, run install.sh
  with `WK_VERSION` pinned to the resolved tag (so install.sh doesn't
  re-resolve and potentially pick a different release), and on success
  print `✓ wk updated to vB.`

Side benefit: pinning WK_VERSION removes the second redirect read
inside install.sh, so the two halves of the update can't disagree.

Tests cover the v-prefix helper used to feed install.sh.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@wavekat-eason
wavekat-eason merged commit 1bfa401 into main Apr 28, 2026
1 check passed
@wavekat-eason
wavekat-eason deleted the feat/update-version-aware branch April 28, 2026 10:45
@github-actions github-actions Bot mentioned this pull request Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant