Skip to content

Commit 289a529

Browse files
committed
ci: release
1 parent 055e607 commit 289a529

File tree

1 file changed

+45
-40
lines changed

1 file changed

+45
-40
lines changed
Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,84 @@
1-
name: Release & Publish
1+
name: release-please
22

33
on:
44
push:
55
branches:
66
- main
7-
- master
8-
release:
9-
types: [published]
7+
workflow_dispatch:
108

119
permissions:
1210
contents: write
1311
pull-requests: write
1412

1513
jobs:
16-
release-please:
17-
if: github.event_name == 'push'
14+
release:
1815
runs-on: ubuntu-latest
16+
outputs:
17+
releases_created: ${{ steps.release.outputs.releases_created }}
1918
steps:
2019
- name: Release Please
20+
id: release
2121
uses: googleapis/release-please-action@v4
2222
with:
23-
token: ${{ secrets.GITHUB_TOKEN }}
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
2427

2528
publish:
26-
if: github.event_name == 'release'
29+
needs: release
30+
if: ${{ needs.release.outputs.releases_created == 'true' }}
2731
runs-on: ubuntu-latest
2832
steps:
2933
- name: Checkout
3034
uses: actions/checkout@v4
3135

32-
- name: Setup pnpm
36+
- name: Install pnpm
3337
uses: pnpm/action-setup@v4
3438
with:
3539
version: 9
3640

37-
- name: Setup Node.js
41+
- name: Setup Node
3842
uses: actions/setup-node@v4
3943
with:
40-
node-version: 18
41-
cache: 'pnpm'
44+
node-version: '20'
4245
registry-url: 'https://registry.npmjs.org'
46+
cache: 'pnpm'
4347

4448
- name: Install dependencies
4549
run: pnpm install --frozen-lockfile
4650

47-
- name: Build packages
51+
- name: Build all packages
4852
run: pnpm -r build
4953

50-
- name: Determine package from tag
51-
id: which
52-
shell: bash
53-
run: |
54-
TAG="${{ github.event.release.tag_name }}"
55-
echo "Release tag: $TAG"
56-
if [[ "$TAG" =~ ^loro-mirror-v([0-9]+\.[0-9]+\.[0-9]+) ]]; then
57-
echo "name=loro-mirror" >> "$GITHUB_OUTPUT"
58-
echo "dir=packages/core" >> "$GITHUB_OUTPUT"
59-
echo "version=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
60-
elif [[ "$TAG" =~ ^loro-mirror-react-v([0-9]+\.[0-9]+\.[0-9]+) ]]; then
61-
echo "name=loro-mirror-react" >> "$GITHUB_OUTPUT"
62-
echo "dir=packages/react" >> "$GITHUB_OUTPUT"
63-
echo "version=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
64-
elif [[ "$TAG" =~ ^loro-mirror-jotai-v([0-9]+\.[0-9]+\.[0-9]+) ]]; then
65-
echo "name=loro-mirror-jotai" >> "$GITHUB_OUTPUT"
66-
echo "dir=packages/jotai" >> "$GITHUB_OUTPUT"
67-
echo "version=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
68-
else
69-
echo "Tag $TAG does not match known packages; skipping publish."
70-
echo "name=" >> "$GITHUB_OUTPUT"
71-
fi
72-
73-
- name: Publish to npm
74-
if: steps.which.outputs.name != ''
54+
- name: Publish changed packages to npm
7555
env:
7656
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
7757
run: |
78-
echo "Publishing ${{ steps.which.outputs.name }} at version ${{ steps.which.outputs.version }}"
79-
pnpm --filter "${{ steps.which.outputs.name }}" publish --no-git-checks
58+
set -euo pipefail
59+
echo "Finding unpublished workspace packages..."
60+
filters=""
61+
for pkgjson in packages/*/package.json; do
62+
name=$(jq -r '.name' "$pkgjson")
63+
version=$(jq -r '.version' "$pkgjson")
64+
private=$(jq -r '(.private // false)' "$pkgjson")
65+
if [ "$private" = "true" ]; then
66+
echo "Skipping private package $name"
67+
continue
68+
fi
69+
if npm view "$name@$version" version > /dev/null 2>&1; then
70+
echo "Already published: $name@$version"
71+
else
72+
echo "Will publish: $name@$version"
73+
filters+=" --filter $name"
74+
fi
75+
done
76+
77+
if [ -z "$filters" ]; then
78+
echo "No unpublished packages detected. Skipping publish."
79+
exit 0
80+
fi
81+
82+
# Publish only the unpublished ones in topo order
83+
echo "Publishing: $filters"
84+
pnpm -r $filters publish --access public --no-git-checks

0 commit comments

Comments
 (0)