Skip to content

Commit

Permalink
fix: release retrieval after creation/update
Browse files Browse the repository at this point in the history
  • Loading branch information
galargh committed Mar 27, 2023
1 parent 71cb54e commit 917f8db
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [1.0.6] - 2023-03-24
### Fixed
- fixed release retrieval after creation/update

## [1.0.5] - 2023-03-24
### Fixed
- changelog parsing when there is no released version in the CHANGELOG.md
Expand Down
16 changes: 13 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async function run() {
core.info(`Tag: ${tag}`)

core.info('Listing releases...')
const releases = await octokit.paginate(octokit.rest.repos.listReleases, github.context.repo)
let releases = await octokit.paginate(octokit.rest.repos.listReleases, github.context.repo)
let release = releases.find(release => release.tag_name === tag)

if (release != null && release.published_at != null) {
Expand All @@ -84,22 +84,32 @@ async function run() {

if (release == null) {
core.info('Creating release...')
release = (await octokit.rest.repos.createRelease({
const response = (await octokit.rest.repos.createRelease({
...github.context.repo,
tag_name: tag,
target_commitish: target,
body,
draft,
prerelease: version[4] != null
})).data
core.info(JSON.stringify(response, null, 2))
} else {
core.info('Updating release...')
release = await octokit.rest.repos.updateRelease({
const response = await octokit.rest.repos.updateRelease({
...github.context.repo,
release_id: release.id,
draft
})
core.info(JSON.stringify(response, null, 2))
}
core.info('Listing releases...')
releases = await octokit.paginate(octokit.rest.repos.listReleases, github.context.repo)
release = releases.find(release => release.tag_name === tag)

if (release == null) {
throw new Error('Release not found')
}

core.info(`Release: ${release.html_url}`)

const tags = []
Expand Down

0 comments on commit 917f8db

Please sign in to comment.