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

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git Tag Semantic Version

GitHub action to get version information from the Git tag.

The tag reqires a "v" as prefix followed by a Semantic Version 2.0.0. You can test your tag for validation.

Formats:

  • *v[Major].[Minor].[Patch]
  • *v[Major].[Minor].[Patch]-[pre-release]
  • *v[Major].[Minor].[Patch]+[buildmetadata]
  • *v[Major].[Minor].[Patch]-[pre-release]+[buildmetadata]

Example

name: Example

on:
  push:
    tags:
      - 'v*'

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v3
    - name: Setup .NET
      uses: actions/setup-dotnet@v3
      with:
        dotnet-version: 6.0.x
    - name: Restore
      run: dotnet restore
    - name: Build
      run: dotnet build --no-restore
    - name: Test
      run: dotnet test --no-restore --no-build
    - name: Get Version from Tag
      if: startsWith(github.event.ref, 'refs/tags/v')
      id: tagver
      uses: ChrSchu90/GitTagSemanticVersion@v1.1
    - name: Pack Release NuGets
      if: ${{ steps.tagver.outputs.is_release == 'true' }}
      run: dotnet pack --no-restore --output ${{ github.workspace }}/packages /p:Version=${{ steps.tagver.outputs.version }}
    - name: Pack Prerelease NuGets
      if: ${{ steps.tagver.outputs.is_prerelease == 'true' }}
      run: dotnet pack --no-restore --output ${{ github.workspace }}/packages /p:VersionPrefix=${{ steps.tagver.outputs.version }} --version-suffix ${{ steps.tagver.outputs.suffix }}
    - name: Push NuGets
      if: ${{ steps.tagver.outputs.is_valid == 'true' }}
      run: dotnet nuget push ${{ github.workspace }}/packages/*.nupkg --source ${{ secrets.NUGET_FEED }} --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }}

Inputs

Name Type Description
tag String [optional] Tag where the version info gets extracted from. Default is github.ref

Outputs

The following outputs can be accessed via ${{ steps.<step-id>.outputs }}. Note that boolean output variables needs to be handled like strings, otherwise it could lead into unexpected behaviors!

Name Type Description
version_tag String The clean version tag (e.g. v1.2.3-beta1+as4at5dd) without the git ref prefix
version String Version without pre-release or build metadata (e.g. 1.2.3)
major String Major version number (e.g. 1)
minor String Minor version number (e.g. 2)
patch String Patch version number (e.g. 3)
suffix String Pre-release tag without - (e.g. beta1)
metadata String Metadata tag without + (e.g. as4at5dd)
package String Package version for NuGet with suffix if defined (e.g. 1.2.3-beta1)
is_valid String true if the version tag was valid and could be processed, otherwise false
is_prerelease String true if the version is a pre-release (suffix defined), otherwise false
is_release String true if the version is a release (no suffix defined), otherwise false

Notes

  • This action requires pwsh to actually be available and on PATH of the runner - which is the case for all GitHub-provided runner VMs; for your own runners you need to take care of that yourself.
  • This action is a composite action.

License

This action is licensed under MIT license.

About

GitHub action to get version information from the Git tag

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages