|
1 | 1 | name: release |
2 | 2 |
|
| 3 | +# A single workflow file so npm Trusted Publishing can be configured against it. |
| 4 | +# The branch determines which release runs: `main` → stable (latest), `canary` |
| 5 | +# → prerelease (canary). Only the job matching the pushed branch runs. |
3 | 6 | on: |
4 | 7 | push: |
5 | 8 | branches: |
6 | 9 | - main |
| 10 | + - canary |
7 | 11 |
|
8 | 12 | jobs: |
9 | | - main: |
| 13 | + stable: |
| 14 | + name: stable (latest) |
| 15 | + if: github.ref == 'refs/heads/main' |
10 | 16 | runs-on: ubuntu-latest |
11 | 17 | permissions: |
12 | 18 | contents: write |
|
16 | 22 | - uses: pnpm/action-setup@v4 |
17 | 23 | - uses: actions/setup-node@v4 |
18 | 24 | with: |
19 | | - cache: "pnpm" |
| 25 | + cache: 'pnpm' |
20 | 26 | node-version: 20.x |
21 | | - registry-url: "https://registry.npmjs.org" |
| 27 | + registry-url: 'https://registry.npmjs.org' |
22 | 28 | - run: npm install -g npm@latest # Trusted publishers |
23 | 29 | - run: pnpm install |
24 | 30 | - run: | |
|
29 | 35 | env: |
30 | 36 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
31 | 37 | # No NODE_AUTH_TOKEN since we use Trusted Publishers |
| 38 | + |
| 39 | + canary: |
| 40 | + name: prerelease (canary) |
| 41 | + if: github.ref == 'refs/heads/canary' |
| 42 | + runs-on: ubuntu-latest |
| 43 | + permissions: |
| 44 | + contents: write |
| 45 | + id-token: write |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + - uses: pnpm/action-setup@v4 |
| 49 | + - uses: actions/setup-node@v4 |
| 50 | + with: |
| 51 | + cache: 'pnpm' |
| 52 | + node-version: 20.x |
| 53 | + registry-url: 'https://registry.npmjs.org' |
| 54 | + - run: npm install -g npm@latest # Trusted publishers |
| 55 | + - run: pnpm install |
| 56 | + - run: pnpm turbo run build --filter './packages/**' |
| 57 | + - run: | |
| 58 | + git config --global user.name "${{ github.actor }}" |
| 59 | + git config --global user.email "${{ github.actor }}@users.noreply.github.com" |
| 60 | + # Change workspace dependencies from "workspace:^" to "workspace:" |
| 61 | + - run: | |
| 62 | + sed -i 's/"use-intl": "workspace:\^"/"use-intl": "workspace:"/' ./packages/next-intl/package.json && \ |
| 63 | + sed -i 's/"next-intl-swc-plugin-extractor": "workspace:\^"/"next-intl-swc-plugin-extractor": "workspace:"/' ./packages/next-intl/package.json && \ |
| 64 | + git commit -am "use fixed version" |
| 65 | + - run: pnpm lerna publish 0.0.0-canary-${GITHUB_SHA::7} --no-git-reset --dist-tag canary --no-push --yes |
| 66 | + if: "${{startsWith(github.event.head_commit.message, 'fix: ') || startsWith(github.event.head_commit.message, 'feat: ') || startsWith(github.event.head_commit.message, 'feat!: ')}}" |
| 67 | + env: |
| 68 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 69 | + # No NODE_AUTH_TOKEN since we use Trusted Publishers |
0 commit comments