Skip to content
info

GitHub Action

ZyAction: Semver

v1.0.0 Latest version

ZyAction: Semver

info

ZyAction: Semver

A GitHub Action that provides access to the individual parts of a SemVer2 version string

Installation

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

              

- name: ZyAction: Semver

uses: zyactions/[email protected]

Learn more about this action in zyactions/semver

Choose a version

SemVer

License: MIT CI Ubuntu macOS Windows

A GitHub Action that provides access to the individual parts of a SemVer2 version string.

Features

  • Provides access to the individual parts of a SemVer2 version string
  • Supports removal of unwanted prefixes
  • Fast execution
  • Supports all platforms (Linux, macOS, Windows)
  • Does not use external GitHub Actions dependencies

Usage

Parse semantic version

steps:
  - name: Parse version
    id: version
    uses: zyactions/semver@v1
    with:
      version: '1.2.3-alpha.1+build'

  - name: Print major version
    run: |-
      echo "Major: ${{ steps.outputs.version.major }}"

Note

If the version starts with refs/ and/or tags/, the prefix is automatically removed so that Git references can easily be used as input.

Inputs

version

A string containing the semantic version to parse.

For example:

  • 1.2.3-alpha.1+build
  • v2.3.4
  • refs/tags/v2.3.4

Defaults to GITHUB_REF if not specified.

prefixes

An optional newline separated list of version prefixes to strip from the input version (e.g. v or release-v).

fail-on-error

Set true to fail, if the input version does not contain a valid semantic version.

Defaults to true.

Outputs

valid

Signals, if the input version contained a valid semantic version.

Note

GitHub Actions outputs are always strings. Please explicitly check this value for 'true' and 'false' (string) instead of relying on boolean operations.

version

The (sanitized) semantic version string with any prefix trimmed from it.

For example: 1.2.3-alpha.1+build

major

The major version.

For example: 1

minor

The minor version.

For example: 2

patch

The patch version.

For example: 3

prerelease

The prerelease version part.

For example: alpha.1

build

The build/metadata version part.

For example: build

Dependencies

This action does not use external GitHub Actions dependencies.

Internal dependencies:

Versioning

Versions follow the semantic versioning scheme.

License

SemVer Action is licensed under the MIT license.