Skip to content

Add automatic version tagging #4

Add automatic version tagging

Add automatic version tagging #4

Workflow file for this run

name: Version Tagging
on:
push:
branches: ["main"]
paths:
- "pyproject.toml"
tags-ignore: ["v*"]
jobs:
tag-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v6
with:
python-version: "3.12"
- name: Get current version
id: version
run: |
CURRENT_VERSION=$(uv version --short)
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "Current version: $CURRENT_VERSION"
- name: Check if tag already exists
id: check_tag
run: |
if git rev-parse "v${{ steps.version.outputs.current_version }}" >/dev/null 2>&1; then
echo "Tag v${{ steps.version.outputs.current_version }} already exists"
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "Tag does not exist yet"
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Create and push new tag
if: steps.check_tag.outputs.exists == 'false'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ steps.version.outputs.current_version }}" -m "Release version ${{ steps.version.outputs.current_version }}"
git push origin "v${{ steps.version.outputs.current_version }}"