Skip to content

Commit

Permalink
update ::set-output alirezanet#7
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed May 11, 2023
1 parent 1be871f commit a8cbe44
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,27 @@ class Action {
this.nugetKey = process.env.INPUT_NUGET_KEY || process.env.NUGET_KEY
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.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 +55,8 @@ 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 @@ -80,10 +93,12 @@ class Action {

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 +163,7 @@ class Action {
console.log(`Version: ${this.version}`)

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

Expand Down

0 comments on commit a8cbe44

Please sign in to comment.