Skip to content

Commit 85b8255

Browse files
feat: export artifact variables to GitHub Actions environment and output
1 parent 1377ef6 commit 85b8255

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

scripts/release/build-mpk.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { basename, join, dirname } from "path";
22
import { readdir, copyFile, rm, mkdir } from "fs/promises";
3+
import { appendFileSync } from "fs";
34
import {
45
execShellCommand,
56
getFiles,
@@ -24,6 +25,22 @@ type ArtifactResult = {
2425
artifactName: string;
2526
};
2627

28+
function setGithubActionsVars(artifact: ArtifactResult): void {
29+
const githubEnvPath = process.env.GITHUB_ENV;
30+
if (githubEnvPath) {
31+
appendFileSync(githubEnvPath, `ARTIFACT_PATH=${artifact.artifactPath}\n`);
32+
appendFileSync(githubEnvPath, `ARTIFACT_NAME=${artifact.artifactName}\n`);
33+
log(`Exported ARTIFACT_PATH and ARTIFACT_NAME to GITHUB_ENV`);
34+
}
35+
36+
const githubOutputPath = process.env.GITHUB_OUTPUT;
37+
if (githubOutputPath) {
38+
appendFileSync(githubOutputPath, `artifact_path=${artifact.artifactPath}\n`);
39+
appendFileSync(githubOutputPath, `artifact_name=${artifact.artifactName}\n`);
40+
log(`Exported artifact_path and artifact_name to GITHUB_OUTPUT`);
41+
}
42+
}
43+
2744
type InputVariables = {
2845
module: string;
2946
version: string;
@@ -51,6 +68,8 @@ function writeArtifactEnvVariable(artifact: ArtifactResult): void {
5168
log(`Setting environment variable ARTIFACT_NAME=${artifact.artifactName}`);
5269
process.env.ARTIFACT_NAME = artifact.artifactName;
5370
log("Artifact environment variables set successfully.");
71+
72+
setGithubActionsVars(artifact);
5473
}
5574

5675
function validateInput(): void {

0 commit comments

Comments
 (0)