Skip to content

Commit

Permalink
feat: support new release asset name for aiken versions
Browse files Browse the repository at this point in the history
  • Loading branch information
rvcas committed May 7, 2024
1 parent 19ce335 commit 344f06a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 16 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ indoc = "2.0.5"
miette = { version = "7.2.0", features = ["fancy"] }
octocrab = "0.38.0"
once_cell = "1.19.0"
semver = "1.0.23"
tar = "0.4.40"
thiserror = "1.0.58"
tokio = { version = "1.37.0", features = ["full"] }
Expand Down
57 changes: 41 additions & 16 deletions src/cmd/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use tokio::fs::symlink_file as symlink;
use flate2::read::GzDecoder;
use http_body_util::BodyExt;
use miette::IntoDiagnostic;
use semver::Version;
use tar::Archive;

use crate::{
Expand Down Expand Up @@ -76,7 +77,7 @@ impl Args {
}
};

let asset_name = asset_name(&release.tag_name);
let asset_name = asset_name(&release.tag_name)?;

let search_result = release
.assets
Expand Down Expand Up @@ -171,19 +172,43 @@ pub async fn latest() -> miette::Result<()> {
Args::latest().exec().await
}

fn asset_name(tag_name: &str) -> String {
let os = match env::consts::OS {
"macos" => "darwin",
"windows" => "win32",
os => os,
};

let arch = match env::consts::ARCH {
"x86" => "amd64",
"x86_64" => "amd64",
"aarch64" => "arm64",
arch => arch,
};

format!("aiken_{}_{}_{}.tar.gz", tag_name, os, arch)
fn asset_name(tag_name: &str) -> miette::Result<String> {
let version = Version::parse(&tag_name.replace('v', "")).into_diagnostic()?;

let cut_off = Version::parse("1.0.26-alpha").into_diagnostic()?;

if version > cut_off {
let os = match env::consts::OS {
"macos" => "apple-darwin",
"windows" => "pc-windows-msvc",
"linux" => "unknown-linux-gnu",
os => os,
};

let arch = match env::consts::ARCH {
"x86" => "x86_64",
arch => arch,
};

let asset_name = format!("aiken-{}-{}.tar.gz", arch, os);

Ok(asset_name)
} else {
let os = match env::consts::OS {
"macos" => "darwin",
"windows" => "win32",
os => os,
};

let arch = match env::consts::ARCH {
"x86" => "amd64",
"x86_64" => "amd64",
"aarch64" => "arm64",
arch => arch,
};

let asset_name = format!("aiken_{}_{}_{}.tar.gz", tag_name, os, arch);

Ok(asset_name)
}
}

0 comments on commit 344f06a

Please sign in to comment.