Skip to content

Commit 2bd5994

Browse files
committed
ci: release-please
1 parent 7b2ccf6 commit 2bd5994

File tree

3 files changed

+108
-0
lines changed

3 files changed

+108
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: release-please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
releases_created: ${{ steps.release.outputs.releases_created }}
18+
steps:
19+
- name: Release Please
20+
id: release
21+
uses: googleapis/release-please-action@v4
22+
with:
23+
# Use manifest mode with workspace-aware config
24+
config-file: release-please-config.json
25+
manifest-file: .release-please-manifest.json
26+
include-component-in-tag: true
27+
28+
publish:
29+
needs: release
30+
if: ${{ needs.release.outputs.releases_created }}
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
36+
- name: Install pnpm
37+
uses: pnpm/action-setup@v4
38+
with:
39+
version: 9
40+
41+
- name: Setup Node
42+
uses: actions/setup-node@v4
43+
with:
44+
node-version: '20'
45+
registry-url: 'https://registry.npmjs.org'
46+
cache: 'pnpm'
47+
48+
- name: Install dependencies
49+
run: pnpm install --frozen-lockfile
50+
51+
- name: Build all packages
52+
run: pnpm -r build
53+
54+
- name: Publish changed packages to npm
55+
env:
56+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
57+
run: |
58+
set -euo pipefail
59+
echo "Finding unpublished workspace packages..."
60+
filters=""
61+
for pkgjson in packages/*/package.json; do
62+
# TODO: REVIEW ensure only public packages under packages/ are considered
63+
name=$(jq -r '.name' "$pkgjson")
64+
version=$(jq -r '.version' "$pkgjson")
65+
private=$(jq -r '(.private // false)' "$pkgjson")
66+
if [ "$private" = "true" ]; then
67+
echo "Skipping private package $name"
68+
continue
69+
fi
70+
if npm view "$name@$version" version > /dev/null 2>&1; then
71+
echo "Already published: $name@$version"
72+
else
73+
echo "Will publish: $name@$version"
74+
filters+=" --filter $name"
75+
fi
76+
done
77+
78+
if [ -z "$filters" ]; then
79+
echo "No unpublished packages detected. Skipping publish."
80+
exit 0
81+
fi
82+
83+
# Publish only the unpublished ones in topo order
84+
echo "Publishing: $filters"
85+
pnpm -r $filters publish --access public --no-git-checks
86+

.release-please-manifest.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{}
2+

release-please-config.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"plugins": [
3+
"node-workspace"
4+
],
5+
"include-component-in-tag": true,
6+
"bump-minor-pre-major": true,
7+
"bump-patch-for-minor-pre-major": true,
8+
"packages": {
9+
"packages/loro-protocol": {
10+
"release-type": "node"
11+
},
12+
"packages/loro-websocket": {
13+
"release-type": "node"
14+
},
15+
"packages/loro-adaptors": {
16+
"release-type": "node"
17+
}
18+
}
19+
}
20+

0 commit comments

Comments
 (0)