Skip to content

Commit 1fed04a

Browse files
committed
fix: update release workflow and script for monorepo
1 parent 2754393 commit 1fed04a

2 files changed

Lines changed: 59 additions & 18 deletions

File tree

.github/workflows/release.yml

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: "Version to publish (e.g. 0.2.0, 0.2.0-rc.1)"
7+
description: "Version to publish (e.g. 0.1.0, 0.1.0-rc.1)"
88
required: true
99
type: string
1010
npm-tag:
@@ -31,30 +31,56 @@ jobs:
3131
with:
3232
ref: v${{ inputs.version }}
3333

34+
- name: Set up pnpm
35+
uses: pnpm/action-setup@v4
36+
3437
- name: Set up Node.js
3538
uses: actions/setup-node@v4
3639
with:
3740
node-version: 22
41+
cache: pnpm
42+
cache-dependency-path: pnpm-lock.yaml
3843
registry-url: https://registry.npmjs.org
3944

4045
- name: Install dependencies
41-
run: npm install
46+
run: pnpm install --no-frozen-lockfile
4247

4348
- name: Build
44-
run: npm run build
49+
run: pnpm turbo build
4550

4651
- name: Type check
47-
run: npm run check-types
52+
run: pnpm turbo check-types
4853

4954
- name: Publish to npm
5055
run: |
51-
VERSION="${{ inputs.version }}"
52-
NAME=$(jq -r .name package.json)
53-
if npm view "${NAME}@${VERSION}" version >/dev/null 2>&1; then
54-
echo "⏭ ${NAME}@${VERSION} already published, skipping."
55-
else
56+
FAILURES=""
57+
58+
# Publish workspace packages (skip root, skip registry/software/)
59+
for dir in $(pnpm -r ls --json --depth -1 | jq -r '.[] | select(.private != true) | .path'); do
60+
# Skip the root package
61+
if [ "$dir" = "$(pwd)" ]; then
62+
continue
63+
fi
64+
# Skip registry/software/ packages (published separately via make publish)
65+
if [[ "$dir" == *"/registry/software/"* ]]; then
66+
echo "⏭ Skipping software package: $(jq -r .name "$dir/package.json")"
67+
continue
68+
fi
69+
NAME=$(jq -r .name "$dir/package.json")
70+
VERSION="${{ inputs.version }}"
71+
if npm view "${NAME}@${VERSION}" version >/dev/null 2>&1; then
72+
echo "⏭ ${NAME}@${VERSION} already published, skipping."
73+
continue
74+
fi
5675
echo "Publishing ${NAME}@${VERSION}..."
57-
npm publish --access public --tag ${{ inputs.npm-tag }}
76+
if ! (cd "$dir" && pnpm publish --access public --tag ${{ inputs.npm-tag }} --no-git-checks); then
77+
FAILURES="${FAILURES} ${NAME}"
78+
fi
79+
done
80+
81+
if [ -n "$FAILURES" ]; then
82+
echo "::error::Failed to publish:${FAILURES}"
83+
exit 1
5884
fi
5985
env:
6086
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

scripts/release.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,24 @@ function parseArgs(): { version: string; tag: "latest" | "rc"; noGitChecks: bool
8787

8888
// ── Update version ──
8989

90+
function findPublishablePackages(): string[] {
91+
const output = run("pnpm -r ls --json --depth -1");
92+
const packages = JSON.parse(output) as Array<{ path: string; private?: boolean }>;
93+
return packages
94+
.filter((p) => !p.private && p.path !== ROOT && !p.path.includes("/registry/software/"))
95+
.map((p) => join(p.path, "package.json"));
96+
}
97+
9098
function setVersion(version: string) {
91-
const file = join(ROOT, "packages/core/package.json");
92-
const content = readFileSync(file, "utf-8");
93-
const pkg = JSON.parse(content);
94-
pkg.version = version;
95-
const indent = content.match(/^(\s+)"/m)?.[1] ?? "\t";
96-
writeFileSync(file, JSON.stringify(pkg, null, indent) + "\n");
99+
const files = findPublishablePackages();
100+
for (const file of files) {
101+
const content = readFileSync(file, "utf-8");
102+
const pkg = JSON.parse(content);
103+
pkg.version = version;
104+
const indent = content.match(/^(\s+)"/m)?.[1] ?? "\t";
105+
writeFileSync(file, JSON.stringify(pkg, null, indent) + "\n");
106+
console.log(` ${pkg.name}${version}`);
107+
}
97108
}
98109

99110
// ── Main ──
@@ -122,13 +133,17 @@ async function main() {
122133
console.log("\x1b[33m⚠ Skipping git checks (--no-git-checks)\x1b[0m");
123134
}
124135

125-
const corePkg = JSON.parse(readFileSync(join(ROOT, "packages/core/package.json"), "utf-8"));
136+
const pkgFiles = findPublishablePackages();
137+
const pkgNames = pkgFiles.map((f) => JSON.parse(readFileSync(f, "utf-8")).name as string);
126138

127139
console.log(`\n\x1b[1mRelease Plan\x1b[0m`);
128-
console.log(` Package: \x1b[36m${corePkg.name}\x1b[0m`);
129140
console.log(` Version: \x1b[36m${version}\x1b[0m`);
130141
console.log(` NPM tag: \x1b[36m${tag}\x1b[0m`);
131142
console.log(` Git tag: \x1b[36mv${version}\x1b[0m`);
143+
console.log(` Packages: \x1b[36m${pkgNames.length}\x1b[0m`);
144+
for (const name of pkgNames) {
145+
console.log(` - ${name}`);
146+
}
132147
console.log();
133148

134149
if (!(await confirm("Proceed?"))) {

0 commit comments

Comments
 (0)