Preflight private releases and add public live verification

This commit is contained in:
Dandaedre 2026-09-17 02:29:15 +02:00
parent 4ee1b3a3b0
commit 66b79a2adf
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
2 changed files with 44 additions and 24 deletions

View File

@ -221,6 +221,17 @@ pub fn run(args: Cli) -> Result<(), Error> {
&& args
.stop_after
.is_none_or(|stage| stage.order() >= Stage::Binstall.order());
let publication = if publishing {
project::validate_checkout_tag(&checkout.root, &tag, &runner)?;
let api = Gitea::new(&repository, &config.token_env)?;
let private = api.repository_private()?;
if private && needs_binstall {
return Err(Error("This repository is private; cargo-binstall cannot verify its private release downloads. Rerun with --skip-binstall-test to verify uploaded assets with Gitea authentication.".into()));
}
Some((api, private))
} else {
None
};
let (mut problems, engine) = build::prerequisites(
&checkout.root,
&config,
@ -250,18 +261,6 @@ pub fn run(args: Cli) -> Result<(), Error> {
"Resolve the prerequisite issues above before building.".into(),
));
}
if publishing {
project::validate_checkout_tag(&checkout.root, &tag, &runner)?;
if std::env::var(&config.token_env)
.ok()
.is_none_or(|value| value.is_empty())
{
return Err(Error(format!(
"Set {} before publishing.",
config.token_env
)));
}
}
build::verify_source(&checkout.root, &selected, &config, args.skip_tests, &runner)?;
if args.stop_after == Some(Stage::Verify) {
return Ok(());
@ -295,11 +294,8 @@ pub fn run(args: Cli) -> Result<(), Error> {
return Ok(());
}
let commit = project::head_commit(&checkout.root, &runner)?;
let api = Gitea::new(&repository, &config.token_env)?;
let private = api.repository_private()?;
if private && needs_binstall {
return Err(Error("This repository is private; cargo-binstall cannot verify its private release downloads. Rerun with --skip-binstall-test to verify uploaded assets with Gitea authentication.".into()));
}
let (api, private) =
publication.ok_or_else(|| Error("Publication client was not initialized.".into()))?;
let release = api.ensure_release(&tag, &commit, args.draft, args.prerelease)?;
println!("Release ready: {tag}");
if args.stop_after == Some(Stage::Release) {

View File

@ -294,18 +294,42 @@ mod tests {
})
.collect::<Result<Vec<_>, Error>>()
.unwrap();
let api = crate::gitea::Gitea::new(&repository, "GITEA_TOKEN").unwrap();
let private = api.repository_private().unwrap();
let private = std::env::var("RUST_RELEASE_LIVE_PRIVATE").as_deref() == Ok("1");
let api = private.then(|| crate::gitea::Gitea::new(&repository, "GITEA_TOKEN").unwrap());
verify_published(
&repository,
&tag,
&artifacts,
&directory.join("SHA256SUMS"),
if private {
Some(api.download_client())
} else {
None
},
api.as_ref().map(crate::gitea::Gitea::download_client),
)
.unwrap();
}
#[test]
#[ignore = "requires a public disposable release and cargo-binstall"]
fn live_binstall_installs_public_release() {
let required = |name: &str| std::env::var(name).expect("set live release test variables");
let manifest = std::path::PathBuf::from(required("RUST_RELEASE_LIVE_MANIFEST"));
let root = manifest.parent().unwrap().to_path_buf();
let name = required("RUST_RELEASE_LIVE_NAME");
let project = SelectedPackage {
name: name.clone(),
version: required("RUST_RELEASE_LIVE_VERSION"),
binary: name,
manifest,
repository: Some(required("RUST_RELEASE_LIVE_REPOSITORY")),
target_directory: root.join("target"),
};
verify_binstall(
&root,
&project,
&[
"x86_64-unknown-linux-musl".into(),
"aarch64-unknown-linux-musl".into(),
"x86_64-pc-windows-gnu".into(),
],
&Runner::new("GITEA_TOKEN"),
)
.unwrap();
}