Skip to content

Commit

Permalink
Merge pull request #1350 from hannobraun/release
Browse files Browse the repository at this point in the history
Re-trigger release v0.24.0
  • Loading branch information
hannobraun authored Nov 14, 2022
2 parents 85b3a08 + 280b420 commit cb04eae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
16 changes: 14 additions & 2 deletions tools/release-operator/src/github.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::{env, fs::File, io::Write};

use crate::release::Outputs;
use anyhow::anyhow;
use cmd_lib::run_fun;
use serde::Deserialize;

Expand Down Expand Up @@ -69,8 +72,17 @@ pub struct Actions;

impl Actions {
// Set an "output" in GitHub Actions
pub fn set_output(key: Outputs, value: &str) {
pub fn set_output(key: Outputs, value: &str) -> anyhow::Result<()> {
const GITHUB_OUTPUT: &str = "GITHUB_OUTPUT";

let output = env::var_os(GITHUB_OUTPUT).ok_or_else(|| {
anyhow!("Could not read environment variable {GITHUB_OUTPUT}")
})?;
let mut output = File::open(output)?;

log::debug!("setting output name={key} value={value}");
println!("\"{key}={value}\" >> $GITHUB_OUTPUT");
writeln!(output, "{key}={value}")?;

Ok(())
}
}
6 changes: 3 additions & 3 deletions tools/release-operator/src/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ impl Release {
let tag = format!("v{tag}");
log::info!("detected release of {tag}");

Actions::set_output(Outputs::ReleaseDetected, "true");
Actions::set_output(Outputs::TagName, &tag);
Actions::set_output(Outputs::ReleaseDetected, "true")?;
Actions::set_output(Outputs::TagName, &tag)?;

Ok(())
}

fn miss(&self) -> anyhow::Result<()> {
log::info!("no release detected");
Actions::set_output(Outputs::ReleaseDetected, "false");
Actions::set_output(Outputs::ReleaseDetected, "false")?;
Ok(())
}
}

0 comments on commit cb04eae

Please sign in to comment.