Skip to content
tag

GitHub Action

NSV (Next Semantic Version)

v1.0.0 Latest version

NSV (Next Semantic Version)

tag

NSV (Next Semantic Version)

Semantic versioning without any config

Installation

Copy and paste the following snippet into your .yml file.

              

- name: NSV (Next Semantic Version)

uses: purpleclay/[email protected]

Learn more about this action in purpleclay/nsv-action

Choose a version

NSV Action

NSV (Next Semantic Version) is a convention-based semantic versioning tool that leans on the power of conventional commits to make versioning your software a breeze!

Check out the latest documentation.

Inputs

Name Required Type Description
token no string A token for performing authenticated requests to the GitHub API
version no string The version of NSV to download (default: latest)
next-only no boolean If the next semantic version should just be calculated. Repository will not be tagged (default: false)

Outputs

Name Type Description
nsv string The calculated next semantic version

Environment variables

You can also define CI/CD variables within your GitLab project to configure the behavior of both nsv and gpg-import. All are optional:

  • NSV_FORMAT is a Go template for formatting the generated semantic version tag.
  • NSV_TAG_MESSAGE is a custom message when creating an annotated tag.
  • GPG_PRIVATE_KEY is the base64 encoded GPG private key in armor format.
  • GPG_PASSPHRASE is an optional passphrase if the GPG key is password protected.
  • GPG_TRUST_LEVEL is an owner trust level assigned to the imported GPG key.

Using the action

Tag the repository

If you wish to tag the repository without triggering another workflow, you must set the permissions of the job to contents: write.

name: ci
on:
  push:
    branches:
      - main
jobs:
  ci:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: NSV
        uses: purpleclay/nsv-action@v1
        env:
          GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}

If you don't wish to use a GPG key to sign the tags, you must set the committer details within the git config yourself. No user impersonation is currently supported.

Trigger another workflow

If you wish to trigger another workflow after nsv tags the repository, you must manually create a token (PAT) with the public_repo permission and use it during the checkout. For best security practice, use a short-lived token.

name: ci
on:
  push:
    branches:
      - main
jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
          token: ${{ secrets.TOKEN }}

      - name: NSV
        uses: purpleclay/nsv-action@v1
        env:
          GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
          GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

Capturing the next tag

You can capture the next tag without tagging the repository by setting the next-only input to true.

name: ci
on:
  push:
    branches:
      - main
jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: NSV
        id: nsv
        uses: purpleclay/nsv-action@v1
        with:
          next-only: true

      - name: Print Tag
        run: |
          echo "Next calculated tag: ${{ steps.nsv.outputs.nsv }}"