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
9 changes: 9 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and describe the change. Commit the generated `.changeset/*.md` file with your P
Include runtime dependency updates that need a release, especially security fixes.
Docs, tests, and development-only tooling changes do not normally need a changeset.

The **Check for changeset** PR check requires an added or updated `.changeset/*.md`
file other than this README, or the `skip-changeset` label. Use the label for changes
that do not need a release, including development-only dependency bumps, not as a
blanket exemption for runtime dependency updates. Adding or removing the label
reruns the check; other CI checks still run. Release tracking PRs receive this
label automatically because they consume existing changesets.
To block merging without this check, make **Check for changeset** a required status
check in the repository's branch protection or ruleset.

## Preparing and publishing a release

The **Release tracking** workflow opens or updates a PR on pushes to `main` when
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/check-for-changeset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Check for changeset

on:
pull_request:
types: [opened, reopened, synchronize, labeled, unlabeled]

permissions:
contents: read
pull-requests: read

jobs:
check-for-changeset:
name: Check for changeset
runs-on: ubuntu-latest
steps:
- name: Check for changeset or skip label
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail

labels="$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER" --jq '.labels[].name')"
if grep -Fxq 'skip-changeset' <<<"$labels"; then
echo 'Skipping the changeset requirement because skip-changeset is set.'
exit 0
fi

changed_files="$(gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/files" \
--jq '.[] | select(.status != "removed" and .filename != ".changeset/README.md") | .filename')"
if grep -Eq '^\.changeset/[^/]+\.md$' <<<"$changed_files"; then
echo 'Found a changeset in this pull request.'
exit 0
fi

echo '::error::Add a release note with npm run changeset, or apply skip-changeset if this PR does not need a release.'
exit 1
7 changes: 7 additions & 0 deletions .github/workflows/release-tracking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
cache: npm
- run: npm ci --ignore-scripts
- name: Create or update release tracking pull request
id: changesets
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3 (Changesets CLI v2)
with:
version: npm run version-packages
Expand All @@ -39,3 +40,9 @@ jobs:
createGithubReleases: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Skip changeset requirement for the release tracking pull request
if: steps.changesets.outputs.pullRequestNumber != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.changesets.outputs.pullRequestNumber }}
run: gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/labels" -f 'labels[]=skip-changeset'