Skip to content

Commit

Permalink
Fix set-output deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
GerardSmit committed Mar 25, 2023
1 parent 9bdaac4 commit 47f6a3c
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const os = require("os"),
spawnSync = require("child_process").spawnSync

class Action {

constructor() {
this.projectFile = process.env.INPUT_PROJECT_FILE_PATH
this.packageName = process.env.INPUT_PACKAGE_NAME || process.env.PACKAGE_NAME
Expand All @@ -17,13 +18,26 @@ class Action {
this.nugetSource = process.env.INPUT_NUGET_SOURCE || process.env.NUGET_SOURCE
this.includeSymbols = JSON.parse(process.env.INPUT_INCLUDE_SYMBOLS || process.env.INCLUDE_SYMBOLS)
this.noBuild = JSON.parse(process.env.INPUT_NO_BUILD || process.env.NO_BUILD)
this._output = []
}

_printErrorAndExit(msg) {
console.log(`##[error]😭 ${msg}`)
throw new Error(msg)
}

_setOutput(name, value) {
this._output.push(`${name}=${value}`)
}

_flushOutput() {
const filePath = process.env['GITHUB_OUTPUT']

if (filePath) {
fs.appendFileSync(filePath, this._output.join(os.EOL))
}
}

_executeCommand(cmd, options) {
console.log(`executing: [${cmd}]`)

Expand All @@ -42,8 +56,7 @@ class Action {

this._executeInProcess(`git tag ${TAG}`)
this._executeInProcess(`git push origin ${TAG}`)

process.stdout.write(`::set-output name=VERSION::${TAG}` + os.EOL)
this._setOutput('VERSION', TAG)
}

_pushPackage(version, name) {
Expand Down Expand Up @@ -78,12 +91,12 @@ class Action {
const packageFilename = packages.filter(p => p.endsWith(".nupkg"))[0],
symbolsFilename = packages.filter(p => p.endsWith(".snupkg"))[0]

process.stdout.write(`::set-output name=PACKAGE_NAME::${packageFilename}` + os.EOL)
process.stdout.write(`::set-output name=PACKAGE_PATH::${path.resolve(packageFilename)}` + os.EOL)
this._setOutput('PACKAGE_NAME', packageFilename)
this._setOutput('PACKAGE_PATH', path.resolve(packageFilename))

if (symbolsFilename) {
process.stdout.write(`::set-output name=SYMBOLS_PACKAGE_NAME::${symbolsFilename}` + os.EOL)
process.stdout.write(`::set-output name=SYMBOLS_PACKAGE_PATH::${path.resolve(symbolsFilename)}` + os.EOL)
this._setOutput('SYMBOLS_PACKAGE_NAME', symbolsFilename)
this._setOutput('SYMBOLS_PACKAGE_PATH', path.resolve(symbolsFilename))
}

if (this.tagCommit)
Expand Down Expand Up @@ -148,6 +161,7 @@ class Action {
console.log(`Version: ${this.version}`)

this._checkForUpdate()
this._flushOutput()
}
}

Expand Down

0 comments on commit 47f6a3c

Please sign in to comment.