workflows,scripts: migrate to use GITHUB_OUTPUT

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-11-22 17:15:37 +01:00
parent 017313d886
commit 609b5ce65b
5 changed files with 19 additions and 7 deletions
+7 -2
View File
@@ -28,6 +28,7 @@ const { execFile: execFileCb } = require('child_process');
const { resolve: resolvePath } = require('path');
const { promises: fs } = require('fs');
const { promisify } = require('util');
const { EOL } = require('os');
const parentRef = process.env.COMMIT_SHA_BEFORE || 'HEAD^';
@@ -53,6 +54,10 @@ async function runPlain(cmd, ...args) {
async function main() {
process.cwd(resolvePath(__dirname, '..'));
if (!process.env.GITHUB_OUTPUT) {
throw new Error('GITHUB_OUTPUT environment variable not set');
}
const diff = await runPlain(
'git',
'diff',
@@ -103,7 +108,7 @@ async function main() {
if (newVersions.length === 0) {
console.log('No package version bumps detected, no release needed');
console.log(`::set-output name=needs_release::false`);
await fs.appendFile(process.env.GITHUB_OUTPUT, `needs_release=false${EOL}`);
return;
}
@@ -114,7 +119,7 @@ async function main() {
` ${name.padEnd(maxLength, ' ')} ${oldVersion} to ${newVersion}`,
);
}
console.log(`::set-output name=needs_release::true`);
await fs.appendFile(process.env.GITHUB_OUTPUT, `needs_release=true${EOL}`);
}
main().catch(error => {
+9 -2
View File
@@ -19,6 +19,7 @@
const { Octokit } = require('@octokit/rest');
const path = require('path');
const fs = require('fs-extra');
const { EOL } = require('os');
const baseOptions = {
owner: 'backstage',
@@ -64,6 +65,9 @@ async function main() {
if (!process.env.GITHUB_TOKEN) {
throw new Error('GITHUB_TOKEN is not set');
}
if (!process.env.GITHUB_OUTPUT) {
throw new Error('GITHUB_OUTPUT environment variable not set');
}
const commitSha = process.env.GITHUB_SHA;
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
@@ -74,8 +78,11 @@ async function main() {
console.log(`Creating release tag ${tagName} at ${commitSha}`);
await createGitTag(octokit, commitSha, tagName);
console.log(`::set-output name=tag_name::${tagName}`);
console.log(`::set-output name=version::${releaseVersion}`);
await fs.appendFile(process.env.GITHUB_OUTPUT, `tag_name=${tagName}${EOL}`);
await fs.appendFile(
process.env.GITHUB_OUTPUT,
`version=${releaseVersion}${EOL}`,
);
}
main().catch(error => {