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
15 changes: 10 additions & 5 deletions .github/auto-changeset/github.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ function encodePath(path) {
}

export function createGitHubClient({ token, repository, fetchImpl = fetch }) {
const { owner, name } = repositoryParts(repository)
const apiBase = `https://api.github.com/repos/${owner}/${name}`
async function request(path, options = {}) {
const response = await fetchImpl(`${apiBase}${path}`, {
const { owner } = repositoryParts(repository)
async function request(path, options = {}, targetRepository = repository) {
const target = repositoryParts(targetRepository)
const response = await fetchImpl(`https://api.github.com/repos/${target.owner}/${target.name}${path}`, {
...options,
headers: {
'accept': 'application/vnd.github+json',
Expand Down Expand Up @@ -67,8 +67,11 @@ export function createGitHubClient({ token, repository, fetchImpl = fetch }) {
throw error
}
},
getRef: ref => request(`/git/ref/${encodePath(ref)}`),
getRef: (ref, targetRepository = repository) => request(`/git/ref/${encodePath(ref)}`, {}, targetRepository),
getCommit: sha => request(`/git/commits/${sha}`),
compareCommits: (base, head) => request(`/compare/${base}...${head}`),
getStatus: sha => request(`/commits/${sha}/status`),
createStatus: (sha, status) => request(`/statuses/${sha}`, { method: 'POST', body: JSON.stringify(status) }),
createBlob: content => request('/git/blobs', { method: 'POST', body: JSON.stringify({ content, encoding: 'utf-8' }) }),
createTree: (baseTree, tree) => request('/git/trees', { method: 'POST', body: JSON.stringify({ base_tree: baseTree, tree }) }),
createCommit: (message, tree, parents) => request('/git/commits', { method: 'POST', body: JSON.stringify({ message, tree, parents }) }),
Expand All @@ -86,5 +89,7 @@ export function createGitHubClient({ token, repository, fetchImpl = fetch }) {
},
createBranch: async (branch, sha) => request('/git/refs', { method: 'POST', body: JSON.stringify({ ref: `refs/heads/${branch}`, sha }) }),
createPullRequest: input => request('/pulls', { method: 'POST', body: JSON.stringify(input) }),
listReleasePullRequests: (base, headRef) => request(`/pulls?state=open&base=${encodeURIComponent(base)}&head=${encodeURIComponent(`${owner}:${headRef}`)}`),
dispatchPrValidation: (number, ref) => request('/actions/workflows/pr-ci-manual.yml/dispatches', { method: 'POST', body: JSON.stringify({ ref, inputs: { pr_number: String(number) } }) }),
}
}
12 changes: 9 additions & 3 deletions .github/auto-changeset/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ async function prepareEntry(client, pullRequest, files) {
}
}

export async function processPullRequest(client, number) {
export async function processPullRequest(client, number, { expectedHeadSha } = {}) {
const pullRequest = await client.getPullRequest(number)
if (expectedHeadSha && pullRequest.head.sha !== expectedHeadSha) {
throw new Error('PR head changed before release intent preparation; approve the latest run.')
}
const files = await client.getPullRequestFiles(number)
const entry = await prepareEntry(client, pullRequest, files)
if (!entry) {
Expand All @@ -138,8 +141,11 @@ export async function processPullRequest(client, number) {
return { action: 'commented', number }
}
const ref = await client.getRef(`heads/${pullRequest.head.ref}`)
await commitChangesets(client, pullRequest.head.ref, ref.object.sha, [entry])
return { action: 'committed', number, path: entry.path }
if (ref.object.sha !== pullRequest.head.sha) {
throw new Error('PR head changed while preparing its release intent; retry the latest run.')
}
const sha = await commitChangesets(client, pullRequest.head.ref, pullRequest.head.sha, [entry])
return { action: 'committed', number, path: entry.path, sha }
}

export async function backfillPullRequests(client, numbers, { runId = `${Date.now()}` } = {}) {
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build and Test
Expand All @@ -18,7 +22,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [22, 24]
node-version: [22.23.4, 24.22.1]
runs-on: ${{ matrix.os }}
# Remote Caching enabled - configure TURBO_TOKEN and TURBO_TEAM in repository settings
env:
Expand All @@ -34,7 +38,7 @@ jobs:
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0

- name: Setup Node.js environment
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
Expand All @@ -53,12 +57,15 @@ jobs:
- name: Build
run: pnpm build

- name: Check CommonJS plugin consumers
run: pnpm check:cjs

- name: Typecheck
if: ${{ matrix.os != 'windows-latest' || matrix.node-version != 22 }}
if: ${{ matrix.os != 'windows-latest' || matrix.node-version != '22.23.4' }}
run: pnpm typecheck

- name: Typecheck (Windows Node 22)
if: ${{ matrix.os == 'windows-latest' && matrix.node-version == 22 }}
if: ${{ matrix.os == 'windows-latest' && matrix.node-version == '22.23.4' }}
run: pnpm exec turbo run typecheck --concurrency=1

- name: TSD
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ jobs:
uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0

- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
node-version: 24.22.1
cache: pnpm
cache-dependency-path: pnpm-lock.yaml

Expand Down
30 changes: 27 additions & 3 deletions .github/workflows/release-intent-auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,38 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 1
ref: ${{ github.event.pull_request.base.sha || github.sha }}
persist-credentials: false

- name: Setup Node.js environment
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
node-version: 24.22.1

- name: Validate GitHub App configuration
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository }}
env:
APP_CLIENT_ID: ${{ vars.REPOCTL_APP_CLIENT_ID }}
APP_PRIVATE_KEY_CONFIGURED: ${{ secrets.REPOCTL_APP_PRIVATE_KEY != '' }}
run: |
if { [ -n "$APP_CLIENT_ID" ] && [ "$APP_PRIVATE_KEY_CONFIGURED" != 'true' ]; } ||
{ [ -z "$APP_CLIENT_ID" ] && [ "$APP_PRIVATE_KEY_CONFIGURED" = 'true' ]; }; then
echo 'Configure both REPOCTL_APP_CLIENT_ID and REPOCTL_APP_PRIVATE_KEY.' >&2
exit 1
fi

- name: Create GitHub App token
if: ${{ vars.REPOCTL_APP_CLIENT_ID != '' && (github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository) }}
id: app-token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
client-id: ${{ vars.REPOCTL_APP_CLIENT_ID }}
private-key: ${{ secrets.REPOCTL_APP_PRIVATE_KEY }}
permission-contents: write
permission-pull-requests: write

- name: Generate or backfill changesets
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_TOKEN: ${{ steps.app-token.outputs.token || github.token }}
PR_NUMBERS: ${{ inputs.pr_numbers }}
run: node .github/auto-changeset/index.mjs
76 changes: 62 additions & 14 deletions .github/workflows/release-intent-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,82 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false

- name: Skip generated release PRs
- name: Check out trusted release validation dependencies
if: startsWith(github.head_ref, 'pnpm-release/') || startsWith(github.head_ref, 'release/pnpm-version')
run: echo "Generated pnpm release PR detected; skipping validation"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.base.sha }}
path: release-validation-tools
persist-credentials: false

- name: Set up the trusted validator runtime
if: startsWith(github.head_ref, 'pnpm-release/') || startsWith(github.head_ref, 'release/pnpm-version')
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24.22.1

- name: Install the frozen base tools without lifecycle scripts
if: startsWith(github.head_ref, 'pnpm-release/') || startsWith(github.head_ref, 'release/pnpm-version')
working-directory: release-validation-tools
shell: bash
run: |
set -euo pipefail
npm install --global corepack@0.36.0
corepack enable
pnpm install --frozen-lockfile --ignore-scripts

- name: Validate exact release preparation
if: startsWith(github.head_ref, 'pnpm-release/') || startsWith(github.head_ref, 'release/pnpm-version')
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
BASE_REF: ${{ github.base_ref }}
shell: bash
run: |
set -euo pipefail
"$GITHUB_WORKSPACE/release-validation-tools/node_modules/.bin/repo" release validate-preparation \
--base "$BASE_SHA" --head "$HEAD_SHA" --branch "$BASE_REF" --json

- name: Validate release intent presence
if: ${{ !startsWith(github.head_ref, 'pnpm-release/') && !startsWith(github.head_ref, 'release/pnpm-version') }}
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
shell: bash
run: |
set -euo pipefail

base_sha="${{ github.event.pull_request.base.sha }}"
head_sha="${{ github.event.pull_request.head.sha }}"
changed_files="$(git diff --name-only "$base_sha" "$head_sha")"
changed_files="$(mktemp)"
trap 'rm -f "$changed_files"' EXIT
if ! git diff --name-status --no-renames -z "$BASE_SHA" "$HEAD_SHA" -- > "$changed_files"; then
echo "Unable to inspect the frozen PR changes; release intent validation failed." >&2
exit 1
fi

publishable_changes="$(printf '%s\n' "$changed_files" | \
rg '^packages/[^/]+/' \
| rg -v '/dist/' \
|| true)"
publishable_changes=()
has_release_intent=false
while IFS= read -r -d '' status && IFS= read -r -d '' file; do
case "$file" in
packages/*/*)
case "$file" in
*/dist/*) ;;
*) publishable_changes+=("$file") ;;
esac
;;
esac
case "$status:$file" in
[AM]:.changeset/?*.md) has_release_intent=true ;;
esac
done < "$changed_files"

if [ -z "$publishable_changes" ]; then
if [ "${#publishable_changes[@]}" -eq 0 ]; then
echo "No publishable package changes detected"
exit 0
fi

release_intents="$(printf '%s\n' "$changed_files" | rg '^\.changeset/.+\.md$' || true)"

if [ -n "$release_intents" ]; then
if [ "$has_release_intent" = true ]; then
echo "pnpm release intent detected"
exit 0
fi
Expand All @@ -53,5 +101,5 @@ jobs:
echo "Create one with: pnpm change"
echo
echo "Changed files:"
printf '%s\n' "$publishable_changes"
printf '%s\n' "${publishable_changes[@]}"
exit 1
Loading
Loading