Skip to content

Commit

Permalink
Merge pull request #3 from pl-strflt/third-release
Browse files Browse the repository at this point in the history
release v1.0.2
  • Loading branch information
galargh authored Feb 28, 2023
2 parents 8878080 + 884aaf3 commit 8d046d6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [1.0.2] - 2023-02-28
### Fixed
- subtags should be updated when the parent tag is created
- tag should be created ahead of the GitHub release

## [1.0.1] - 2023-02-27
### Fixed
- creating subtags
Expand Down
34 changes: 30 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,29 @@ async function run() {
return
}

if (!draft) {
core.info('Creating fixed tag...')
core.info('Listing refs...')
const refs = await octokit.rest.git.listMatchingRefs({
...github.context.repo,
ref: `tags/${tag}`
})
const ref = refs.data.find(ref => ref.ref === `refs/tags/${tag}`)
if (ref == null) {
core.info('Creating ref...')
await octokit.rest.git.createRef({
...github.context.repo,
ref: `refs/tags/${tag}`,
sha: github.context.sha
})
}
}

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

let shouldCreateExtraTags = !draft
let shouldUpdateMutableTags = !draft
if (release != null) {
if (release.draft === true && draft === false) {
core.info('Publishing release...')
Expand All @@ -79,7 +97,7 @@ async function run() {
draft
})
} else {
shouldCreateExtraTags = false
shouldUpdateMutableTags = false
}
} else {
core.info('Creating release...')
Expand All @@ -94,8 +112,8 @@ async function run() {
}
core.info(`Release: ${release.html_url}`)

if (shouldCreateExtraTags) {
core.info('Creating tags...')
if (shouldUpdateMutableTags) {
core.info('Updating mutable tags...')
const suffix = `${version[4] != null ? '-' + version[4] : ''}${version[5] != null ? '+' + version[5] : ''}`
const tags = [
`v${version[1]}.${version[2]}${suffix}`,
Expand All @@ -116,6 +134,14 @@ async function run() {
ref: `refs/tags/${tag}`,
sha: github.context.sha
})
} else {
core.info('Updating ref...')
await octokit.rest.git.updateRef({
...github.context.repo,
ref: `tags/${tag}`,
sha: github.context.sha,
force: true
})
}
}
}
Expand Down

0 comments on commit 8d046d6

Please sign in to comment.