Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ::set-output #7 #10

Merged
merged 1 commit into from
May 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 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 @@ -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