name: Bump version on PR merge on: pull_request: branches: [master] types: [closed] permissions: contents: write jobs: bump: # Only run when the PR was actually merged (not just closed) if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v5 with: # fetch-depth 2 so git diff HEAD~1 HEAD works for detecting changed files fetch-depth: 2 # Use a PAT/GitHub App token so the pushed commit can trigger deploy.yml and other workflows token: ${{ secrets.RELEASE_BOT_TOKEN }} - name: Set up Node uses: actions/setup-node@v6 with: node-version: '24.x' cache: npm - name: Determine bump type from PR labels id: bump run: | LABELS='${{ toJSON(github.event.pull_request.labels.*.name) }}' if echo "$LABELS" | grep -q '"major"'; then echo "type=major" >> "$GITHUB_OUTPUT" elif echo "$LABELS" | grep -q '"minor"'; then echo "type=minor" >> "$GITHUB_OUTPUT" else echo "type=patch" >> "$GITHUB_OUTPUT" fi - name: Extract base version (master before this PR merged) id: base run: | BASE=$(git show HEAD~1:public/versioning.js \ | grep -oP 'const VERSION = "\K[\d.]+') echo "version=$BASE" >> "$GITHUB_OUTPUT" echo "Base version on master before merge: $BASE" - name: Run version bump script run: | node scripts/bump-version.js ${{ steps.bump.outputs.type }} \ --base-version ${{ steps.base.outputs.version }} - name: Commit and push bump run: | NEW_VERSION=$(node -e " const m = require('fs') .readFileSync('public/versioning.js', 'utf8') .match(/const VERSION = \"([\d.]+)\"/); console.log(m[1]); ") git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add . # Only commit if something actually changed if ! git diff --cached --quiet; then git commit -m "chore: bump version to $NEW_VERSION" git push echo "Pushed version bump → $NEW_VERSION" else echo "Nothing changed, skipping commit." fi