Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
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

strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -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 👍 / 👎.

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
Expand Down
26 changes: 26 additions & 0 deletions crates/vite_global_cli/build.rs
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())
}
4 changes: 2 additions & 2 deletions crates/vite_global_cli/src/commands/upgrade/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub async fn execute(options: UpgradeOptions) -> Result<ExitStatus, Error> {
registry::resolve_version(version_or_tag, &platform_suffix, options.registry.as_deref())
.await?;

let current_version = env!("CARGO_PKG_VERSION");
let current_version = env!("VITE_PLUS_VERSION");

if !options.silent {
output::info(&format!(
Expand Down Expand Up @@ -220,7 +220,7 @@ async fn execute_rollback(
}

if !silent {
let current_version = env!("CARGO_PKG_VERSION");
let current_version = env!("VITE_PLUS_VERSION");
output::info("rolling back to previous version...");
output::info(&format!("switching from {} {} {}", current_version, output::ARROW, previous));
}
Expand Down
2 changes: 1 addition & 1 deletion crates/vite_global_cli/src/commands/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub async fn execute(cwd: AbsolutePathBuf) -> Result<ExitStatus, Error> {
println!("{}", vite_shared::header::vite_plus_header());
println!();

println!("vp v{}", env!("CARGO_PKG_VERSION"));
println!("vp v{}", env!("VITE_PLUS_VERSION"));
println!();

// Local vite-plus and tools
Expand Down
Loading