Skip to content

feat(cli): embed release version via build.rs instead of CI string replacement#989

Open
Nobody9512 wants to merge 3 commits intovoidzero-dev:mainfrom
Nobody9512:feat/embed-release-version
Open

feat(cli): embed release version via build.rs instead of CI string replacement#989
Nobody9512 wants to merge 3 commits intovoidzero-dev:mainfrom
Nobody9512:feat/embed-release-version

Conversation

@Nobody9512
Copy link
Copy Markdown

Summary

  • Add build.rs to vite_global_cli that resolves the version at compile time through a 3-layer fallback: VITE_PLUS_VERSION env var → git describe --tagsCARGO_PKG_VERSION
  • Replace env!("CARGO_PKG_VERSION") with env!("VITE_PLUS_VERSION") in the 3 call sites within vite_global_cli
  • Update CI release workflow to pass VITE_PLUS_VERSION env var and remove the now-unnecessary string replacement for vite_global_cli/Cargo.toml

This allows distro packagers (Nix, Homebrew, AUR) to build from source with the correct version by setting VITE_PLUS_VERSION=x.y.z, and local dev builds in a git checkout will automatically pick up the version from git tags instead of showing vp v0.0.0.

Closes #976

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 17, 2026

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 5c1d20f
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/69e5be67eaeb1e00083700f2

@fengmk2 fengmk2 requested review from Boshen and Brooooooklyn March 17, 2026 09:17
@Boshen Boshen requested a review from fengmk2 April 20, 2026 05:07
contents: read
env:
VERSION: ${{ needs.prepare.outputs.version }}
VITE_PLUS_VERSION: ${{ needs.prepare.outputs.version }}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should change to VP_VERSION instead of VITE_PLUS_VERSION after #1166

@fengmk2
Copy link
Copy Markdown
Member

fengmk2 commented Apr 20, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c1d20fc47

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -91,17 +92,10 @@ jobs:
shell: bash
run: |
pnpm exec tool replace-file-content packages/cli/binding/Cargo.toml 'version = "0.0.0"' 'version = "${{ env.VERSION }}"'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore CLI package version replacement for release builds

Keeping only packages/cli/binding/Cargo.toml replacement here leaves crates/vite_global_cli/Cargo.toml at 0.0.0 in release artifacts, but upgrade_check.rs still reads env!("CARGO_PKG_VERSION") (see check_for_update/display_upgrade_notice) and is_newer_version explicitly returns false for 0.0.0. In release binaries this disables background update notices entirely, which is a functional regression from the previous workflow where the CLI crate version was rewritten before building.

Useful? React with 👍 / 👎.

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.

Embed release version in source instead of relying on CI string replacement

2 participants