Skip to content

Commit 9f1c8b7

Browse files
chore(ci): publish package previews (#370)
Co-authored-by: neverland <chenjiahan.jait@bytedance.com>
1 parent 2fe122e commit 9f1c8b7

5 files changed

Lines changed: 65 additions & 0 deletions

File tree

‎.github/workflows/pkg-pr-new.yml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Publish Package Previews
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
permissions: {}
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
18+
with:
19+
node-version: 24.19.0
20+
package-manager-cache: false
21+
22+
- name: Install Pnpm
23+
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
24+
with:
25+
run_install: true
26+
27+
- name: Build Packages
28+
run: node --run build
29+
30+
- name: Publish Package Previews
31+
run: pnpm exec pkg-pr-new publish --pnpm --previewVersion --no-template './packages/rstack' './packages/create-rstack'

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@types/node": "catalog:",
2121
"cspell-ban-words": "catalog:",
2222
"heading-case": "catalog:",
23+
"pkg-pr-new": "catalog:",
2324
"prettier": "catalog:",
2425
"rstack": "workspace:*",
2526
"typescript": "catalog:"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { readFile } from 'node:fs/promises';
2+
import { expect, test } from 'rstack/test';
3+
4+
test('publishes pull request previews for public packages', async () => {
5+
const [workflow, packageJson, workspace] = await Promise.all([
6+
readFile(
7+
new URL('../../../.github/workflows/pkg-pr-new.yml', import.meta.url),
8+
'utf8',
9+
),
10+
readFile(new URL('../../../package.json', import.meta.url), 'utf8'),
11+
readFile(new URL('../../../pnpm-workspace.yaml', import.meta.url), 'utf8'),
12+
]);
13+
14+
expect(workflow).toContain('pkg-pr-new publish --pnpm --previewVersion');
15+
expect(workflow).toContain("'./packages/rstack'");
16+
expect(workflow).toContain("'./packages/create-rstack'");
17+
expect(workflow).not.toContain('head.repo.full_name == github.repository');
18+
expect(packageJson).toContain('"pkg-pr-new": "catalog:"');
19+
expect(workspace).toContain('pkg-pr-new: 0.0.87');
20+
});

‎pnpm-lock.yaml‎

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pnpm-workspace.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ catalog:
4545
is-binary-path: 3.0.0
4646
'lint-staged': '^17.6.0'
4747
'micromatch': '4.0.8'
48+
pkg-pr-new: 0.0.87
4849
prettier: '3.9.10'
4950
'prettier-plugin-tailwindcss': '0.8.1'
5051
'prettier-plugin-svelte': '^4.1.1'

0 commit comments

Comments
 (0)