From 3f20c0136356650c321269a7027e99426a81b78b Mon Sep 17 00:00:00 2001 From: Liu Liu Date: Fri, 4 Dec 2026 12:14:06 -0800 Subject: [PATCH] ci: add changeset check with skip label Follow up on #411 with the same label-aware changeset check as the other custom elements. Label generated release tracking PRs and document the required-check setting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .changeset/README.md | 9 ++++++ .github/workflows/check-for-changeset.yml | 37 +++++++++++++++++++++++ .github/workflows/release-tracking.yml | 7 +++++ 3 files changed, 53 insertions(+) create mode 100644 .github/workflows/check-for-changeset.yml diff --git a/.changeset/README.md b/.changeset/README.md index bfd2a40..0c363dc 100644 --- a/.changeset/README.md +++ b/.changeset/README.md @@ -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 diff --git a/.github/workflows/check-for-changeset.yml b/.github/workflows/check-for-changeset.yml new file mode 100644 index 0000000..78d966b --- /dev/null +++ b/.github/workflows/check-for-changeset.yml @@ -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 diff --git a/.github/workflows/release-tracking.yml b/.github/workflows/release-tracking.yml index 7edbee4..e0f6157 100644 --- a/.github/workflows/release-tracking.yml +++ b/.github/workflows/release-tracking.yml @@ -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 @@ -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'