diff --git a/book/src/reference/config.md b/book/src/reference/config.md index 0642461a2..51217ba6b 100644 --- a/book/src/reference/config.md +++ b/book/src/reference/config.md @@ -615,6 +615,15 @@ The syntax must be a valid rustup toolchain like "1.60.0" or "stable" (should no If you delete the key, generate won't explicitly setup a toolchain, so whatever's on the machine will be used (with things like rust-toolchain.toml behaving as normal). Before being deprecated the default was to `rustup update stable`, but this is no longer the case. +### tag-namespace + +> since 0.10.0 + +Example: `tag-namespace = "some-prefix"` + +Setting `tag-name = "owo"` will change the tag matching expression we put in your github ci, to require the tag to start with "owo" for cargo-dist to care about it. This can be useful for situations where you have several things with different tag/release workflows in the same workspace. It also renames `release.yaml` to `owo-release.yml` to make it clear it's just one of many release workflows. + + ### tap > since 0.2.0 diff --git a/cargo-dist/src/backend/ci/github.rs b/cargo-dist/src/backend/ci/github.rs index 980a3a4dd..7cb2168b5 100644 --- a/cargo-dist/src/backend/ci/github.rs +++ b/cargo-dist/src/backend/ci/github.rs @@ -62,6 +62,8 @@ pub struct GithubCiInfo { pub ssldotcom_windows_sign: Option, /// what hosting provider we're using pub hosting_providers: Vec, + /// whether to prefix release.yml and the tag pattern + pub tag_namespace: Option, } impl GithubCiInfo { @@ -81,6 +83,7 @@ impl GithubCiInfo { let dispatch_releases = dist.dispatch_releases; let create_release = dist.create_release; let ssldotcom_windows_sign = dist.ssldotcom_windows_sign.clone(); + let tag_namespace = dist.tag_namespace.clone(); let mut dependencies = SystemDependencies::default(); // Figure out what builds we need to do @@ -153,6 +156,7 @@ impl GithubCiInfo { } GithubCiInfo { + tag_namespace, rust_version, install_dist_sh, install_dist_ps1, @@ -178,7 +182,14 @@ impl GithubCiInfo { fn github_ci_path(&self, dist: &DistGraph) -> camino::Utf8PathBuf { let ci_dir = dist.workspace_dir.join(GITHUB_CI_DIR); - ci_dir.join(GITHUB_CI_FILE) + // If tag-namespace is set, apply the prefix to the filename to emphasize it's + // just one of many workflows in this project + let prefix = self + .tag_namespace + .as_deref() + .map(|p| format!("{p}-")) + .unwrap_or_default(); + ci_dir.join(format!("{prefix}{GITHUB_CI_FILE}")) } /// Generate the requested configuration and returns it as a string. diff --git a/cargo-dist/src/config.rs b/cargo-dist/src/config.rs index 932f13285..f8fec31ea 100644 --- a/cargo-dist/src/config.rs +++ b/cargo-dist/src/config.rs @@ -326,6 +326,11 @@ pub struct DistMetadata { /// Custom GitHub runners, mapped by triple target #[serde(skip_serializing_if = "Option::is_none")] pub github_custom_runners: Option>, + + /// a prefix to add to the release.yml and tag pattern so that + /// cargo-dist can co-exist with other release workflows in complex workspaces + #[serde(skip_serializing_if = "Option::is_none")] + pub tag_namespace: Option, } impl DistMetadata { @@ -371,6 +376,7 @@ impl DistMetadata { hosting: _, extra_artifacts: _, github_custom_runners: _, + tag_namespace: _, } = self; if let Some(include) = include { for include in include { @@ -425,6 +431,7 @@ impl DistMetadata { hosting, extra_artifacts, github_custom_runners, + tag_namespace, } = self; // Check for global settings on local packages @@ -493,6 +500,9 @@ impl DistMetadata { if post_announce_jobs.is_some() { warn!("package.metadata.dist.post-announce-jobs is set, but this is only accepted in workspace.metadata (value is being ignored): {}", package_manifest_path); } + if tag_namespace.is_some() { + warn!("package.metadata.dist.tag-namespace is set, but this is only accepted in workspace.metadata (value is being ignored): {}", package_manifest_path); + } // Merge non-global settings if installers.is_none() { diff --git a/cargo-dist/src/init.rs b/cargo-dist/src/init.rs index 51820b81c..23c5c3244 100644 --- a/cargo-dist/src/init.rs +++ b/cargo-dist/src/init.rs @@ -262,6 +262,7 @@ fn get_new_dist_metadata( hosting: None, extra_artifacts: None, github_custom_runners: None, + tag_namespace: None, } }; @@ -792,6 +793,7 @@ fn apply_dist_to_metadata(metadata: &mut toml_edit::Item, meta: &DistMetadata) { ssldotcom_windows_sign, msvc_crt_static, hosting, + tag_namespace, extra_artifacts: _, github_custom_runners: _, } = &meta; @@ -1036,6 +1038,13 @@ fn apply_dist_to_metadata(metadata: &mut toml_edit::Item, meta: &DistMetadata) { hosting.as_ref(), ); + apply_optional_value( + table, + "tag-namespace", + "# A prefix git tags must include for cargo-dist to care about them\n", + tag_namespace.as_ref(), + ); + // Finalize the table table .decor_mut() diff --git a/cargo-dist/src/tasks.rs b/cargo-dist/src/tasks.rs index ca777b5be..748038293 100644 --- a/cargo-dist/src/tasks.rs +++ b/cargo-dist/src/tasks.rs @@ -218,6 +218,8 @@ pub struct DistGraph { pub github_custom_runners: HashMap, /// LIES ALL LIES pub local_builds_are_lies: bool, + /// Prefix git tags must include to be picked up (also renames release.yml) + pub tag_namespace: Option, } /// Info about artifacts should be hosted @@ -713,6 +715,7 @@ impl<'pkg_graph> DistGraphBuilder<'pkg_graph> { build_local_artifacts, dispatch_releases, ssldotcom_windows_sign, + tag_namespace, // Partially Processed elsewhere // // FIXME?: this is the last vestige of us actually needing to keep workspace_metadata @@ -785,6 +788,7 @@ impl<'pkg_graph> DistGraphBuilder<'pkg_graph> { let msvc_crt_static = msvc_crt_static.unwrap_or(true); let local_builds_are_lies = artifact_mode == ArtifactMode::Lies; let ssldotcom_windows_sign = ssldotcom_windows_sign.clone(); + let tag_namespace = tag_namespace.clone(); let mut packages_with_mismatched_features = vec![]; // Compute/merge package configs @@ -944,6 +948,7 @@ impl<'pkg_graph> DistGraphBuilder<'pkg_graph> { ssldotcom_windows_sign, desired_cargo_dist_version, desired_rust_toolchain, + tag_namespace, tools, local_builds_are_lies, templates, diff --git a/cargo-dist/templates/ci/github_ci.yml.j2 b/cargo-dist/templates/ci/github_ci.yml.j2 index 60694ec4b..941ef4240 100644 --- a/cargo-dist/templates/ci/github_ci.yml.j2 +++ b/cargo-dist/templates/ci/github_ci.yml.j2 @@ -66,7 +66,7 @@ on: {{%- else %}} push: tags: - - '**[0-9]+.[0-9]+.[0-9]+*' + - '{{%- if tag_namespace %}}{{{ tag_namespace | safe }}}{{%- endif %}}**[0-9]+.[0-9]+.[0-9]+*' {{%- endif %}} {{%- if pr_run_mode != "skip" %}} pull_request: diff --git a/cargo-dist/tests/gallery/dist.rs b/cargo-dist/tests/gallery/dist.rs index 38cd3be44..cc17e0970 100644 --- a/cargo-dist/tests/gallery/dist.rs +++ b/cargo-dist/tests/gallery/dist.rs @@ -172,7 +172,17 @@ impl<'a> TestContext<'a, Tools> { } /// Run 'cargo dist generate' and return paths to various files that were generated pub fn cargo_dist_generate(&self, test_name: &str) -> Result { - let github_ci_path = Utf8Path::new(".github/workflows/release.yml").to_owned(); + self.cargo_dist_generate_prefixed(test_name, "") + } + /// Run 'cargo dist generate' and return paths to various files that were generated + /// (also apply a prefix to the github filename) + pub fn cargo_dist_generate_prefixed( + &self, + test_name: &str, + prefix: &str, + ) -> Result { + let ci_file_name = format!("{prefix}release.yml"); + let github_ci_path = Utf8Path::new(".github/workflows/").join(ci_file_name); let wxs_path = Utf8Path::new("wix/main.wxs").to_owned(); // Delete files if they already exist if github_ci_path.exists() { @@ -582,9 +592,13 @@ impl GenerateResult { // in one test (necessitating rerunning it multiple times or passing special flags to get all the changes) let mut snapshots = String::new(); + eprintln!("{:?}", self.github_ci_path); append_snapshot_file( &mut snapshots, - "github-ci.yml", + self.github_ci_path + .as_deref() + .and_then(|p| p.file_name()) + .unwrap_or_default(), self.github_ci_path.as_deref(), )?; diff --git a/cargo-dist/tests/integration-tests.rs b/cargo-dist/tests/integration-tests.rs index 4a2b97c87..dff7946d0 100644 --- a/cargo-dist/tests/integration-tests.rs +++ b/cargo-dist/tests/integration-tests.rs @@ -152,7 +152,34 @@ dispatch-releases = true // Run generate to make sure stuff is up to date before running other commands let ci_result = ctx.cargo_dist_generate(test_name)?; let ci_snap = ci_result.check_all()?; - //rr Do usual build+plan checks + // Do usual build+plan checks + let main_result = ctx.cargo_dist_build_and_plan(test_name)?; + let main_snap = main_result.check_all(ctx, ".cargo/bin/")?; + // snapshot all + main_snap.join(ci_snap).snap(); + Ok(()) + }) +} + +#[test] +fn axolotlsay_tag_namespace() -> Result<(), miette::Report> { + let test_name = _function_name!(); + AXOLOTLSAY.run_test(|ctx| { + let dist_version = ctx.tools.cargo_dist.version().unwrap(); + ctx.patch_cargo_toml(format!(r#" +[workspace.metadata.dist] +cargo-dist-version = "{dist_version}" +installers = [] +targets = ["x86_64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "aarch64-apple-darwin"] +ci = ["github"] +tag-namespace = "owo" +"# + ))?; + + // Run generate to make sure stuff is up to date before running other commands + let ci_result = ctx.cargo_dist_generate_prefixed(test_name, "owo-")?; + let ci_snap = ci_result.check_all()?; + // Do usual build+plan checks let main_result = ctx.cargo_dist_build_and_plan(test_name)?; let main_snap = main_result.check_all(ctx, ".cargo/bin/")?; // snapshot all diff --git a/cargo-dist/tests/snapshots/akaikatana_basic.snap b/cargo-dist/tests/snapshots/akaikatana_basic.snap index 1fb3d8bc0..10101c35b 100644 --- a/cargo-dist/tests/snapshots/akaikatana_basic.snap +++ b/cargo-dist/tests/snapshots/akaikatana_basic.snap @@ -1454,7 +1454,7 @@ try { "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/akaikatana_musl.snap b/cargo-dist/tests/snapshots/akaikatana_musl.snap index 6cfd79273..48259c809 100644 --- a/cargo-dist/tests/snapshots/akaikatana_musl.snap +++ b/cargo-dist/tests/snapshots/akaikatana_musl.snap @@ -1085,7 +1085,7 @@ download_binary_and_run_installer "$@" || exit 1 "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/akaikatana_repo_with_dot_git.snap b/cargo-dist/tests/snapshots/akaikatana_repo_with_dot_git.snap index 1fb3d8bc0..10101c35b 100644 --- a/cargo-dist/tests/snapshots/akaikatana_repo_with_dot_git.snap +++ b/cargo-dist/tests/snapshots/akaikatana_repo_with_dot_git.snap @@ -1454,7 +1454,7 @@ try { "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_abyss.snap b/cargo-dist/tests/snapshots/axolotlsay_abyss.snap index a1dc4c70a..becea47b7 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_abyss.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_abyss.snap @@ -2386,7 +2386,7 @@ maybeInstall(true).then(run); "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_abyss_only.snap b/cargo-dist/tests/snapshots/axolotlsay_abyss_only.snap index 73b52366b..c2291b0ce 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_abyss_only.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_abyss_only.snap @@ -2382,7 +2382,7 @@ maybeInstall(true).then(run); "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_basic.snap b/cargo-dist/tests/snapshots/axolotlsay_basic.snap index 95cc42b38..91ccd6ed3 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_basic.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_basic.snap @@ -2378,7 +2378,7 @@ maybeInstall(true).then(run); "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_custom_github_runners.snap b/cargo-dist/tests/snapshots/axolotlsay_custom_github_runners.snap index 0a235b7a1..4ff4fafdb 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_custom_github_runners.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_custom_github_runners.snap @@ -263,7 +263,7 @@ expression: self.payload "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_dispatch.snap b/cargo-dist/tests/snapshots/axolotlsay_dispatch.snap index 56c1282e3..dfc8cc3b5 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_dispatch.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_dispatch.snap @@ -261,7 +261,7 @@ expression: self.payload "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_dispatch_abyss.snap b/cargo-dist/tests/snapshots/axolotlsay_dispatch_abyss.snap index dca0f5b43..6133d8688 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_dispatch_abyss.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_dispatch_abyss.snap @@ -269,7 +269,7 @@ expression: self.payload "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_dispatch_abyss_only.snap b/cargo-dist/tests/snapshots/axolotlsay_dispatch_abyss_only.snap index 331b52bd8..16c01e4c5 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_dispatch_abyss_only.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_dispatch_abyss_only.snap @@ -265,7 +265,7 @@ expression: self.payload "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_edit_existing.snap b/cargo-dist/tests/snapshots/axolotlsay_edit_existing.snap index 78cc3489b..da93806ec 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_edit_existing.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_edit_existing.snap @@ -2353,7 +2353,7 @@ maybeInstall(true).then(run); "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_musl.snap b/cargo-dist/tests/snapshots/axolotlsay_musl.snap index 670a40f39..39257a439 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_musl.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_musl.snap @@ -1988,7 +1988,7 @@ maybeInstall(true).then(run); "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_musl_no_gnu.snap b/cargo-dist/tests/snapshots/axolotlsay_musl_no_gnu.snap index bb4cec727..98c6051fd 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_musl_no_gnu.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_musl_no_gnu.snap @@ -1934,7 +1934,7 @@ maybeInstall(true).then(run); "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_no_homebrew_publish.snap b/cargo-dist/tests/snapshots/axolotlsay_no_homebrew_publish.snap index 765ef4cef..7b60c956d 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_no_homebrew_publish.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_no_homebrew_publish.snap @@ -2353,7 +2353,7 @@ maybeInstall(true).then(run); "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_no_locals.snap b/cargo-dist/tests/snapshots/axolotlsay_no_locals.snap index 06cc4d5bc..58e0d62e1 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_no_locals.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_no_locals.snap @@ -261,7 +261,7 @@ expression: self.payload "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_no_locals_but_custom.snap b/cargo-dist/tests/snapshots/axolotlsay_no_locals_but_custom.snap index b11f6404f..5e23c7d01 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_no_locals_but_custom.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_no_locals_but_custom.snap @@ -261,7 +261,7 @@ expression: self.payload "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_ssldotcom_windows_sign.snap b/cargo-dist/tests/snapshots/axolotlsay_ssldotcom_windows_sign.snap index b8b925b78..bbb058b34 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_ssldotcom_windows_sign.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_ssldotcom_windows_sign.snap @@ -1423,7 +1423,7 @@ try { "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_ssldotcom_windows_sign_prod.snap b/cargo-dist/tests/snapshots/axolotlsay_ssldotcom_windows_sign_prod.snap index 68a1b74ef..ad085d8be 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_ssldotcom_windows_sign_prod.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_ssldotcom_windows_sign_prod.snap @@ -1423,7 +1423,7 @@ try { "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_tag_namespace.snap b/cargo-dist/tests/snapshots/axolotlsay_tag_namespace.snap new file mode 100644 index 000000000..a737b00c6 --- /dev/null +++ b/cargo-dist/tests/snapshots/axolotlsay_tag_namespace.snap @@ -0,0 +1,531 @@ +--- +source: cargo-dist/tests/gallery/dist.rs +expression: self.payload +--- +================ dist-manifest.json ================ +{ + "dist_version": "CENSORED", + "announcement_tag": "v0.2.1", + "announcement_tag_is_implicit": true, + "announcement_is_prerelease": false, + "announcement_title": "Version 0.2.1", + "announcement_changelog": "```text\n +--------------------------------------+\n | now with linux static musl binary!!! |\n +--------------------------------------+\n /\n≽(◕ ᴗ ◕)≼\n```", + "announcement_github_body": "## Release Notes\n\n```text\n +--------------------------------------+\n | now with linux static musl binary!!! |\n +--------------------------------------+\n /\n≽(◕ ᴗ ◕)≼\n```\n\n## Download axolotlsay 0.2.1\n\n| File | Platform | Checksum |\n|--------|----------|----------|\n| [axolotlsay-aarch64-apple-darwin.tar.xz](https://github.com/axodotdev/axolotlsay/releases/download/v0.2.1/axolotlsay-aarch64-apple-darwin.tar.xz) | Apple Silicon macOS | [checksum](https://github.com/axodotdev/axolotlsay/releases/download/v0.2.1/axolotlsay-aarch64-apple-darwin.tar.xz.sha256) |\n| [axolotlsay-x86_64-apple-darwin.tar.xz](https://github.com/axodotdev/axolotlsay/releases/download/v0.2.1/axolotlsay-x86_64-apple-darwin.tar.xz) | Intel macOS | [checksum](https://github.com/axodotdev/axolotlsay/releases/download/v0.2.1/axolotlsay-x86_64-apple-darwin.tar.xz.sha256) |\n| [axolotlsay-x86_64-pc-windows-msvc.zip](https://github.com/axodotdev/axolotlsay/releases/download/v0.2.1/axolotlsay-x86_64-pc-windows-msvc.zip) | x64 Windows | [checksum](https://github.com/axodotdev/axolotlsay/releases/download/v0.2.1/axolotlsay-x86_64-pc-windows-msvc.zip.sha256) |\n| [axolotlsay-x86_64-unknown-linux-gnu.tar.xz](https://github.com/axodotdev/axolotlsay/releases/download/v0.2.1/axolotlsay-x86_64-unknown-linux-gnu.tar.xz) | x64 Linux | [checksum](https://github.com/axodotdev/axolotlsay/releases/download/v0.2.1/axolotlsay-x86_64-unknown-linux-gnu.tar.xz.sha256) |\n\n", + "system_info": { + "cargo_version_line": "CENSORED" + }, + "releases": [ + { + "app_name": "axolotlsay", + "app_version": "0.2.1", + "artifacts": [ + "source.tar.gz", + "source.tar.gz.sha256", + "axolotlsay-aarch64-apple-darwin.tar.xz", + "axolotlsay-aarch64-apple-darwin.tar.xz.sha256", + "axolotlsay-x86_64-apple-darwin.tar.xz", + "axolotlsay-x86_64-apple-darwin.tar.xz.sha256", + "axolotlsay-x86_64-pc-windows-msvc.zip", + "axolotlsay-x86_64-pc-windows-msvc.zip.sha256", + "axolotlsay-x86_64-unknown-linux-gnu.tar.xz", + "axolotlsay-x86_64-unknown-linux-gnu.tar.xz.sha256" + ], + "hosting": { + "github": { + "artifact_download_url": "https://github.com/axodotdev/axolotlsay/releases/download/v0.2.1" + } + } + } + ], + "artifacts": { + "axolotlsay-aarch64-apple-darwin.tar.xz": { + "name": "axolotlsay-aarch64-apple-darwin.tar.xz", + "kind": "executable-zip", + "target_triples": [ + "aarch64-apple-darwin" + ], + "assets": [ + { + "name": "CHANGELOG.md", + "path": "CHANGELOG.md", + "kind": "changelog" + }, + { + "name": "LICENSE-APACHE", + "path": "LICENSE-APACHE", + "kind": "license" + }, + { + "name": "LICENSE-MIT", + "path": "LICENSE-MIT", + "kind": "license" + }, + { + "name": "README.md", + "path": "README.md", + "kind": "readme" + }, + { + "name": "axolotlsay", + "path": "axolotlsay", + "kind": "executable" + } + ], + "checksum": "axolotlsay-aarch64-apple-darwin.tar.xz.sha256" + }, + "axolotlsay-aarch64-apple-darwin.tar.xz.sha256": { + "name": "axolotlsay-aarch64-apple-darwin.tar.xz.sha256", + "kind": "checksum", + "target_triples": [ + "aarch64-apple-darwin" + ] + }, + "axolotlsay-x86_64-apple-darwin.tar.xz": { + "name": "axolotlsay-x86_64-apple-darwin.tar.xz", + "kind": "executable-zip", + "target_triples": [ + "x86_64-apple-darwin" + ], + "assets": [ + { + "name": "CHANGELOG.md", + "path": "CHANGELOG.md", + "kind": "changelog" + }, + { + "name": "LICENSE-APACHE", + "path": "LICENSE-APACHE", + "kind": "license" + }, + { + "name": "LICENSE-MIT", + "path": "LICENSE-MIT", + "kind": "license" + }, + { + "name": "README.md", + "path": "README.md", + "kind": "readme" + }, + { + "name": "axolotlsay", + "path": "axolotlsay", + "kind": "executable" + } + ], + "checksum": "axolotlsay-x86_64-apple-darwin.tar.xz.sha256" + }, + "axolotlsay-x86_64-apple-darwin.tar.xz.sha256": { + "name": "axolotlsay-x86_64-apple-darwin.tar.xz.sha256", + "kind": "checksum", + "target_triples": [ + "x86_64-apple-darwin" + ] + }, + "axolotlsay-x86_64-pc-windows-msvc.zip": { + "name": "axolotlsay-x86_64-pc-windows-msvc.zip", + "kind": "executable-zip", + "target_triples": [ + "x86_64-pc-windows-msvc" + ], + "assets": [ + { + "name": "CHANGELOG.md", + "path": "CHANGELOG.md", + "kind": "changelog" + }, + { + "name": "LICENSE-APACHE", + "path": "LICENSE-APACHE", + "kind": "license" + }, + { + "name": "LICENSE-MIT", + "path": "LICENSE-MIT", + "kind": "license" + }, + { + "name": "README.md", + "path": "README.md", + "kind": "readme" + }, + { + "name": "axolotlsay", + "path": "axolotlsay.exe", + "kind": "executable" + } + ], + "checksum": "axolotlsay-x86_64-pc-windows-msvc.zip.sha256" + }, + "axolotlsay-x86_64-pc-windows-msvc.zip.sha256": { + "name": "axolotlsay-x86_64-pc-windows-msvc.zip.sha256", + "kind": "checksum", + "target_triples": [ + "x86_64-pc-windows-msvc" + ] + }, + "axolotlsay-x86_64-unknown-linux-gnu.tar.xz": { + "name": "axolotlsay-x86_64-unknown-linux-gnu.tar.xz", + "kind": "executable-zip", + "target_triples": [ + "x86_64-unknown-linux-gnu" + ], + "assets": [ + { + "name": "CHANGELOG.md", + "path": "CHANGELOG.md", + "kind": "changelog" + }, + { + "name": "LICENSE-APACHE", + "path": "LICENSE-APACHE", + "kind": "license" + }, + { + "name": "LICENSE-MIT", + "path": "LICENSE-MIT", + "kind": "license" + }, + { + "name": "README.md", + "path": "README.md", + "kind": "readme" + }, + { + "name": "axolotlsay", + "path": "axolotlsay", + "kind": "executable" + } + ], + "checksum": "axolotlsay-x86_64-unknown-linux-gnu.tar.xz.sha256" + }, + "axolotlsay-x86_64-unknown-linux-gnu.tar.xz.sha256": { + "name": "axolotlsay-x86_64-unknown-linux-gnu.tar.xz.sha256", + "kind": "checksum", + "target_triples": [ + "x86_64-unknown-linux-gnu" + ] + }, + "source.tar.gz": { + "name": "source.tar.gz", + "kind": "source-tarball", + "checksum": "source.tar.gz.sha256" + }, + "source.tar.gz.sha256": { + "name": "source.tar.gz.sha256", + "kind": "checksum" + } + }, + "publish_prereleases": false, + "ci": { + "github": { + "artifacts_matrix": { + "include": [ + { + "targets": [ + "aarch64-apple-darwin" + ], + "runner": "macos-12", + "install_dist": "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/vSOME_VERSION/cargo-dist-installer.sh | sh", + "dist_args": "--artifacts=local --target=aarch64-apple-darwin" + }, + { + "targets": [ + "x86_64-apple-darwin" + ], + "runner": "macos-12", + "install_dist": "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/vSOME_VERSION/cargo-dist-installer.sh | sh", + "dist_args": "--artifacts=local --target=x86_64-apple-darwin" + }, + { + "targets": [ + "x86_64-pc-windows-msvc" + ], + "runner": "windows-2019", + "install_dist": "irm https://github.com/axodotdev/cargo-dist/releases/download/vSOME_VERSION/cargo-dist-installer.ps1 | iex", + "dist_args": "--artifacts=local --target=x86_64-pc-windows-msvc" + }, + { + "targets": [ + "x86_64-unknown-linux-gnu" + ], + "runner": "ubuntu-20.04", + "install_dist": "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/vSOME_VERSION/cargo-dist-installer.sh | sh", + "dist_args": "--artifacts=local --target=x86_64-unknown-linux-gnu" + } + ] + }, + "pr_run_mode": "plan" + } + }, + "linkage": [] +} + +================ owo-release.yml ================ +# Copyright 2022-2023, axodotdev +# SPDX-License-Identifier: MIT or Apache-2.0 +# +# CI that: +# +# * checks for a Git Tag that looks like a release +# * builds artifacts with cargo-dist (archives, installers, hashes) +# * uploads those artifacts to temporary workflow zip +# * on success, uploads the artifacts to a Github Release +# +# Note that the Github Release will be created with a generated +# title/body based on your changelogs. + +name: Release + +permissions: + contents: write + +# This task will run whenever you push a git tag that looks like a version +# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc. +# Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where +# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION +# must be a Cargo-style SemVer Version (must have at least major.minor.patch). +# +# If PACKAGE_NAME is specified, then the announcement will be for that +# package (erroring out if it doesn't have the given version or isn't cargo-dist-able). +# +# If PACKAGE_NAME isn't specified, then the announcement will be for all +# (cargo-dist-able) packages in the workspace with that version (this mode is +# intended for workspaces with only one dist-able package, or with all dist-able +# packages versioned/released in lockstep). +# +# If you push multiple tags at once, separate instances of this workflow will +# spin up, creating an independent announcement for each one. However Github +# will hard limit this to 3 tags per commit, as it will assume more tags is a +# mistake. +# +# If there's a prerelease-style suffix to the version, then the release(s) +# will be marked as a prerelease. +on: + push: + tags: + - 'owo**[0-9]+.[0-9]+.[0-9]+*' + pull_request: + +jobs: + # Run 'cargo dist plan' (or host) to determine what tasks we need to do + plan: + runs-on: ubuntu-latest + outputs: + val: ${{ steps.plan.outputs.manifest }} + tag: ${{ !github.event.pull_request && github.ref_name || '' }} + tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }} + publishing: ${{ !github.event.pull_request }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Install cargo-dist + # we specify bash to get pipefail; it guards against the `curl` command + # failing. otherwise `sh` won't catch that `curl` returned non-0 + shell: bash + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/vSOME_VERSION/cargo-dist-installer.sh | sh" + # sure would be cool if github gave us proper conditionals... + # so here's a doubly-nested ternary-via-truthiness to try to provide the best possible + # functionality based on whether this is a pull_request, and whether it's from a fork. + # (PRs run on the *source* but secrets are usually on the *target* -- that's *good* + # but also really annoying to build CI around when it needs secrets to work right.) + - id: plan + run: | + cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json + echo "cargo dist ran successfully" + cat plan-dist-manifest.json + echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT" + - name: "Upload dist-manifest.json" + uses: actions/upload-artifact@v4 + with: + name: artifacts-plan-dist-manifest + path: plan-dist-manifest.json + + # Build and packages all the platform-specific things + build-local-artifacts: + name: build-local-artifacts (${{ join(matrix.targets, ', ') }}) + # Let the initial task tell us to not run (currently very blunt) + needs: + - plan + if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }} + strategy: + fail-fast: false + # Target platforms/runners are computed by cargo-dist in create-release. + # Each member of the matrix has the following arguments: + # + # - runner: the github runner + # - dist-args: cli flags to pass to cargo dist + # - install-dist: expression to run to install cargo-dist on the runner + # + # Typically there will be: + # - 1 "global" task that builds universal installers + # - N "local" tasks that build each platform's binaries and platform-specific installers + matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }} + runs-on: ${{ matrix.runner }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: swatinem/rust-cache@v2 + - name: Install cargo-dist + run: ${{ matrix.install_dist }} + # Get the dist-manifest + - name: Fetch local artifacts + uses: actions/download-artifact@v4 + with: + pattern: artifacts-* + path: target/distrib/ + merge-multiple: true + - name: Install dependencies + run: | + ${{ matrix.packages_install }} + - name: Build artifacts + run: | + # Actually do builds and make zips and whatnot + cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json + echo "cargo dist ran successfully" + - id: cargo-dist + name: Post-build + # We force bash here just because github makes it really hard to get values up + # to "real" actions without writing to env-vars, and writing to env-vars has + # inconsistent syntax between shell and powershell. + shell: bash + run: | + # Parse out what we just built and upload it to scratch storage + echo "paths<> "$GITHUB_OUTPUT" + jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" + + cp dist-manifest.json "$BUILD_MANIFEST_NAME" + - name: "Upload artifacts" + uses: actions/upload-artifact@v4 + with: + name: artifacts-build-local-${{ join(matrix.targets, '_') }} + path: | + ${{ steps.cargo-dist.outputs.paths }} + ${{ env.BUILD_MANIFEST_NAME }} + + # Build and package all the platform-agnostic(ish) things + build-global-artifacts: + needs: + - plan + - build-local-artifacts + runs-on: "ubuntu-20.04" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Install cargo-dist + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/vSOME_VERSION/cargo-dist-installer.sh | sh" + # Get all the local artifacts for the global tasks to use (for e.g. checksums) + - name: Fetch local artifacts + uses: actions/download-artifact@v4 + with: + pattern: artifacts-* + path: target/distrib/ + merge-multiple: true + - id: cargo-dist + shell: bash + run: | + cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json + echo "cargo dist ran successfully" + + # Parse out what we just built and upload it to scratch storage + echo "paths<> "$GITHUB_OUTPUT" + jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" + + cp dist-manifest.json "$BUILD_MANIFEST_NAME" + - name: "Upload artifacts" + uses: actions/upload-artifact@v4 + with: + name: artifacts-build-global + path: | + ${{ steps.cargo-dist.outputs.paths }} + ${{ env.BUILD_MANIFEST_NAME }} + # Determines if we should publish/announce + host: + needs: + - plan + - build-local-artifacts + - build-global-artifacts + # Only run if we're "publishing", and only if local and global didn't fail (skipped is fine) + if: ${{ always() && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + runs-on: "ubuntu-20.04" + outputs: + val: ${{ steps.host.outputs.manifest }} + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Install cargo-dist + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/vSOME_VERSION/cargo-dist-installer.sh | sh" + # Fetch artifacts from scratch-storage + - name: Fetch artifacts + uses: actions/download-artifact@v4 + with: + pattern: artifacts-* + path: target/distrib/ + merge-multiple: true + # This is a harmless no-op for Github Releases, hosting for that happens in "announce" + - id: host + shell: bash + run: | + cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json + echo "artifacts uploaded and released successfully" + cat dist-manifest.json + echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT" + - name: "Upload dist-manifest.json" + uses: actions/upload-artifact@v4 + with: + # Overwrite the previous copy + name: artifacts-dist-manifest + path: dist-manifest.json + + # Create a Github Release while uploading all files to it + announce: + needs: + - plan + - host + # use "always() && ..." to allow us to wait for all publish jobs while + # still allowing individual publish jobs to skip themselves (for prereleases). + # "host" however must run to completion, no skipping allowed! + if: ${{ always() && needs.host.result == 'success' }} + runs-on: "ubuntu-20.04" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: "Download Github Artifacts" + uses: actions/download-artifact@v4 + with: + pattern: artifacts-* + path: artifacts + merge-multiple: true + - name: Cleanup + run: | + # Remove the granular manifests + rm -f artifacts/*-dist-manifest.json + - name: Create Github Release + uses: ncipollo/release-action@v1 + with: + tag: ${{ needs.plan.outputs.tag }} + name: ${{ fromJson(needs.host.outputs.val).announcement_title }} + body: ${{ fromJson(needs.host.outputs.val).announcement_github_body }} + prerelease: ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }} + artifacts: "artifacts/*" + + diff --git a/cargo-dist/tests/snapshots/axolotlsay_user_global_build_job.snap b/cargo-dist/tests/snapshots/axolotlsay_user_global_build_job.snap index 6c234b9df..da5818835 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_user_global_build_job.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_user_global_build_job.snap @@ -2353,7 +2353,7 @@ maybeInstall(true).then(run); "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_user_host_job.snap b/cargo-dist/tests/snapshots/axolotlsay_user_host_job.snap index 1bc39f1d9..c2327abb9 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_user_host_job.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_user_host_job.snap @@ -2353,7 +2353,7 @@ maybeInstall(true).then(run); "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_user_local_build_job.snap b/cargo-dist/tests/snapshots/axolotlsay_user_local_build_job.snap index b899dffa2..a791ac904 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_user_local_build_job.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_user_local_build_job.snap @@ -2353,7 +2353,7 @@ maybeInstall(true).then(run); "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_user_plan_job.snap b/cargo-dist/tests/snapshots/axolotlsay_user_plan_job.snap index c034ff3c5..7dfab8912 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_user_plan_job.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_user_plan_job.snap @@ -2353,7 +2353,7 @@ maybeInstall(true).then(run); "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # diff --git a/cargo-dist/tests/snapshots/axolotlsay_user_publish_job.snap b/cargo-dist/tests/snapshots/axolotlsay_user_publish_job.snap index 7e21d56da..078deedac 100644 --- a/cargo-dist/tests/snapshots/axolotlsay_user_publish_job.snap +++ b/cargo-dist/tests/snapshots/axolotlsay_user_publish_job.snap @@ -2353,7 +2353,7 @@ maybeInstall(true).then(run); "linkage": [] } -================ github-ci.yml ================ +================ release.yml ================ # Copyright 2022-2023, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 #