Skip to content
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

fix(cli): Fix auto-package version bumping in 'wasmer deploy' #4467

Merged
Merged
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
2 changes: 1 addition & 1 deletion lib/cli/src/commands/create_exe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1958,7 +1958,7 @@ pub(super) mod utils {
#[test]
fn test_filter_tarball() {
use std::str::FromStr;
let test_paths = vec![
let test_paths = [
"/test/wasmer-darwin-amd64.tar.gz",
"/test/wasmer-darwin-arm64.tar.gz",
"/test/wasmer-linux-aarch64.tar.gz",
Expand Down
30 changes: 28 additions & 2 deletions lib/cli/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,31 @@ pub async fn republish_package_with_bumped_version(
.context("could not load package info from backend")?
.and_then(|x| x.last_version);

let new_version = if let Some(current) = current_opt {
let new_version = if let Some(current) = &current_opt {
let mut v = semver::Version::parse(&current.version)
.with_context(|| format!("Could not parse package version: '{}'", current.version))?;

v.patch += 1;

// The backend does not have a reliable way to return the latest version,
// so we have to check each version in a loop.
loop {
let version = format!("={}", v);
let version = wasmer_api::query::get_package_version(
client,
manifest.package.name.clone(),
version.clone(),
)
.await
.context("could not load package info from backend")?;

if version.is_some() {
v.patch += 1;
} else {
break;
}
}

v
} else {
manifest.package.version
Expand Down Expand Up @@ -246,7 +266,13 @@ pub async fn republish_package_with_bumped_version(
// large packages.
timeout: std::time::Duration::from_secs(60 * 60 * 12),
};
publish.execute()?;

// Publish uses a blocking http client internally, which leads to a
// "can't drop a runtime within an async context" error, so this has
// to be run in a separate thread.
std::thread::spawn(move || publish.execute())
.join()
.map_err(|e| anyhow::format_err!("failed to publish package: {:?}", e))??;
maminrayej marked this conversation as resolved.
Show resolved Hide resolved

Ok(manifest)
}
Expand Down
Loading