Skip to content

Commit 401f6c4

Browse files
chore: use the shared release workflows (#136)
Replaces local copies of release-prepare.yml and changeset-check.yml with thin callers into Nano-Collective/.github, and turns on validate-changesets. Two things this fixes rather than just deduplicates. The local changeset-check ran pull_request_target, then checked out `github.event.pull_request.head.sha` with allow-unsafe-pr-checkout: true, in a job holding a pull-requests: write token. Contributor-controlled code on disk in a privileged job. Not exploitable — nothing executed the tree — but one added build step from being so, and the checkout was never needed. The shared version uses pulls.listFiles, so there is nothing on disk at all. This repo also had no changeset validator: nothing checked that the package name inside a changeset resolves. That gap is what broke release-prepare on nanocoder main (#1065). validate-changesets closes it without adding a script here. changeset:version is unchanged (`changeset version && node scripts/normalize-changelog.js`) — the shared workflow takes the script name as an input precisely so repos that post-process CHANGELOG.md keep doing so. Claude-Session: https://claude.ai/code/session_01PZY52ePXLjwG9TaQgq2cHT Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 195cbc4 commit 401f6c4

3 files changed

Lines changed: 11 additions & 112 deletions

File tree

Lines changed: 3 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,16 @@
11
name: Changeset Check
22

3-
# Friendly, NON-BLOCKING nudge: if a pull request changes source but adds no
4-
# changeset, leave a single comment explaining how to add one. If a changeset is
5-
# later added, the comment is removed. This never fails the build - it only
6-
# keeps the release-notes pipeline fed.
3+
# Thin caller for the shared org workflow. Non-blocking: comments when a pull
4+
# request adds no changeset, removes the comment when one appears.
75

86
on:
97
pull_request_target:
108
types: [opened, synchronize, reopened]
119
branches: [main]
1210

1311
permissions:
14-
contents: read
1512
pull-requests: write
1613

1714
jobs:
1815
changeset-check:
19-
runs-on: ubuntu-latest
20-
if: github.head_ref != 'changeset-release/main'
21-
steps:
22-
- name: Checkout PR head
23-
uses: actions/checkout@v7
24-
with:
25-
ref: ${{ github.event.pull_request.head.sha }}
26-
fetch-depth: 0
27-
allow-unsafe-pr-checkout: true
28-
29-
- name: Detect a changeset in this PR
30-
id: detect
31-
env:
32-
BASE_SHA: ${{ github.event.pull_request.base.sha }}
33-
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
34-
run: |
35-
ADDED=$(git diff --name-only --diff-filter=A "$BASE_SHA" "$HEAD_SHA" \
36-
| { grep -E '^\.changeset/.+\.md$' || true; } \
37-
| { grep -v -E '^\.changeset/README\.md$' || true; })
38-
if [ -n "$ADDED" ]; then
39-
echo "has-changeset=true" >> "$GITHUB_OUTPUT"
40-
else
41-
echo "has-changeset=false" >> "$GITHUB_OUTPUT"
42-
fi
43-
44-
- name: Comment if missing (or clean up if present)
45-
uses: actions/github-script@v9
46-
with:
47-
script: |
48-
const marker = '<!-- changeset-check -->';
49-
const hasChangeset = ${{ steps.detect.outputs.has-changeset }};
50-
const {owner, repo} = context.repo;
51-
const issue_number = context.issue.number;
52-
53-
const comments = await github.paginate(github.rest.issues.listComments, {
54-
owner, repo, issue_number,
55-
});
56-
const existing = comments.find(c => c.body && c.body.includes(marker));
57-
58-
if (hasChangeset) {
59-
if (existing) {
60-
await github.rest.issues.deleteComment({owner, repo, comment_id: existing.id});
61-
}
62-
return;
63-
}
64-
65-
const body = [
66-
marker,
67-
"### No changeset found",
68-
"",
69-
"This PR does not add a changeset, so it will not appear in the changelog or trigger a release.",
70-
"",
71-
"If the change is user-facing, add one:",
72-
"",
73-
"```bash",
74-
"pnpm changeset",
75-
"```",
76-
"",
77-
"Pick a bump (patch / minor / major) and write the changelog entry in our usual voice (`Added **X**... Closes #<issue>.`), then commit the generated `.changeset/*.md` file.",
78-
"",
79-
"If this PR is docs-only or a chore that needs no release note, you can ignore this - or run `pnpm changeset --empty` to record that intentionally.",
80-
].join("\n");
81-
82-
if (existing) {
83-
await github.rest.issues.updateComment({owner, repo, comment_id: existing.id, body});
84-
} else {
85-
await github.rest.issues.createComment({owner, repo, issue_number, body});
86-
}
16+
uses: Nano-Collective/.github/.github/workflows/changeset-check.yml@main

.github/workflows/pr-checks.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ permissions:
1616
jobs:
1717
pr-checks:
1818
uses: Nano-Collective/.github/.github/workflows/pr-checks.yml@main
19+
with:
20+
validate-changesets: true
Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,19 @@
11
name: Prepare Release (Version PR)
22

3-
# Keeps a single open "Version Packages" pull request up to date. As changesets
4-
# land on main, this PR accumulates them, bumps package.json, and rolls the
5-
# entries into CHANGELOG.md (in our house style, via changeset:version).
3+
# Thin caller for the shared org workflow. Everything lives in
4+
# Nano-Collective/.github — change it there and every repo picks it up.
65
#
7-
# This workflow NEVER publishes. Merging the Version PR pushes a version bump to
8-
# main, which the existing release.yml detects and publishes. That split keeps
9-
# release.yml the single source of truth for publishing.
6+
# This never publishes. Merging the Version Packages PR it maintains pushes a
7+
# version bump to main, which release.yml detects and publishes.
108

119
on:
1210
push:
1311
branches: [main]
1412

15-
# Avoid racing the Version PR against itself on rapid merges.
16-
concurrency:
17-
group: release-prepare
18-
cancel-in-progress: false
19-
2013
permissions:
2114
contents: write
2215
pull-requests: write
2316

2417
jobs:
25-
version:
26-
runs-on: ubuntu-latest
27-
steps:
28-
- name: Checkout code
29-
uses: actions/checkout@v7
30-
with:
31-
fetch-depth: 0
32-
33-
- name: Setup pnpm
34-
uses: pnpm/action-setup@v6.0.10
35-
36-
- name: Setup Node.js
37-
uses: actions/setup-node@v7
38-
with:
39-
node-version: '22'
40-
cache: 'pnpm'
41-
42-
- name: Install dependencies
43-
run: pnpm install --frozen-lockfile
44-
45-
- name: Create or update the Version Packages PR
46-
uses: changesets/action@8488615a623b1b9c987934bb89eae8af6a946ac1 # v2.1.1
47-
with:
48-
version: pnpm run changeset:version
49-
title: 'chore: version packages'
50-
commit: 'chore: version packages'
51-
env:
52-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
release-prepare:
19+
uses: Nano-Collective/.github/.github/workflows/release-prepare.yml@main

0 commit comments

Comments
 (0)