feat: add compile-only artifact builds
This commit is contained in:
parent
73f5361172
commit
a28aa30e3d
|
|
@ -973,7 +973,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rust_realease"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"directories",
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
```
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
26
src/cli.rs
26
src/cli.rs
|
|
@ -52,6 +52,12 @@ pub struct Cli {
|
|||
pub verbose: bool,
|
||||
#[arg(long, value_enum)]
|
||||
pub stop_after: Option<Stage>,
|
||||
/// 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<PackageFormat>,
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in New Issue