Skip to content

Commit

Permalink
Set outputs if this ref has been published before
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamc committed Sep 24, 2024
1 parent 53b28e3 commit 8a2eb34
Showing 1 changed file with 29 additions and 22 deletions.
51 changes: 29 additions & 22 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ async fn execute() -> Result<std::process::ExitCode> {
upload_name = ctx.upload_name,
release_version = &ctx.release_version,
);

set_release_outputs(&ctx.upload_name, &ctx.release_version).await;

if ctx.error_if_release_conflicts {
return Err(Error::Conflict {
upload_name: ctx.upload_name.to_string(),
Expand Down Expand Up @@ -182,28 +185,7 @@ async fn execute() -> Result<std::process::ExitCode> {
ctx.release_version
);

let outputs = [
("flake_name", &ctx.upload_name),
("flake_version", &ctx.release_version),
(
"flakeref_descriptive",
&format!("{}/{}", ctx.upload_name, ctx.release_version),
),
(
"flakeref_exact",
&format!("{}/={}", ctx.upload_name, ctx.release_version),
),
];
for (output_name, value) in outputs.into_iter() {
if let Err(e) = github_actions::set_output(output_name, value).await {
tracing::warn!(
"Failed to set the `{}` output to {}: {}",
output_name,
value,
e
);
}
}
set_release_outputs(&ctx.upload_name, &ctx.release_version).await;

Ok(ExitCode::SUCCESS)
}
Expand Down Expand Up @@ -236,3 +218,28 @@ impl Display for Visibility {
}
}
}

async fn set_release_outputs(upload_name: &str, release_version: &str) {
let outputs = [
("flake_name", upload_name),
("flake_version", release_version),
(
"flakeref_descriptive",
&format!("{}/{}", upload_name, release_version),
),
(
"flakeref_exact",
&format!("{}/={}", upload_name, release_version),
),
];
for (output_name, value) in outputs.into_iter() {
if let Err(e) = github_actions::set_output(output_name, value).await {
tracing::warn!(
"Failed to set the `{}` output to {}: {}",
output_name,
value,
e
);
}
}
}

0 comments on commit 8a2eb34

Please sign in to comment.