release: 3.1.2 #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: Sync Release-As from release PR title | |
| on: | |
| pull_request: | |
| types: [edited] | |
| permissions: | |
| contents: write | |
| jobs: | |
| sync: | |
| if: >- | |
| github.event.pull_request.base.ref == 'master' && | |
| startsWith(github.event.pull_request.head.ref, 'release-please--') && | |
| github.event.changes.title != null | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Extract versions from old and new title | |
| id: parse | |
| env: | |
| NEW_TITLE: ${{ github.event.pull_request.title }} | |
| OLD_TITLE: ${{ github.event.changes.title.from }} | |
| run: | | |
| # Anchored on pull-request-title-pattern "release: ${version}" from release-please-config.json. | |
| extract() { | |
| echo "$1" | grep -oE '^release:[[:space:]]+v?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?' \ | |
| | sed -E 's/^release:[[:space:]]+v?//' | |
| } | |
| NEW_VERSION=$(extract "$NEW_TITLE") | |
| OLD_VERSION=$(extract "$OLD_TITLE") | |
| echo "old=$OLD_VERSION" | |
| echo "new=$NEW_VERSION" | |
| if [ -z "$NEW_VERSION" ]; then | |
| echo "::notice::No semver in new title; nothing to do." | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| if [ "$NEW_VERSION" = "$OLD_VERSION" ]; then | |
| echo "::notice::Version unchanged ($NEW_VERSION); not pushing." | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Check out master | |
| if: steps.parse.outputs.skip != 'true' | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: master | |
| token: ${{ secrets.RELEASE_PLEASE_TOKEN }} | |
| fetch-depth: 1 | |
| - name: Push empty Release-As commit | |
| if: steps.parse.outputs.skip != 'true' | |
| env: | |
| VERSION: ${{ steps.parse.outputs.version }} | |
| run: | | |
| git config user.name "release-as-bot" | |
| git config user.email "release-as-bot@users.noreply.github.com" | |
| git commit --allow-empty -m "chore: pin next release | |
| Release-As: ${VERSION}" | |
| git push origin master |