Skip to content

feat(cli): add odek upgrade self-update command#119

Merged
jkyberneees merged 1 commit into
mainfrom
feat/self-upgrade
Jul 27, 2026
Merged

feat(cli): add odek upgrade self-update command#119
jkyberneees merged 1 commit into
mainfrom
feat/self-upgrade

Conversation

@jkyberneees

Copy link
Copy Markdown
Contributor

Summary

New odek upgrade [--check] command: self-upgrade from GitHub Releases with OS/arch autodetection.

Behavior

  • Autodetection — maps runtime.GOOS/GOARCH to the odek-<goos>-<goarch> release asset (darwin/linux × amd64/arm64); unsupported platforms get a clear build-from-source error
  • Version check — fetches repos/BackendStack21/odek/releases/latest via the GitHub API, semver-compares against getVersion(); dev/commit-hash builds always count as older; prints "up to date" when current ≥ latest
  • Verified install — downloads checksums.txt + the asset, requires a matching SHA-256 (refuses unverifiable installs and checksum mismatches), then replaces the binary atomically: temp dir next to the target → chmod to the original mode → os.Rename (same filesystem). Permission failures suggest sudo odek upgrade
  • --check — reports the available upgrade without touching the binary
  • Download caps: 256 MiB asset, 1 MiB API/checksum reads; 5-minute overall timeout

Testing

  • 8 new tests in cmd/odek/upgrade_test.go against an httptest fake release server: version compare, checksum parsing, platform mapping, end-to-end replace with mode preservation, up-to-date short-circuit, --check no-touch, checksum-mismatch refusal, API payload parsing
  • Full cmd/odek suite green; gofmt/go vet clean
  • Live E2E: a dev-built binary ran upgrade --check (correctly offered 9a0c0fa → v1.16.0 on darwin/arm64), then upgrade — downloaded, verified, self-replaced, and reported odek v1.16.0

Docs: docs/CLI.md command row, usage text in main.go, layout entry in AGENTS.md.

Self-upgrade from GitHub Releases with OS/arch autodetection:

- Maps runtime.GOOS/GOARCH to the odek-<goos>-<goarch> release asset;
  unsupported platforms get a clear build-from-source error
- Fetches the latest release via the GitHub API and semver-compares
  against getVersion(); dev/commit-hash builds always count as older
- Verifies the download against the release checksums.txt (SHA-256) and
  refuses unverifiable or mismatching installs
- Installs atomically: temp dir next to the target binary, chmod to the
  original mode, os.Rename over the running binary; permission failures
  suggest sudo
- --check reports the available upgrade without installing

Tests (httptest fake release server): version compare, checksum parsing,
platform mapping, end-to-end replace with mode preservation, up-to-date
short-circuit, --check no-touch, checksum-mismatch refusal, API parsing.
Also verified live: dev binary upgraded itself to v1.16.0 from GitHub.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
odek 4dabec3 Commit Preview URL

Branch Preview URL
Jul 27 2026, 11:02 AM

@jkyberneees
jkyberneees merged commit 2a0ea86 into main Jul 27, 2026
10 checks passed
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