Skip to content

Commit

Permalink
remove versions from ids
Browse files Browse the repository at this point in the history
This makes it possible to link the latest build with a static url on github.

fixes #184
  • Loading branch information
Gankra committed May 3, 2023
1 parent a4e588e commit 8a417f2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 25 deletions.
13 changes: 11 additions & 2 deletions cargo-dist/src/ci.rs
Expand Up @@ -195,6 +195,9 @@ const SELF_DIST_VERSION: &str = env!("CARGO_PKG_VERSION");
/// The first epoch of cargo-dist, after this version a bunch of things changed
/// and we don't support generating CI for that design anymore!
const DIST_EPOCH_1: &str = "0.0.2";
/// Second epoch of cargo-dist, after this we stopped putting versions in artifact ids.
/// This changes the download URL, but everything else works the same.
const DIST_EPOCH_2: &str = "0.0.5";
/// The base URL to fetch cargo-dist artifacts from (tag gets appended)
const BASE_DIST_FETCH_URL: &str = "https://github.com/axodotdev/cargo-dist/releases/download";

Expand All @@ -204,7 +207,10 @@ fn install_dist_sh_for_version(version: &Version) -> String {
return git;
}
let epoch1 = Version::parse(DIST_EPOCH_1).unwrap();
let installer_name = if version > &epoch1 {
let epoch2 = Version::parse(DIST_EPOCH_2).unwrap();
let installer_name = if version > &epoch2 {
"cargo-dist-installer.sh".to_owned()
} else if version > &epoch1 {
format!("cargo-dist-v{version}-installer.sh")
} else {
// FIXME: we should probably do this check way higher up and produce a proper err...
Expand All @@ -223,7 +229,10 @@ fn install_dist_ps1_for_version(version: &Version) -> String {
return git;
}
let epoch1 = Version::parse(DIST_EPOCH_1).unwrap();
let installer_name = if version > &epoch1 {
let epoch2 = Version::parse(DIST_EPOCH_2).unwrap();
let installer_name = if version > &epoch2 {
"cargo-dist-installer.ps1".to_owned()
} else if version > &epoch1 {
format!("cargo-dist-v{version}-installer.ps1")
} else {
// FIXME: we should probably do this check way higher up and produce a proper err...
Expand Down
6 changes: 3 additions & 3 deletions cargo-dist/src/tasks.rs
Expand Up @@ -960,7 +960,7 @@ impl<'pkg_graph> DistGraphBuilder<'pkg_graph> {
}

let idx = ReleaseIdx(self.inner.releases.len());
let id = format!("{app_name}-v{version}");
let id = app_name.clone();
info!("added release {id}");
self.inner.releases.push(Release {
app_name,
Expand Down Expand Up @@ -1207,7 +1207,7 @@ impl<'pkg_graph> DistGraphBuilder<'pkg_graph> {
let artifact_name = format!("{release_id}-installer.sh");
let artifact_path = self.inner.dist_dir.join(&artifact_name);
let installer_url = format!("{download_url}/{artifact_name}");
let hint = format!("# WARNING: this installer is experimental\ncurl --proto '=https' --tlsv1.2 -LsSf {installer_url} | sh");
let hint = format!("curl --proto '=https' --tlsv1.2 -LsSf {installer_url} | sh");
let desc = "Install prebuilt binaries via shell script".to_owned();

// Gather up the bundles the installer supports
Expand Down Expand Up @@ -1275,7 +1275,7 @@ impl<'pkg_graph> DistGraphBuilder<'pkg_graph> {
let artifact_name = format!("{release_id}-installer.ps1");
let artifact_path = self.inner.dist_dir.join(&artifact_name);
let installer_url = format!("{download_url}/{artifact_name}");
let hint = format!("# WARNING: this installer is experimental\nirm {installer_url} | iex");
let hint = format!("irm {installer_url} | iex");
let desc = "Install prebuilt binaries via powershell script".to_owned();

// Gather up the bundles the installer supports
Expand Down
40 changes: 20 additions & 20 deletions cargo-dist/tests/snapshots/cli_tests__manifest.snap
Expand Up @@ -15,18 +15,18 @@ stdout:
"app_name": "cargo-dist",
"app_version": "1.0.0-FAKEVERSION",
"artifacts": [
"cargo-dist-v1.0.0-FAKEVERSION-installer.sh",
"cargo-dist-v1.0.0-FAKEVERSION-installer.ps1",
"cargo-dist-v1.0.0-FAKEVERSION-aarch64-apple-darwin.tar.xz",
"cargo-dist-v1.0.0-FAKEVERSION-x86_64-apple-darwin.tar.xz",
"cargo-dist-v1.0.0-FAKEVERSION-x86_64-pc-windows-msvc.zip",
"cargo-dist-v1.0.0-FAKEVERSION-x86_64-unknown-linux-gnu.tar.xz"
"cargo-dist-installer.sh",
"cargo-dist-installer.ps1",
"cargo-dist-aarch64-apple-darwin.tar.xz",
"cargo-dist-x86_64-apple-darwin.tar.xz",
"cargo-dist-x86_64-pc-windows-msvc.zip",
"cargo-dist-x86_64-unknown-linux-gnu.tar.xz"
]
}
],
"artifacts": {
"cargo-dist-v1.0.0-FAKEVERSION-aarch64-apple-darwin.tar.xz": {
"name": "cargo-dist-v1.0.0-FAKEVERSION-aarch64-apple-darwin.tar.xz",
"cargo-dist-aarch64-apple-darwin.tar.xz": {
"name": "cargo-dist-aarch64-apple-darwin.tar.xz",
"kind": "executable-zip",
"target_triples": [
"aarch64-apple-darwin"
Expand Down Expand Up @@ -59,28 +59,28 @@ stdout:
}
]
},
"cargo-dist-v1.0.0-FAKEVERSION-installer.ps1": {
"name": "cargo-dist-v1.0.0-FAKEVERSION-installer.ps1",
"cargo-dist-installer.ps1": {
"name": "cargo-dist-installer.ps1",
"kind": "installer",
"target_triples": [
"x86_64-pc-windows-msvc"
],
"install_hint": "# WARNING: this installer is experimental\nirm https://github.com/axodotdev/cargo-dist/releases/download/v1.0.0-FAKEVERSION/cargo-dist-v1.0.0-FAKEVERSION-installer.ps1 | iex",
"install_hint": "irm https://github.com/axodotdev/cargo-dist/releases/download/v1.0.0-FAKEVERSION/cargo-dist-installer.ps1 | iex",
"description": "Install prebuilt binaries via powershell script"
},
"cargo-dist-v1.0.0-FAKEVERSION-installer.sh": {
"name": "cargo-dist-v1.0.0-FAKEVERSION-installer.sh",
"cargo-dist-installer.sh": {
"name": "cargo-dist-installer.sh",
"kind": "installer",
"target_triples": [
"aarch64-apple-darwin",
"x86_64-apple-darwin",
"x86_64-unknown-linux-gnu"
],
"install_hint": "# WARNING: this installer is experimental\ncurl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v1.0.0-FAKEVERSION/cargo-dist-v1.0.0-FAKEVERSION-installer.sh | sh",
"install_hint": "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v1.0.0-FAKEVERSION/cargo-dist-installer.sh | sh",
"description": "Install prebuilt binaries via shell script"
},
"cargo-dist-v1.0.0-FAKEVERSION-x86_64-apple-darwin.tar.xz": {
"name": "cargo-dist-v1.0.0-FAKEVERSION-x86_64-apple-darwin.tar.xz",
"cargo-dist-x86_64-apple-darwin.tar.xz": {
"name": "cargo-dist-x86_64-apple-darwin.tar.xz",
"kind": "executable-zip",
"target_triples": [
"x86_64-apple-darwin"
Expand Down Expand Up @@ -113,8 +113,8 @@ stdout:
}
]
},
"cargo-dist-v1.0.0-FAKEVERSION-x86_64-pc-windows-msvc.zip": {
"name": "cargo-dist-v1.0.0-FAKEVERSION-x86_64-pc-windows-msvc.zip",
"cargo-dist-x86_64-pc-windows-msvc.zip": {
"name": "cargo-dist-x86_64-pc-windows-msvc.zip",
"kind": "executable-zip",
"target_triples": [
"x86_64-pc-windows-msvc"
Expand Down Expand Up @@ -147,8 +147,8 @@ stdout:
}
]
},
"cargo-dist-v1.0.0-FAKEVERSION-x86_64-unknown-linux-gnu.tar.xz": {
"name": "cargo-dist-v1.0.0-FAKEVERSION-x86_64-unknown-linux-gnu.tar.xz",
"cargo-dist-x86_64-unknown-linux-gnu.tar.xz": {
"name": "cargo-dist-x86_64-unknown-linux-gnu.tar.xz",
"kind": "executable-zip",
"target_triples": [
"x86_64-unknown-linux-gnu"
Expand Down

0 comments on commit 8a417f2

Please sign in to comment.