Tag with GitVersion #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tag with GitVersion | |
on: | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
tag: | |
name: Create tag from GitVersion | |
runs-on: ubuntu-latest | |
# additional safety to ensure this runs for main branch only | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Checkout repository (full history) | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: '6.3.x' | |
- name: Determine Version | |
id: gitversion # step id used as reference for output values | |
uses: gittools/actions/gitversion/[email protected] | |
- name: Create and push annotated tag (minor+1, patch=0) | |
env: | |
GITHUB_TOKEN: ${{ secrets.GIST_AUTH_TOKEN }} | |
run: | | |
set -euo pipefail | |
MAJOR="${{ steps.gitversion.outputs.major }}" | |
MINOR="${{ steps.gitversion.outputs.minor }}" | |
# increment minor and set patch to 0 | |
NEW_MINOR=$((MINOR + 1)) | |
TAG="v${MAJOR}.${NEW_MINOR}.0" | |
git config user.name github-actions[bot] | |
git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
git tag -a $TAG -m "Tag created by GitHub Actions using GitVersion (incremented minor)" | |
git push origin $TAG | |