|
1 | | -name: Release & Publish |
| 1 | +name: release-please |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - main |
7 | | - - master |
8 | | - release: |
9 | | - types: [published] |
| 7 | + workflow_dispatch: |
10 | 8 |
|
11 | 9 | permissions: |
12 | 10 | contents: write |
13 | 11 | pull-requests: write |
14 | 12 |
|
15 | 13 | jobs: |
16 | | - release-please: |
17 | | - if: github.event_name == 'push' |
| 14 | + release: |
18 | 15 | runs-on: ubuntu-latest |
| 16 | + outputs: |
| 17 | + releases_created: ${{ steps.release.outputs.releases_created }} |
19 | 18 | steps: |
20 | 19 | - name: Release Please |
| 20 | + id: release |
21 | 21 | uses: googleapis/release-please-action@v4 |
22 | 22 | 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 |
24 | 27 |
|
25 | 28 | publish: |
26 | | - if: github.event_name == 'release' |
| 29 | + needs: release |
| 30 | + if: ${{ needs.release.outputs.releases_created == 'true' }} |
27 | 31 | runs-on: ubuntu-latest |
28 | 32 | steps: |
29 | 33 | - name: Checkout |
30 | 34 | uses: actions/checkout@v4 |
31 | 35 |
|
32 | | - - name: Setup pnpm |
| 36 | + - name: Install pnpm |
33 | 37 | uses: pnpm/action-setup@v4 |
34 | 38 | with: |
35 | 39 | version: 9 |
36 | 40 |
|
37 | | - - name: Setup Node.js |
| 41 | + - name: Setup Node |
38 | 42 | uses: actions/setup-node@v4 |
39 | 43 | with: |
40 | | - node-version: 18 |
41 | | - cache: 'pnpm' |
| 44 | + node-version: '20' |
42 | 45 | registry-url: 'https://registry.npmjs.org' |
| 46 | + cache: 'pnpm' |
43 | 47 |
|
44 | 48 | - name: Install dependencies |
45 | 49 | run: pnpm install --frozen-lockfile |
46 | 50 |
|
47 | | - - name: Build packages |
| 51 | + - name: Build all packages |
48 | 52 | run: pnpm -r build |
49 | 53 |
|
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 |
75 | 55 | env: |
76 | 56 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
77 | 57 | 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