This action calculates the semantic version of the repository using the GitVersion tool, and then creates a Git tag and GitHub release. Optionally you can pass in a pre-determined semantic version and that will be used instead.
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.release.outputs.version }}
major: ${{ steps.release.outputs.major }}
minor: ${{ steps.release.outputs.minor }}
patch: ${{ steps.release.outputs.patch }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # required for GitVersion to read full history
- uses: f2calv/gha-release-versioning@v1
id: release
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}Note:
fetch-depth: 0is required so GitVersion can read the full commit history to calculate the version.
| Input | Required | Default | Description |
|---|---|---|---|
GITHUB_TOKEN |
Yes | β | GitHub token for API access and creating releases. |
semVer |
No | '' |
Pass in an externally generated semantic version. When empty, GitVersion is used. |
tag-prefix |
No | v |
Prefix applied to the version tag, e.g. v1.0.1. |
move-major-tag |
No | true |
When true, moves rolling major (e.g. v1) and minor (e.g. v1.2) tags to the new release commit. |
tag-and-release |
No | true |
When true, creates a Git tag and a GitHub release. |
gv-config |
No | GitVersion.yml |
Path to the GitVersion configuration file. |
gv-source |
No | actions |
GitVersion installation source: actions, dotnet, or container. |
dotnet-version |
No | 10.0.x |
.NET SDK version to install when gv-source is dotnet. |
generate-release-notes |
No | true |
Auto-generate release notes from merged PRs since the last release. |
| Output | Description |
|---|---|
version |
The calculated semantic version, e.g. 1.2.301 or 1.2.301-feature-my-feature.12+56. |
major |
The major version component, e.g. 1. |
minor |
The minor version component, e.g. 2. |
patch |
The patch version component, e.g. 301. |
release-exists |
true if a GitHub Release already exists for this version, otherwise false. |
A GitVersion.yml file is required in the repository root when gv-source is used. The configuration schema changed between GitVersion v5 and v6 β the main difference is that branch pre-release labels are configured with label: in v6 (previously tag: in v5).
The action auto-detects the GitVersion version from the config file: if the config contains label: keys under branches, 6.x is used; if it contains tag: keys, 5.x is used. There is no need to specify the version manually.
mode: MainLine
branches:
main:
regex: ^main$
tag: ''
feature:
regex: ^features?[/-]
tag: useBranchNamemode: ContinuousDeployment
branches:
main:
regex: ^main$
label: ''
feature:
regex: ^features?[/-]
label: useBranchNameNote:
tag:in v5 branch config is a pre-release label setting and is not related to Git tags. In v6 this field was renamed tolabel:to avoid confusion. Themodevalue also changed:MainLinein v5 becameContinuousDeploymentin v6 (both produce clean versions on the default branch without requiring a pre-existing tag).
| Source | GitVersion v5 | GitVersion v6 | Notes |
|---|---|---|---|
actions |
β
via gittools/actions@v3 |
β
via gittools/actions@v4 |
Auto-selects the correct action version based on the detected spec. |
dotnet |
β | β | Installs GitVersion.Tool at the correct major version. |
container |
β
image tag 5.12.0 |
β
image tag latest |
Runs the official gittools/gitversion Docker image. |
MIT