Skip to content

Commit 9f0efb6

Browse files
committed
ci: add publish workflow with npm trusted publishers
1 parent d8139e3 commit 9f0efb6

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

.github/workflows/publish.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Publish Packages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
id-token: write
9+
contents: read
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: "22"
20+
registry-url: "https://registry.npmjs.org"
21+
22+
- name: Enable Corepack (Yarn 4)
23+
run: corepack enable
24+
25+
- name: Install dependencies
26+
run: yarn install --immutable
27+
28+
- name: Build all packages
29+
run: yarn build
30+
31+
- name: Publish changed packages
32+
run: |
33+
publish_if_new() {
34+
local dir=$1
35+
local name=$(node -p "require('./$dir/package.json').name")
36+
local version=$(node -p "require('./$dir/package.json').version")
37+
local published=$(npm view "$name@$version" version 2>/dev/null || echo "")
38+
39+
if [ "$published" = "$version" ]; then
40+
echo "⏭️ $name@$version already published, skipping"
41+
else
42+
echo "📦 Publishing $name@$version..."
43+
npm publish "./$dir" --access public
44+
echo "✅ Published $name@$version"
45+
fi
46+
}
47+
48+
# SDK first (other plugins may depend on it)
49+
publish_if_new packages/plugins-sdk
50+
51+
# Then plugins
52+
publish_if_new plugins/product-reviews
53+
publish_if_new plugins/braintree-payment
54+
publish_if_new plugins/webhooks

0 commit comments

Comments
 (0)