fix(workflow): improve release existence check in release-on-tag.yml

Refactor the script to improve checking for existing releases by tag.
Return an object instead of using core.setOutput to streamline the
workflow logic. Also, set result-encoding to string for better
compatibility.
This commit is contained in:
Yidi 2024-09-26 21:20:07 -04:00
parent bc08931b8d
commit 1ff25f9d33

View File

@ -15,19 +15,20 @@ jobs:
with:
script: |
try {
const release = await github.rest.repos.getReleaseByTag({
await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: context.ref.replace('refs/tags/', ''),
})
core.setOutput('release_exists', 'true')
return { release_exists: 'true' }
} catch (error) {
if (error.status === 404) {
core.setOutput('release_exists', 'false')
return { release_exists: 'false' }
} else {
throw error
}
}
result-encoding: string
- name: Create Release
if: steps.check_release.outputs.release_exists == 'false'