Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,53 @@ jobs:
echo "CHANGELOG_EOF"
} >> $GITHUB_OUTPUT

- name: Get contributors from changelog PRs
id: contributors
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHANGELOG: ${{ steps.changelog.outputs.body }}
run: |
# Extract PR numbers from changelog links like [#123](...).
PR_NUMBERS=$(echo "$CHANGELOG" | grep -oE '\[#[0-9]+\]' | tr -d '[]#' | sort -u)

CONTRIBUTORS=""
if [ -n "$PR_NUMBERS" ]; then
# Build a single GraphQL query to fetch all PR authors.
QUERY='{ repository(owner: "${{ github.repository_owner }}", name: "${{ github.event.repository.name }}") {'
while IFS= read -r PR; do
[ -n "$PR" ] && QUERY="$QUERY pr$PR: pullRequest(number: $PR) { author { login } }"
done <<< "$PR_NUMBERS"
QUERY="$QUERY } }"

CONTRIBUTORS=$(gh api graphql -f query="$QUERY" \
--jq '[.data.repository[].author.login] | unique | map("@" + .) | join(", ")')
fi
echo "list=$CONTRIBUTORS" >> $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 }}
CONTRIBUTORS: ${{ steps.contributors.outputs.list }}
run: |
PRERELEASE_FLAG=""
if [[ "${{ steps.version.outputs.prerelease }}" == "true" ]]; then
PRERELEASE_FLAG="--prerelease"
fi

NOTES="$BODY"
if [ -n "$CONTRIBUTORS" ]; then
NOTES="$(printf '%s\n\n**Contributors:** %s' "$BODY" "$CONTRIBUTORS")"
fi

gh release create "$TAG" \
--target "$MERGE_SHA" \
--title "$TAG" \
--notes "$BODY" \
--notes "$NOTES" \
$PRERELEASE_FLAG \
"build/sqlite-database-integration.zip"
"build/plugin-sqlite-database-integration.zip"

- name: Delete release branch
env:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release-wporg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ jobs:
run: |
gh release download "$RELEASE_TAG" \
--repo "${{ github.repository }}" \
--pattern "sqlite-database-integration.zip" \
--pattern "plugin-sqlite-database-integration.zip" \
--dir .
unzip sqlite-database-integration.zip
unzip plugin-sqlite-database-integration.zip

- name: Verify release metadata
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
VERSION="${RELEASE_TAG#v}"
bash bin/verify-release-metadata.sh sqlite-database-integration "$VERSION"
bash bin/verify-release-metadata.sh plugin-sqlite-database-integration "$VERSION"

- name: Deploy to WordPress.org
uses: 10up/action-wordpress-plugin-deploy@v2
env:
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SLUG: sqlite-database-integration
BUILD_DIR: sqlite-database-integration
BUILD_DIR: plugin-sqlite-database-integration
2 changes: 1 addition & 1 deletion bin/prepare-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ if git rev-parse "$LATEST_TAG" >/dev/null 2>&1; then
--limit 100 \
--json number,title,mergedAt \
--jq "sort_by(.mergedAt) | reverse | .[]
| \"* \\(.title) ([#\\(.number)]($REPO_URL/pull/\\(.number)))\"" 2>/dev/null || true)"
| \"* \\(.title) ([#\\(.number)]($REPO_URL/pull/\\(.number)))\"")"
fi

if [ -z "$CHANGELOG" ]; then
Expand Down
Loading