Skip to content

Commit 30720f7

Browse files
committed
CI: Replace deprecated ::set-output command
1 parent 0f77981 commit 30720f7

File tree

7 files changed

+30
-19
lines changed

7 files changed

+30
-19
lines changed

.github/actions/cargo-install-upload-artifacts/action.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ runs:
1414
metadata="$(cargo metadata --format-version 1 --no-deps)"
1515
1616
package_name="cross"
17-
echo "::set-output name=package-name::${package_name}"
17+
echo "package-name=${package_name}" >> $GITHUB_OUTPUT
1818
1919
out_dir="$(mktemp -d)"
2020
artifacts_dir="$(mktemp -d)"
@@ -24,8 +24,8 @@ runs:
2424
artifacts_dir="$(cygpath -w "${artifacts_dir}")"
2525
fi
2626
27-
echo "::set-output name=out-dir::${out_dir}"
28-
echo "::set-output name=artifacts-dir::${artifacts_dir}"
27+
echo "out-dir=${out_dir}" >> $GITHUB_OUTPUT
28+
echo "artifacts-dir=${artifacts_dir}" >> $GITHUB_OUTPUT
2929
shell: bash
3030
- run: rm -rf .git
3131
shell: bash
@@ -66,8 +66,8 @@ runs:
6666
artifact_path="$(cygpath -w "${artifact_path}")"
6767
fi
6868
69-
echo "::set-output name=name::${artifact_name}"
70-
echo "::set-output name=path::${artifact_path}"
69+
echo "name=${artifact_name}" >> $GITHUB_OUTPUT
70+
echo "path=${artifact_path}" >> $GITHUB_OUTPUT
7171
env:
7272
package_name: ${{ steps.metadata.outputs.package-name }}
7373
out_dir: ${{ steps.metadata.outputs.out-dir }}

.github/actions/cargo-llvm-cov/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ runs:
3131
echo LLVM_PROFILE_FILE="${pwd}/target/cross-%m.profraw" >> $GITHUB_ENV
3232
echo CARGO_INCREMENTAL="0" >> $GITHUB_ENV
3333
echo RUST_TEST_THREADS="1" >> $GITHUB_ENV
34-
echo "::set-output name=artifact-name::_coverage-${name}"
34+
echo "artifact-name=_coverage-${name}" >> $GITHUB_OUTPUT
3535
post: |
3636
# XXX(emilgardis): Upload early?
3737
pwd=$(pwd)

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ jobs:
385385
with:
386386
path: ${{ runner.temp }}/artifacts
387387
- name: Grab PR number
388-
run: echo "::set-output name=pr::"$(echo $commit_message | sed -ne 's/.*\#\(.*\):/\1/p')
388+
run: echo "pr=$(echo ${commit_message} | sed -ne 's/.*#\(.*\):/\1/p')" >> $GITHUB_OUTPUT
389389
id: pr-number
390390
if: ${{ !github.event.pull_request.number }}
391391
env:

xtask/src/build_docker_image.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ pub fn build_docker_image(
324324
}
325325
}
326326
if gha {
327-
gha_output("image", &tags[0]);
328-
gha_output("images", &format!("'{}'", serde_json::to_string(&tags)?));
327+
gha_output("image", &tags[0])?;
328+
gha_output("images", &format!("'{}'", serde_json::to_string(&tags)?))?;
329329
if targets.len() > 1 {
330330
gha_print("::endgroup::");
331331
}

xtask/src/ci.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn ci(args: CiJob, metadata: CargoMetadata) -> cross::Result<()> {
6363
chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Millis, true)
6464
));
6565

66-
gha_output("labels", &serde_json::to_string(&labels.join("\n"))?);
66+
gha_output("labels", &serde_json::to_string(&labels.join("\n"))?)?;
6767

6868
let version = cross_meta.version.clone();
6969

@@ -78,15 +78,15 @@ pub fn ci(args: CiJob, metadata: CargoMetadata) -> cross::Result<()> {
7878
false,
7979
&version,
8080
)?[0],
81-
);
81+
)?;
8282

8383
if target.has_ci_image() {
84-
gha_output("has-image", "true")
84+
gha_output("has-image", "true")?
8585
}
8686
if target.is_standard_target_image() {
87-
gha_output("test-variant", "default")
87+
gha_output("test-variant", "default")?
8888
} else {
89-
gha_output("test-variant", &target.name)
89+
gha_output("test-variant", &target.name)?
9090
}
9191
}
9292
CiJob::Check { ref_type, ref_name } => {
@@ -110,7 +110,7 @@ pub fn ci(args: CiJob, metadata: CargoMetadata) -> cross::Result<()> {
110110
.ok_or_else(|| eyre::eyre!("cargo search returned unexpected data"))?,
111111
)?;
112112
if version >= latest_version && version.pre.is_empty() {
113-
gha_output("is-latest", "true")
113+
gha_output("is-latest", "true")?
114114
}
115115
}
116116
}

xtask/src/ci/target_matrix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub(crate) fn run(message: String, author: String) -> Result<(), color_eyre::Rep
4545

4646
let json = serde_json::to_string(&matrix)?;
4747
gha_print(&json);
48-
gha_output("matrix", &json);
48+
gha_output("matrix", &json)?;
4949
Ok(())
5050
}
5151

xtask/src/util.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::env;
12
use std::fs;
23
use std::io::Write;
34
use std::path::{Path, PathBuf};
@@ -296,12 +297,13 @@ pub fn gha_error(content: &str) {
296297
}
297298

298299
#[track_caller]
299-
pub fn gha_output(tag: &str, content: &str) {
300+
pub fn gha_output(tag: &str, content: &str) -> cross::Result<()> {
300301
if content.contains('\n') {
301302
// https://github.com/actions/toolkit/issues/403
302-
panic!("output `{tag}` contains newlines, consider serializing with json and deserializing in gha with fromJSON()")
303+
eyre::bail!("output `{tag}` contains newlines, consider serializing with json and deserializing in gha with fromJSON()");
303304
}
304-
gha_output!("::set-output name={tag}::{}", content);
305+
write_to_gha_env_file("GITHUB_OUTPUT", &format!("{tag}={content}"))?;
306+
Ok(())
305307
}
306308

307309
pub fn read_dockerfiles(msg_info: &mut MessageInfo) -> cross::Result<Vec<(PathBuf, String)>> {
@@ -411,3 +413,12 @@ pub fn write_to_string(path: &Path, contents: &str) -> cross::Result<()> {
411413
writeln!(file, "{}", contents)?;
412414
Ok(())
413415
}
416+
417+
// https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files
418+
pub fn write_to_gha_env_file(env_name: &str, contents: &str) -> cross::Result<()> {
419+
let path = env::var(env_name)?;
420+
let path = Path::new(&path);
421+
let mut file = fs::OpenOptions::new().append(true).open(path)?;
422+
writeln!(file, "{}", contents)?;
423+
Ok(())
424+
}

0 commit comments

Comments
 (0)