diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index aab24bd38..73f858990 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -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: diff --git a/.github/workflows/release-wporg.yml b/.github/workflows/release-wporg.yml index 98128679d..bca92d569 100644 --- a/.github/workflows/release-wporg.yml +++ b/.github/workflows/release-wporg.yml @@ -33,16 +33,16 @@ 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 @@ -50,4 +50,4 @@ jobs: 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 diff --git a/bin/prepare-release.sh b/bin/prepare-release.sh index eba71a405..5170291dc 100755 --- a/bin/prepare-release.sh +++ b/bin/prepare-release.sh @@ -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