name: Auto Tag
on:
push:
branches:
- main
paths-ignore:
- 'docs/**'
- '**.md'
- 'CHANGELOG.md'
- 'LICENSE'
permissions:
contents: write
jobs:
check-and-tag:
name: Check version and create tag
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from Cargo.toml
id: version
run: |
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
echo "version=v$VERSION" >> $GITHUB_OUTPUT
echo "Version from Cargo.toml: v$VERSION"
- name: Check if tag exists
id: check_tag
run: |
if git rev-parse "${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Tag ${{ steps.version.outputs.version }} already exists"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Tag ${{ steps.version.outputs.version }} does not exist"
fi
- name: Configure Git
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"
- name: Create and push tag
if: steps.check_tag.outputs.exists == 'false'
run: |
git tag ${{ steps.version.outputs.version }}
git push origin ${{ steps.version.outputs.version }}
echo "Created and pushed tag ${{ steps.version.outputs.version }}"
echo "Release workflow will be triggered automatically by tag push"