From 602c9d0a6835fd3706d885ab9b32d14e5b5c1f07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isaac=20Rold=C3=A1n?= Date: Tue, 28 Apr 2026 13:08:25 +0200 Subject: [PATCH] Auto-label PRs and use native release notes generation Replaces the empty release body with GitHub's native --generate-notes output, made useful by two new pieces of automation: - .github/workflows/label-pr.yml runs on PR open/sync and inspects any changeset files added in the PR. PRs with no changeset get the no-changelog label; PRs with a changeset get an Area: @shopify/... label derived from the packages in the changeset frontmatter. Multi-package changesets fold to Area: @shopify/cli. - .github/release.yml configures --generate-notes to exclude PRs labeled no-changelog and to bucket the rest into App / Theme / CLI / Other categories using the area labels. Fork PRs are skipped by the labeler (read-only token); they fall into the Other category in release notes until labeled by hand. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/release.yml | 17 +++++++++ .github/workflows/label-pr.yml | 70 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 2 +- 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 .github/release.yml create mode 100644 .github/workflows/label-pr.yml diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 00000000000..7e69c56f707 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,17 @@ +changelog: + exclude: + labels: + - no-changelog + categories: + - title: App + labels: + - "Area: @shopify/app" + - title: Theme + labels: + - "Area: @shopify/theme" + - title: CLI + labels: + - "Area: @shopify/cli" + - title: Other + labels: + - "*" diff --git a/.github/workflows/label-pr.yml b/.github/workflows/label-pr.yml new file mode 100644 index 00000000000..2838ec85e6b --- /dev/null +++ b/.github/workflows/label-pr.yml @@ -0,0 +1,70 @@ +name: Label PR + +on: + pull_request: + types: + - opened + - synchronize + - reopened + +jobs: + label: + name: Apply labels from changesets + # Skip fork PRs — GITHUB_TOKEN is read-only there and the labeling would fail. + if: github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: read + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Determine and apply label + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUM: ${{ github.event.pull_request.number }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + run: | + set -euo pipefail + + CHANGESETS=$(git diff --name-only --diff-filter=A "$BASE_SHA" HEAD -- '.changeset/*.md' | grep -v 'README\.md$' || true) + + if [ -z "$CHANGESETS" ]; then + TARGET="no-changelog" + else + HAS_APP=0 + HAS_THEME=0 + HAS_OTHER=0 + while IFS= read -r FILE; do + [ -z "$FILE" ] && continue + FRONTMATTER=$(awk '/^---$/{c++; if (c==2) exit; next} c==1' "$FILE") + while IFS= read -r PKG; do + case "$PKG" in + @shopify/app|@shopify/create-app) HAS_APP=1 ;; + @shopify/theme) HAS_THEME=1 ;; + @shopify/*) HAS_OTHER=1 ;; + esac + done < <(echo "$FRONTMATTER" | grep -oE "'@shopify/[a-z-]+'" | tr -d "'") + done <<< "$CHANGESETS" + + AREA_COUNT=$((HAS_APP + HAS_THEME + HAS_OTHER)) + if [ "$AREA_COUNT" -eq 1 ] && [ "$HAS_APP" -eq 1 ]; then + TARGET="Area: @shopify/app" + elif [ "$AREA_COUNT" -eq 1 ] && [ "$HAS_THEME" -eq 1 ]; then + TARGET="Area: @shopify/theme" + else + TARGET="Area: @shopify/cli" + fi + fi + + echo "Target label: $TARGET" + + # Idempotently keep only the target label from the managed set. + for L in "no-changelog" "Area: @shopify/app" "Area: @shopify/theme" "Area: @shopify/cli"; do + if [ "$L" = "$TARGET" ]; then + gh pr edit "$PR_NUM" --add-label "$L" + else + gh pr edit "$PR_NUM" --remove-label "$L" 2>/dev/null || true + fi + done diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4695f9652a4..f5e9118d728 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -166,7 +166,7 @@ jobs: fi gh release create "$TAG" \ --title "$TAG" \ - --notes "" \ + --generate-notes \ --latest=legacy echo "Created release $TAG"