105 lines
2.9 KiB
YAML
105 lines
2.9 KiB
YAML
name: Changeset Status
|
|
|
|
on:
|
|
pull_request:
|
|
types:
|
|
- opened
|
|
- reopened
|
|
- synchronize
|
|
- labeled
|
|
- unlabeled
|
|
- ready_for_review
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
changeset-status:
|
|
if: ${{ !github.event.pull_request.draft }}
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
BASE_REF: ${{ github.event.pull_request.base.ref }}
|
|
PR_LABELS: ${{ join(github.event.pull_request.labels.*.name, ',') }}
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 10.25.0
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 24
|
|
cache: pnpm
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Require a changeset for releasable package changes
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
if [[ ",${PR_LABELS}," == *",no-changeset-needed,"* ]]; then
|
|
echo "Skipping changeset requirement because the PR is labeled no-changeset-needed."
|
|
exit 0
|
|
fi
|
|
|
|
changed_files="$(git diff --name-only "origin/${BASE_REF}...HEAD")"
|
|
|
|
if [[ -z "${changed_files}" ]]; then
|
|
echo "No changed files detected."
|
|
exit 0
|
|
fi
|
|
|
|
echo "Changed files:"
|
|
printf '%s\n' "${changed_files}"
|
|
|
|
needs_changeset=false
|
|
has_changeset=false
|
|
|
|
while IFS= read -r file; do
|
|
[[ -z "${file}" ]] && continue
|
|
|
|
case "${file}" in
|
|
.changeset/*.md)
|
|
if [[ "${file}" != ".changeset/README.md" ]]; then
|
|
has_changeset=true
|
|
fi
|
|
;;
|
|
packages/tokens/*)
|
|
needs_changeset=true
|
|
;;
|
|
packages/ui/package.json)
|
|
needs_changeset=true
|
|
;;
|
|
packages/ui/src/test/*|packages/ui/src/**/*.test.ts|packages/ui/src/**/*.test.tsx)
|
|
;;
|
|
packages/ui/src/*)
|
|
needs_changeset=true
|
|
;;
|
|
esac
|
|
done <<< "${changed_files}"
|
|
|
|
if [[ "${needs_changeset}" != "true" ]]; then
|
|
echo "No releasable package changes detected."
|
|
exit 0
|
|
fi
|
|
|
|
if [[ "${has_changeset}" != "true" ]]; then
|
|
echo "::error::Changes to @ai-ui/ui or @ai-ui/tokens require a changeset file under .changeset/."
|
|
echo "::error::If this PR is intentionally docs-only, test-only, or otherwise non-releasable, apply the no-changeset-needed label."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Validate pending changesets
|
|
run: pnpm changeset:status --since "origin/${BASE_REF}"
|
|
|
|
- name: Validate registry metadata
|
|
run: pnpm registry:check
|