Skip to content

Tag a git version

Actions
Tag a repo with a version calculated by GitVersion
v5
Latest
Star (1)

GitVersion Tag Action

Overview

The gitversion-tag-action automates tagging your repository with a semantic version determined by GitVersion, which analyzes your git history to calculate the next version based on your configuration.

Inputs

Below are the inputs required for this action:

  • configFilePath:
    • Description: Path to the GitVersion configuration file.
    • Required: True
    • Default: 'gitversion.yml'

Outputs

Below are the outputs generated by this action:

  • semVer: The semantic version determined by GitVersion

Execution

The action follows these steps:

  1. Install GitVersion: Installs the specified version of GitVersion.
  2. Determine Version: Uses GitVersion to determine the semantic version based on the repository's history and the provided configuration file.
  3. Tag the Repo: The repository is tagged with the determined version and the tag is pushed to the origin.

Example Workflow

To use the Tag a git version action in a GitHub workflow, refer to the example below:

Warning

For production environments make sure to replace @main by a pinned version.

name: GitVersion Tag

permissions:
  id-token: write
  contents: write

on:
  push:
    branches: [ "main" ]
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout Step
      uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - name: Tag the repo
      id: gitversion
      uses: michielvha/gitversion-tag-action@main
      with:
        configFilePath: gitversion.yml

Important

Ensure that you have the gitversion.yml configuration file in your repository's root or provide the correct path to your configuration file by using the configFilePath input.

In this workflow:

  • The action is triggered on pushes to the main branch and can also be manually triggered using the workflow_dispatch event.
  • The repository is checked out with a fetch depth of 0, ensuring all tags and branches are fetched.
  • The SemVer is calculated and tagged to the repo together with the latest commit message.

It's possible to pass the version to other actions via the output.

...
      - name: Build and Push Docker Image
        id: docker-build
        uses: michielvha/docker-release-action@v1
        with:
          version: ${{ steps.gitversion.outputs.semver }}
...

Reference

Tag a git version is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Tag a repo with a version calculated by GitVersion
v5
Latest

Tag a git version is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.