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
17 changes: 17 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -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:
- "*"
70 changes: 70 additions & 0 deletions .github/workflows/label-pr.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ jobs:
fi
gh release create "$TAG" \
--title "$TAG" \
--notes "" \
--generate-notes \
--latest=legacy
echo "Created release $TAG"

Expand Down
Loading