Skip to content

GitHub Action that parses SemVer version which can be a tag.

License

Notifications You must be signed in to change notification settings

akshens/semver-tag

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Semver Tag GitHub Action

pnpm jest

GitHub Action that extracts Semver version tag which can be used as npm tag.

Inputs

  • version

    Required Input version to get parsed. It may contain 'v' prefix.

Outputs

  • is-prerelease

    Indicates whether the version is a pre-release

  • tag

    Version tag, whether is a release or a pre-release. Is is guaranteed that tag output has a value. In case when the version is detected as a pre-release version, if there is an identifier provided in the version, e.g., using --preid option of npm version command, the provided identifier will be returned as the tag, otherwise, dev tag will be returned. And in case where the version is detected as a version (non-pre-release), the tag value will be latest. See examples below for more.

Example Usage

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

Input/Output Examples

  • 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"