Create Tag #6
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: Create Tag | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| confirm: | |
| description: 'Type "yes" to confirm tag creation' | |
| required: true | |
| default: 'no' | |
| jobs: | |
| create-tag: | |
| runs-on: ubuntu-latest | |
| if: github.event.inputs.confirm == 'yes' | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract version from pyproject.toml | |
| id: version | |
| run: | | |
| VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "tag=v$VERSION" >> $GITHUB_OUTPUT | |
| echo "📦 Version found: $VERSION" | |
| - name: Check if tag already exists | |
| id: check | |
| run: | | |
| if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| echo "❌ Tag v${{ steps.version.outputs.version }} already exists!" | |
| exit 1 | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| echo "✅ Tag v${{ steps.version.outputs.version }} does not exist yet" | |
| fi | |
| - name: Create and push tag | |
| if: steps.check.outputs.exists == 'false' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag "v${{ steps.version.outputs.version }}" | |
| git push origin "v${{ steps.version.outputs.version }}" | |
| echo "🏷️ Created and pushed tag: v${{ steps.version.outputs.version }}" | |
| - name: Tag created successfully | |
| if: steps.check.outputs.exists == 'false' | |
| run: | | |
| echo "✨ Tag v${{ steps.version.outputs.version }} has been created!" | |
| echo "🚀 This will trigger the publish workflow automatically." |