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
12 changes: 8 additions & 4 deletions cargo-dist/src/backend/ci/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ pub enum DistInstallStrategy {
installer_url: String,
/// the installer name, without `.sh` or `.ps1`
installer_name: String,
/// the version to install, used for cargo install fallback
version: String,
},
/// Run `cargo install --git` (slow!)
GitBranch {
Expand All @@ -97,6 +99,7 @@ impl DistInstallSettings<'_> {
return DistInstallStrategy::Installer {
installer_url: url.as_str().to_owned(),
installer_name: "cargo-dist-installer".to_owned(),
version: self.version.to_string(),
};
}

Expand All @@ -116,6 +119,7 @@ impl DistInstallSettings<'_> {
// to compute these values for packages we build *BUT* it's messy and not that important
installer_url: format!("{BASE_DIST_FETCH_URL}/v{version}"),
installer_name,
version: version.to_string(),
}
}
}
Expand All @@ -124,8 +128,8 @@ impl InstallStrategy for DistInstallStrategy {
/// Returns a bit of sh/dash to install the requested version of dist
fn dash(&self) -> GhaRunStep {
DashScript::new(match self {
DistInstallStrategy::Installer { installer_url, installer_name } => format!(
"curl --proto '=https' --tlsv1.2 -LsSf {installer_url}/{installer_name}.sh | sh"
DistInstallStrategy::Installer { installer_url, installer_name, version } => format!(
"curl --proto '=https' --tlsv1.2 -LsSf {installer_url}/{installer_name}.sh | sh || cargo install cargo-dist --locked --version {version}"
),
DistInstallStrategy::GitBranch { branch } => format!(
"cargo install --git https://github.com/axodotdev/cargo-dist/ --branch={branch} --locked cargo-dist"
Expand All @@ -136,8 +140,8 @@ impl InstallStrategy for DistInstallStrategy {
/// Returns a bit of powershell to install the requested version of dist
fn powershell(&self) -> GhaRunStep {
PowershellScript::new(match self {
DistInstallStrategy::Installer { installer_url, installer_name } => format!(
"irm {installer_url}/{installer_name}.ps1 | iex"
DistInstallStrategy::Installer { installer_url, installer_name, version } => format!(
"try {{ irm {installer_url}/{installer_name}.ps1 | iex }} catch {{ cargo install cargo-dist --locked --version {version} }}"
),
DistInstallStrategy::GitBranch { branch } => format!(
"cargo install --git https://github.com/axodotdev/cargo-dist/ --branch={branch} --locked cargo-dist"
Expand Down
4 changes: 4 additions & 0 deletions cargo-dist/tests/gallery/dist/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ pub fn snapshot_settings_with_gallery_filter() -> insta::Settings {
r"cargo-dist/releases/download/v\d+\.\d+\.\d+(\-prerelease\d*)?(\.\d+)?/",
"cargo-dist/releases/download/vSOME_VERSION/",
);
settings.add_filter(
r"cargo install cargo-dist --locked --version \d+\.\d+\.\d+(\-prerelease\d*)?(\.\d+)?",
"cargo install cargo-dist --locked --version SOME_VERSION",
);
settings.add_filter(r#"sha256 ".*""#, r#"sha256 "CENSORED""#);
settings.add_filter(r#""sha256": .*"#, r#""sha256": "CENSORED""#);
settings.add_filter(r#""sha512": .*"#, r#""sha512": "CENSORED""#);
Expand Down
10 changes: 5 additions & 5 deletions cargo-dist/tests/snapshots/akaikatana_basic.snap

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

10 changes: 5 additions & 5 deletions cargo-dist/tests/snapshots/akaikatana_bins.snap

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

10 changes: 5 additions & 5 deletions cargo-dist/tests/snapshots/akaikatana_musl.snap

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

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

Loading