Add automatic version tagging #1
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 Version | |
on: | |
push: | |
branches: [main] | |
paths: | |
- "pyproject.toml" | |
jobs: | |
tag-version: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Get all history for version comparison | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Install uv | |
run: pip install uv | |
- name: Get current version | |
id: version | |
run: | | |
CURRENT_VERSION=$(uv version --project) | |
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 new tag | |
if: steps.check_tag.outputs.exists == 'false' | |
run: | | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
git tag -a "v${{ steps.version.outputs.current_version }}" -m "Version ${{ steps.version.outputs.current_version }}" | |
git push origin "v${{ steps.version.outputs.current_version }}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |