diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 864786267..df1071dc1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -454,6 +454,7 @@ jobs: timeout-minutes: 10 permissions: contents: read + pull-requests: read env: CI_REPO: Droid-Deck/DroidDeck-CI KEEP: 10 @@ -472,6 +473,34 @@ jobs: owner: Droid-Deck repositories: DroidDeck-CI + # What this build is, for the top of the release notes: the merged PR's title and the first + # paragraph of its description, or the commit's subject for a push made without a PR. + - name: Describe the change + env: + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + pr=$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/pulls" \ + --jq '[.[] | select(.merged_at != null and .base.ref == "main")] | first // empty') + if [ -n "$pr" ]; then + number=$(jq -r .number <<<"$pr") + title=$(jq -r .title <<<"$pr") + merged=$(jq -r '.merged_at[:10]' <<<"$pr") + summary=$(jq -r '.body // ""' <<<"$pr" | tr -d '\r' | { grep -v '^🤖' || true; } | + awk '!p && /^#/ { next } NF { p = 1; print; next } p { exit }' | head -n 6 | cut -c1-400) + { + echo "**Merged to main** - [PR #$number]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/pull/$number): $title (merged $merged)" + if [ -n "$summary" ]; then + echo + echo "$summary" + fi + } > notes-head.md + else + subject=$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA" --jq '.commit.message | split("\n")[0]') + echo "**Pushed to main** without a PR - $subject" > notes-head.md + fi + cat notes-head.md + - name: Publish to DroidDeck-CI id: publish env: @@ -481,7 +510,9 @@ jobs: tag=main-${GITHUB_SHA::7} cat signed/SHA256SUMS-*.txt > signed/SHA256SUMS.txt rm signed/SHA256SUMS-*.txt - notes="Signed build of $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$GITHUB_SHA - unreleased, for testing. + notes="$(cat notes-head.md) + + Signed build of $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/$GITHUB_SHA - in main, not yet in a DroidDeck release; for testing. Each apk installs over a DroidDeck release and keeps its data. \`standard\` is the normal app; the others are the same app under another package name, installed beside it. SHA-256: diff --git a/.github/workflows/pr-release-publish.yml b/.github/workflows/pr-release-publish.yml index 3ae1ab307..cbd532c42 100644 --- a/.github/workflows/pr-release-publish.yml +++ b/.github/workflows/pr-release-publish.yml @@ -115,11 +115,32 @@ jobs: permissions: actions: read contents: read + pull-requests: read steps: - uses: actions/download-artifact@v4 with: name: droiddeck-pr-signed-standard path: signed + # What this build is, for the top of the release notes: the PR's title and the first + # paragraph of its description. + - name: Describe the change + env: + GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ inputs.pr_number }} + run: | + set -euo pipefail + pr=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER") + title=$(jq -r .title <<<"$pr") + summary=$(jq -r '.body // ""' <<<"$pr" | tr -d '\r' | { grep -v '^🤖' || true; } | + awk '!p && /^#/ { next } NF { p = 1; print; next } p { exit }' | head -n 6 | cut -c1-400) + { + echo "**Not merged** - a test build of open [PR #$PR_NUMBER]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/pull/$PR_NUMBER): $title" + if [ -n "$summary" ]; then + echo + echo "$summary" + fi + } > notes-head.md + cat notes-head.md # A token of the org's "DroidDeck CI Publisher" app, as build.yml's announce job uses. - uses: actions/create-github-app-token@v2 id: ci-token @@ -140,7 +161,9 @@ jobs: tag="pr-$PR_NUMBER" apk="DroidDeck-$LABEL.apk" sha=$(sha256sum "signed/$apk" | cut -d ' ' -f 1) - notes="Source: https://github.com/$GITHUB_REPOSITORY/pull/$PR_NUMBER + notes="$(cat notes-head.md) + + Source: https://github.com/$GITHUB_REPOSITORY/pull/$PR_NUMBER Commit: $HEAD_SHA APK SHA-256: $sha" if ! gh release view "$tag" -R "$repo" >/dev/null 2>&1; then