Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/version_tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Create version tag

on:
push:
branches:
- main
paths:
- 'pyproject.toml'

jobs:
create-version-tag:
name: Check version and create tag
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Extract version from pyproject.toml
id: get_version
run: |
VERSION=$(grep -m 1 '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"

- name: Check if tag exists
id: check_tag
run: |
if git rev-parse "${{ steps.get_version.outputs.version }}" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Tag '${{ steps.get_version.outputs.version }}' already exists"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Tag '${{ steps.get_version.outputs.version }}' does not exist"
fi

- name: Create and push 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 "${{ steps.get_version.outputs.version }}"
git push origin "${{ steps.get_version.outputs.version }}"