-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a3a747
commit 1acc215
Showing
8 changed files
with
144 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: 'Update tags' | ||
description: 'Update major and (optionally) minor tags.' | ||
|
||
inputs: | ||
major: | ||
required: false | ||
description: 'Update the major version.' | ||
default: 'true' | ||
|
||
minor: | ||
required: false | ||
default: 'false' | ||
description: 'Update the minor version.' | ||
|
||
runs: | ||
using: 'node16' | ||
main: 'index.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const core = require('@actions/core'); | ||
|
||
const { major, minor, prerelease } = require('semver'); | ||
const { spawnSync } = require('child_process'); | ||
|
||
const updateTags = () => { | ||
const lastTagRef = spawnSync('git', ['rev-list', '--tags', '--max-count=1']).stdout.toString().trim(); | ||
const version = spawnSync('git', ['describe', '--tags', lastTagRef]).stdout.toString().trim(); | ||
|
||
const updateMajor = core.getBooleanInput('major'); | ||
const updateMinor = core.getBooleanInput('minor'); | ||
|
||
if (prerelease(version)) { | ||
core.info('Prerelease version detected; will not add a major version update-tags.'); | ||
return; | ||
} | ||
|
||
const versionTags = []; | ||
|
||
if (updateMajor) { | ||
versionTags.push(major(version)); | ||
} | ||
|
||
if (updateMinor) { | ||
versionTags.push(`${major(version)}.${minor(version)}`); | ||
} | ||
|
||
const ref = spawnSync('git', ['show-ref', '-s', version]).stdout.toString(); | ||
|
||
versionTags.forEach(tag => { | ||
const tagName = `v${tag}`; | ||
|
||
core.info(`Deleting tag "${tagName}"`); | ||
spawnSync('git', ['push', 'origin', `:refs/tags/v${tagName}`], { stdio: 'inherit' }); | ||
|
||
core.info(`Creating new tag "${tagName}" on ${ref}`); | ||
spawnSync('git', ['tag', '--force', `v${tagName}`, ref], { stdio: 'inherit' }); | ||
}); | ||
|
||
core.info('Pushing tags'); | ||
spawnSync('git', ['push', '--tags']) | ||
}; | ||
|
||
try { | ||
updateTags(); | ||
} catch (e) { | ||
core.setFailed(e.message); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters