Bump & Tag Version #35
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: Bump & Tag Version | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| bump: | |
| description: "Тип оновлення версії (patch | minor | major | none)" | |
| required: true | |
| default: "patch" | |
| permissions: | |
| contents: write | |
| jobs: | |
| bump_and_tag: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout (full history) | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Bump version | |
| id: bump | |
| run: | | |
| NEW_VER=$(python scripts/bump_version.py --file SteamAchievementLocalizer.py --bump "${{ github.event.inputs.bump }}") | |
| echo "new=$NEW_VER" >> $GITHUB_OUTPUT | |
| echo "New version: $NEW_VER" | |
| - name: Sync version to all files | |
| run: | | |
| echo "Syncing version ${{ steps.bump.outputs.new }} to all build files..." | |
| python scripts/update_version.py "${{ steps.bump.outputs.new }}" | |
| - name: Configure git (use PAT to allow triggering downstream workflows) | |
| env: | |
| PAT: ${{ secrets.ACTIONS_PAT }} | |
| run: | | |
| git config user.name "panvena-actions" | |
| git config user.email "[email protected]" | |
| git remote set-url origin https://${PAT}@github.com/${{ github.repository }}.git | |
| - name: Commit version change (if changed) | |
| run: | | |
| if git diff --quiet; then | |
| echo "Version unchanged (bump probably 'none')" | |
| else | |
| git add SteamAchievementLocalizer.py version_info.txt setup.py | |
| git commit -m "chore: bump version to ${{ steps.bump.outputs.new }}" | |
| git push | |
| fi | |
| - name: Create tag (with PAT) | |
| run: | | |
| TAG="v${{ steps.bump.outputs.new }}" | |
| if git rev-parse "$TAG" >/dev/null 2>&1; then | |
| echo "Tag $TAG already exists" | |
| exit 1 | |
| fi | |
| git tag -a "$TAG" -m "Release $TAG" | |
| git push origin "$TAG" | |
| - name: Trigger release workflow | |
| env: | |
| # Use PAT for workflow triggering (GITHUB_TOKEN doesn't have workflow:write permission) | |
| GH_TOKEN: ${{ secrets.PAT_TOKEN || secrets.ACTIONS_PAT || secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="v${{ steps.bump.outputs.new }}" | |
| echo "Triggering release workflow for tag: $TAG" | |
| # Wait a moment for the tag to be available | |
| sleep 5 | |
| # Try to trigger the release workflow directly | |
| if gh workflow run "release-on-tag.yml" --field tag="$TAG" --repo "${{ github.repository }}" 2>/dev/null; then | |
| echo "✅ Release workflow triggered successfully via workflow_dispatch!" | |
| echo "Check the Actions tab to monitor the build progress." | |
| else | |
| echo "⚠️ Direct workflow trigger failed, trying repository dispatch..." | |
| # Fallback: use repository dispatch | |
| if gh api repos/${{ github.repository }}/dispatches \ | |
| --method POST \ | |
| --field event_type='release-trigger' \ | |
| --field client_payload='{"tag":"'$TAG'"}' 2>/dev/null; then | |
| echo "✅ Release workflow triggered successfully via repository dispatch!" | |
| echo "Check the Actions tab to monitor the build progress." | |
| else | |
| echo "❌ Failed to auto-trigger release workflow." | |
| echo "Please manually run the 'Build & Release on Tag' workflow with tag: $TAG" | |
| echo "Go to: https://github.com/${{ github.repository }}/actions/workflows/release-on-tag.yml" | |
| echo "" | |
| echo "Or create a Personal Access Token with 'repo' and 'workflow' scopes:" | |
| echo "1. Go to GitHub Settings → Developer settings → Personal access tokens" | |
| echo "2. Generate token with 'repo' and 'workflow' scopes" | |
| echo "3. Add it as repository secret named 'PAT_TOKEN'" | |
| fi | |
| fi |