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 }}
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -87,17 +88,10 @@ jobs:
shell: bash
run: |
pnpm exec tool replace-file-content packages/cli/binding/Cargo.toml 'version = "0.0.0"' 'version = "${{ env.VERSION }}"'
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 @@ -64,7 +64,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 @@ -226,7 +226,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 @@ -148,7 +148,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