GitHub Action that extracts Semver version tag which can be used as npm tag.
-
versionRequired Input version to get parsed. It may contain 'v' prefix.
-
is-prereleaseIndicates whether the version is a pre-release
-
tagVersion tag, whether is a release or a pre-release. Is is guaranteed that
tagoutput has a value. In case when theversionis detected as a pre-release version, if there is an identifier provided in theversion, e.g., using--preidoption ofnpm versioncommand, the provided identifier will be returned as thetag, otherwise,devtag will be returned. And in case where the version is detected as a version (non-pre-release), thetagvalue will belatest. See examples below for more.
You can use action output by setting an id field to the step that uses this action. For example:
jobs:
PublishGPR:
name: Publish Package to GitHub Package Registry
runs-on: ubuntu-20.04
steps:
# Use the action somewhere among the steps
- name: Semver Tag
# This `id` is required to be referenced later from other steps
id: SemverTag
uses: akshens/semver-tag@v4
with:
version: 1.2.3
# And in some later step:
- name: Publish to GPR
# You can use the action outputs, for example the `tag` output, like this:
run: npm publish --tag ${{ steps.SemverTag.outputs.tag }} # npm publish --tag latest-
Successful pre-release version with identifier parse:
-
Input:
uses: "akshens/semver-tag@v4" with: version: "1.3.6-alpha.3"
-
Output:
is-prerelease: "true" tag: "alpha"
-
-
Successful pre-release version without identifier parse:
-
Input:
uses: "akshens/semver-tag@v4" with: version: "1.0.6-1"
-
Output:
is-prerelease: "true" tag: "dev"
-
-
Successful release parse:
-
Input:
uses: "akshens/semver-tag@v4" with: version: "1.3.0"
-
Output:
is-prerelease: "false" tag: "latest"
-