diff --git a/Cargo.lock b/Cargo.lock index 72c29aa..facfd82 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -973,7 +973,7 @@ dependencies = [ [[package]] name = "rust_realease" -version = "0.1.1" +version = "0.1.2" dependencies = [ "clap", "directories", diff --git a/Cargo.toml b/Cargo.toml index 86b912e..b54c44d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rust_realease" -version = "0.1.1" +version = "0.1.2" edition = "2021" publish = false repository = "https://proxy.dandaedre.com/gitea/idle-org/rust_realease" diff --git a/Cross.toml b/Cross.toml index 74bf6a5..bead784 100644 --- a/Cross.toml +++ b/Cross.toml @@ -2,3 +2,12 @@ [build.env] passthrough = ["RUSTUP_TOOLCHAIN"] + +[target.x86_64-unknown-linux-musl] +image = "ghcr.io/cross-rs/x86_64-unknown-linux-musl:main" + +[target.aarch64-unknown-linux-musl] +image = "ghcr.io/cross-rs/aarch64-unknown-linux-musl:main" + +[target.x86_64-pc-windows-gnu] +image = "ghcr.io/cross-rs/x86_64-pc-windows-gnu:main" diff --git a/README.md b/README.md index 320a1a2..39649bb 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ The preparation commit uses your configured Git author and signing settings. The ## Build local artifacts ```bash -rust_realease ./my-tool --stop-after package +rust_realease ./my-tool --compile-only ``` This runs host `cargo check` and `cargo test`, builds the selected targets with Cross, and writes the configured artifacts plus `SHA256SUMS` into a new `dist/release-*/` directory. It does not contact Gitea. The default targets are: @@ -85,7 +85,7 @@ Override the matrix with repeatable `--target TARGET` options. Use `--stop-after Use `--artifact-format binary` when you only want raw executables, or `--artifact-format both` to publish raw executables alongside the default cargo-binstall archives: ```bash -rust_realease ./my-tool --artifact-format binary --stop-after package +rust_realease ./my-tool --artifact-format binary --compile-only rust_realease ./my-tool --artifact-format both ``` @@ -108,6 +108,7 @@ process arguments and publishes both archive and standalone-binary assets: ```bash cargo install --path . --locked +./release.sh ../gitea_token.txt --compile-only ./release.sh ../gitea_token.txt --dry-run ./release.sh ../gitea_token.txt ``` diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 3834410..2434399 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -87,6 +87,8 @@ For repositories whose build scripts need a selected Rust toolchain inside Cross ## Pipeline stages +`--compile-only` runs through the package stage and then stops: it performs host checks, cross-compiles, and writes local artifacts without creating or uploading a release. It is the explicit artifact-build mode and conflicts with `--dry-run`, `--prepare-repo`, and `--stop-after`. + `--stop-after` can stop at `inspect`, `metadata`, `verify`, `build`, `package`, `release`, `upload`, or `binstall`. `verify` runs host `cargo check` and `cargo test`; `--skip-tests` skips only tests. Release builds use fresh target directories to avoid stale build-script output. `release` creates or reuses the Gitea release; `upload` uploads archives and checksums. The final stage downloads assets anonymously for public repositories or with Gitea authentication for private repositories, checks their checksums and archive layout, and runs isolated `cargo-binstall` installs for public targets. `--skip-binstall-test` skips that install check, while retaining download verification. `--draft --stop-after upload` is useful when a release must stay private for review. Private repositories require `--skip-binstall-test`; cargo-binstall cannot fetch their attachment URLs, even when `GITEA_TOKEN` is set. `--prerelease` and `--draft` set properties when a release is created; reusing a release preserves its existing settings. Asset replacement is not transactional: if an upload fails after a matching asset is deleted, retry the publication explicitly. diff --git a/src/cli.rs b/src/cli.rs index debd578..eaa45fe 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -52,6 +52,12 @@ pub struct Cli { pub verbose: bool, #[arg(long, value_enum)] pub stop_after: Option, + /// Build and package local artifacts without creating or uploading a release. + #[arg( + long, + conflicts_with_all = ["dry_run", "stop_after", "prepare_repo"] + )] + pub compile_only: bool, #[arg(long)] pub prepare_repo: bool, #[arg(long)] @@ -71,7 +77,10 @@ pub struct Cli { pub artifact_format: Option, } -pub fn run(args: Cli) -> Result<(), Error> { +pub fn run(mut args: Cli) -> Result<(), Error> { + if args.compile_only { + args.stop_after = Some(Stage::Package); + } if (args.commit_preparation || args.create_tag || args.push_preparation @@ -446,4 +455,19 @@ mod tests { ]); run(args).unwrap(); } + + #[test] + fn compile_only_is_an_explicit_package_stage_without_release_options() { + let args = Cli::try_parse_from(["rust_realease", ".", "--compile-only"]).unwrap(); + assert!(args.compile_only); + assert_eq!(args.stop_after, None); + + for conflicting in ["--dry-run", "--stop-after", "--prepare-repo"] { + let mut arguments = vec!["rust_realease", ".", "--compile-only", conflicting]; + if conflicting == "--stop-after" { + arguments.push("package"); + } + assert!(Cli::try_parse_from(arguments).is_err()); + } + } } diff --git a/tests/release_wrapper.rs b/tests/release_wrapper.rs index c9e2e2b..5215c7a 100644 --- a/tests/release_wrapper.rs +++ b/tests/release_wrapper.rs @@ -42,7 +42,7 @@ fn release_wrapper_passes_the_token_and_preserves_the_ssh_origin() { } fs::write( repository.join("Cargo.toml"), - "[package]\nname = \"rust_realease\"\nversion = \"0.1.1\"\n", + "[package]\nname = \"rust_realease\"\nversion = \"0.1.2\"\n", ) .expect("manifest should be written"); fs::write(repository.join("token.txt"), "test-token\n").expect("token file should be written");