Skip to content

Monorepo setup + release automation #1

Monorepo setup + release automation

Monorepo setup + release automation #1

Workflow file for this run

name: Publish release
on:
pull_request:
types: [closed]
branches: [trunk]
jobs:
publish-release:
name: Publish draft 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
- name: Publish draft release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.version.outputs.tag }}
MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }}
run: |
# Get the current release body and remove the PR note.
BODY=$(gh release view "$TAG" --json body --jq '.body' 2>/dev/null || echo "")
CLEAN_BODY=$(echo "$BODY" | grep -v "^> To publish the release, review and merge:")
# Publish the release, targeting the merge commit.
gh release edit "$TAG" \
--draft=false \
--target "$MERGE_SHA" \
--notes "$CLEAN_BODY"
- name: Delete release branch
env:
BRANCH: ${{ github.event.pull_request.head.ref }}
run: git push origin --delete "$BRANCH" 2>/dev/null || true