Skip to content

Commit

Permalink
Add more outputs suitable for deployment pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamc committed Sep 24, 2024
1 parent b661514 commit e850d85
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ Although the `flakehub-push` Action requires little configuration, you may benef

## Integration

This action sets the `flakeref` output to the exact name and version that was published.
The flake reference can be used in subsequent steps or workflows as part of a deployment process.
This action sets outputs for integrating into CD pipelines:

- `flake_name` Name of the flake. Example: `DeterminateSystems/flakehub-push`
- `flake_version` Name of the flake. Example: `0.1.99+rev-2075013a3f3544d45a96f4b35df4ed03cd53779c`
- `flakeref_descriptive` A loose reference to this release. Depending on this reference will require at least this version, and will also resolve to newer releases. This output is not sufficient for deployment pipelines, use `flake_exact` instead. Example: `DeterminateSystems/flakehub-push/0.1.99+rev-2075013a3f3544d45a96f4b35df4ed03cd53779c`
- `flake_exact` A precise reference that always resolves to this to this exact release. Example: `DeterminateSystems/flakehub-push/=0.1.99+rev-2075013a3f3544d45a96f4b35df4ed03cd53779c`

## More Information

Expand Down
28 changes: 21 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,27 @@ async fn execute() -> Result<std::process::ExitCode> {
ctx.release_version
);

if let Err(e) = github_actions::set_output(
"flakeref",
&format!("{}/{}", ctx.upload_name, ctx.release_version),
)
.await
{
tracing::warn!("Failed to set the `flakeref` output: {}", e);
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
);
}
}

Ok(ExitCode::SUCCESS)
Expand Down

0 comments on commit e850d85

Please sign in to comment.