/get-version-tag-action

A GitHub Action that finds a version tag for the checked-out SHA

Primary LanguageJavaScriptMIT LicenseMIT

Get Version Tag

Continuous Integration GitHub release (latest SemVer)

GitHub Action that gets the version from a tag on the current SHA

Input

The action requires no input parameters. The action will fail if no appropriate git tag can be found.

Output

This action has two outputs:

  • version - The version from the tag, numbers only, like 1.2.3
  • version-with-v - The version from the tag, prefixed with "v", like v1.2.3

Example

Find more examples in the examples directory.

name: Generate
jobs:
  generate:
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0 # Required due to the way Git works, without it this action won't be able to find any or the correct tags

      # This action will fail if no version tag is found.
      - name: 'Get version from tag'
        id: versiontag
        uses: "efirestone/get-version-tag-action@v1"

      - run: echo "Found version: ${{ steps.versiontag.outputs.version-with-v }}"

Recognition

The get-previous-tag action by Cees-Jan Kiewiet was used as the initial template for the structure of this project. Big thanks to him for the jumping off point.

License

Copyright 2023 Eric Firestone

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.