From 884aaf3c936a043007925a9a9293c85967f02274 Mon Sep 17 00:00:00 2001 From: galargh Date: Tue, 28 Feb 2023 12:10:29 +0100 Subject: [PATCH] release v1.0.2 --- CHANGELOG.md | 5 +++++ index.js | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c23beae..c17b7d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/index.js b/index.js index 1223d0a..636517a 100644 --- a/index.js +++ b/index.js @@ -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...') @@ -79,7 +97,7 @@ async function run() { draft }) } else { - shouldCreateExtraTags = false + shouldUpdateMutableTags = false } } else { core.info('Creating release...') @@ -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}`, @@ -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 + }) } } }