Use npm package version for release builds#1008
Conversation
The CI refactor (5932048) dropped the Cargo.toml version patching step that was in the old release.yml. Without it, release binaries are compiled with version "0.0.1-dev", causing get_envio_version() to walk up the filesystem looking for packages/envio — which doesn't exist when the binary is installed via npm. - Add "Set version in Cargo.toml" step to build-platforms.yml - Add linux-x64 (musl) to build-platforms.yml matrix so all 4 release binaries get the correct version baked in - Update publish.yml to download all platform packages from build-platforms instead of reusing the dev linux-x64 from build_and_verify https://claude.ai/code/session_01QvDMVPq3tH4A1EQqtxudj2
Instead of relying solely on the compile-time CARGO_PKG_VERSION (which requires Cargo.toml patching during CI), read the version from the sibling package.json of the npm platform package at runtime. This avoids rebuilding linux-x64 in the publish pipeline — the binary from build_and_verify (compiled with 0.0.1-dev) will read the correct version from the package.json that publish.yml already patches. The Cargo.toml patching in build-platforms.yml is kept as a safety net for the 3 other platforms. Fallback order: 1. ../package.json version (npm-installed binaries) 2. Compile-time CARGO_PKG_VERSION (standalone binaries) 3. Filesystem walk for packages/envio (local dev) https://claude.ai/code/session_01QvDMVPq3tH4A1EQqtxudj2
The runtime package.json read is the sole mechanism for determining the version in published binaries. No need for Cargo.toml patching in CI or the compile-time version fallback in get_envio_version(). Note: CURRENT_CRATE_VERSION in persisted_state still uses CARGO_PKG_VERSION for detecting version changes during codegen. https://claude.ai/code/session_01QvDMVPq3tH4A1EQqtxudj2
Replace CURRENT_CRATE_VERSION static (compile-time CARGO_PKG_VERSION) with current_version() function that reads from the npm platform package's package.json at runtime, cached via OnceLock. Falls back to CARGO_PKG_VERSION for local dev builds. This ensures persisted state correctly detects version changes between envio upgrades in published binaries. https://claude.ai/code/session_01QvDMVPq3tH4A1EQqtxudj2
…errors The function now returns descriptive error messages (e.g. "Could not read package.json ... Try reinstalling with: pnpm add envio") instead of silently returning None. current_version() still falls back to "dev" for local dev/test builds where no package.json exists, while get_envio_version() surfaces the error when both package.json and packages/envio are missing. https://claude.ai/code/session_01QvDMVPq3tH4A1EQqtxudj2
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (7)
📒 Files selected for processing (6)
📝 WalkthroughWalkthroughA refactoring that replaces the hard-coded Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
This PR updates the version detection logic to prioritize the npm package's
package.jsonversion for release builds, while maintaining fallback to local development mode detection.Key Changes
read_version_from_package_json()function: Reads the version from the npm platform package'spackage.jsonfile by traversing up from the executable location (<pkg>/bin/envio→<pkg>/package.json)get_envio_version()logic: Now uses a two-tier approach:package.json(used for published releases)packages/envio(for development)CURRENT_CRATE_VERSIONconstant to a runtimecurrent_version()function that usesOnceLockfor lazy initializationpersisted_state,codegen,dev, andmodmodules to use the newcurrent_version()function"0.0.1-dev"to"dev"in all codegen template snapshotsImplementation Details
OnceLockto ensure the version is computed only once and cached for the lifetime of the applicationpackage.jsoncannot be found (suggests reinstalling via pnpm)https://claude.ai/code/session_01QvDMVPq3tH4A1EQqtxudj2
Summary by CodeRabbit