-
Notifications
You must be signed in to change notification settings - Fork 165
feat(cli): embed release version via build.rs instead of CI string replacement #989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,7 @@ jobs: | |
| contents: read | ||
| env: | ||
| VERSION: ${{ needs.prepare.outputs.version }} | ||
| VITE_PLUS_VERSION: ${{ needs.prepare.outputs.version }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
|
|
@@ -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 }}"' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Keeping only Useful? React with 👍 / 👎. |
||
| pnpm exec tool replace-file-content crates/vite_global_cli/Cargo.toml 'version = "0.0.0"' 'version = "${{ env.VERSION }}"' | ||
| cat crates/vite_global_cli/Cargo.toml | ||
|
|
||
| - name: Verify version replacement | ||
| shell: bash | ||
| run: | | ||
| if grep -q 'version = "0.0.0"' crates/vite_global_cli/Cargo.toml; then | ||
| echo "ERROR: Version replacement failed for crates/vite_global_cli/Cargo.toml" | ||
| head -5 crates/vite_global_cli/Cargo.toml | ||
| exit 1 | ||
| fi | ||
| if grep -q 'version = "0.0.0"' packages/cli/binding/Cargo.toml; then | ||
| echo "ERROR: Version replacement failed for packages/cli/binding/Cargo.toml" | ||
| head -5 packages/cli/binding/Cargo.toml | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| fn main() { | ||
| println!("cargo:rerun-if-env-changed=VITE_PLUS_VERSION"); | ||
|
|
||
| let version = std::env::var("VITE_PLUS_VERSION") | ||
| .ok() | ||
| .filter(|v| !v.is_empty()) | ||
| .or_else(version_from_git) | ||
| .unwrap_or_else(|| std::env::var("CARGO_PKG_VERSION").unwrap()); | ||
|
|
||
| println!("cargo:rustc-env=VITE_PLUS_VERSION={version}"); | ||
| } | ||
|
|
||
| fn version_from_git() -> Option<String> { | ||
| let output = std::process::Command::new("git") | ||
| .args(["describe", "--tags", "--match", "v*", "--abbrev=0"]) | ||
| .output() | ||
| .ok()?; | ||
|
|
||
| if !output.status.success() { | ||
| return None; | ||
| } | ||
|
|
||
| let tag = String::from_utf8(output.stdout).ok()?; | ||
| let tag = tag.trim(); | ||
| tag.strip_prefix('v').map(|s| s.to_owned()) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should change to
VP_VERSIONinstead ofVITE_PLUS_VERSIONafter #1166