Tag a git version
ActionsTags
(2)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.
Below are the inputs required for this action:
- configFilePath:
- Description: Path to the GitVersion configuration file.
- Required: True
- Default: 'gitversion.yml'
Below are the outputs generated by this action:
- semVer: The semantic version determined by GitVersion
The action follows these steps:
- Install GitVersion: Installs the specified version of GitVersion.
- Determine Version: Uses GitVersion to determine the semantic version based on the repository's history and the provided configuration file.
- Tag the Repo: The repository is tagged with the determined version and the tag is pushed to the origin.
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.ymlImportant
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
mainbranch and can also be manually triggered using theworkflow_dispatchevent. - The repository is checked out with a fetch depth of 0, ensuring all tags and branches are fetched.
- The
SemVeris 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 }}
...- GitVersion Config File Specification - Complete reference for the configuration file. My pre-made config can be found here
- Metadata syntax for GitHub Actions
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.