Release 2.2.20-testing.1 #3
Workflow file for this run
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: Publish release | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: [trunk] | |
| concurrency: | |
| group: release-publish | |
| cancel-in-progress: false | |
| jobs: | |
| publish-release: | |
| name: Build plugin and create GitHub release | |
| if: >- | |
| github.repository == 'WordPress/sqlite-database-integration' | |
| && github.event.pull_request.merged == true | |
| && startsWith(github.event.pull_request.head.ref, 'release/') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Extract version from branch name | |
| id: version | |
| env: | |
| BRANCH: ${{ github.event.pull_request.head.ref }} | |
| run: | | |
| # Extract version from branch name (release/v2.3.0 → 2.3.0). | |
| VERSION="${BRANCH#release/v}" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "tag=v$VERSION" >> $GITHUB_OUTPUT | |
| # Versions with a hyphen (e.g., 2.3.0-beta.1) are prereleases. | |
| if [[ "$VERSION" == *-* ]]; then | |
| echo "prerelease=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "prerelease=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Set up PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.2' | |
| - name: Build plugin zip | |
| run: composer run build-sqlite-plugin-zip | |
| - name: Extract changelog from readme.txt | |
| id: changelog | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| README="packages/plugin-sqlite-database-integration/readme.txt" | |
| # Extract the changelog entry for this version. | |
| CHANGELOG=$(awk -v version="$VERSION" ' | |
| $0 == "= " version " =" { found = 1; next } | |
| found && /^= / { exit } | |
| found { print } | |
| ' "$README" | sed -e '/./,$!d' -e :a -e '/^\s*$/{ $d; N; ba; }') # Trim leading/trailing blank lines. | |
| { | |
| echo "body<<CHANGELOG_EOF" | |
| echo "$CHANGELOG" | |
| echo "CHANGELOG_EOF" | |
| } >> $GITHUB_OUTPUT | |
| - name: Create GitHub release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TAG: ${{ steps.version.outputs.tag }} | |
| MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }} | |
| BODY: ${{ steps.changelog.outputs.body }} | |
| run: | | |
| PRERELEASE_FLAG="" | |
| if [[ "${{ steps.version.outputs.prerelease }}" == "true" ]]; then | |
| PRERELEASE_FLAG="--prerelease" | |
| fi | |
| gh release create "$TAG" \ | |
| --target "$MERGE_SHA" \ | |
| --title "$TAG" \ | |
| --notes "$BODY" \ | |
| $PRERELEASE_FLAG \ | |
| "build/sqlite-database-integration.zip" | |
| - name: Delete release branch | |
| env: | |
| BRANCH: ${{ github.event.pull_request.head.ref }} | |
| run: git push origin --delete "$BRANCH" 2>/dev/null || true |