build: fix publishing on JSR, take 2
[poolifier.git] / .github / workflows / publish-package.yml
1 name: Publish package
2
3 on:
4 release:
5 types: [created]
6
7 jobs:
8 build:
9 runs-on: ubuntu-latest
10
11 steps:
12 - name: Checkout
13 uses: actions/checkout@v4
14
15 - name: Setup pnpm
16 uses: pnpm/action-setup@v3
17 with:
18 version: 8
19
20 - name: Setup Node.js
21 uses: actions/setup-node@v4
22 with:
23 node-version: '20.x'
24 cache: 'pnpm'
25
26 - name: Install Dependencies
27 run: pnpm install --ignore-scripts --frozen-lockfile
28
29 - name: Tests & Coverage
30 run: |
31 pnpm test
32 pnpm coverage
33
34 - name: Lint
35 run: pnpm lint
36
37 - name: Production Build
38 run: pnpm build:prod
39
40 publish-jsr:
41 needs: build
42 runs-on: ubuntu-latest
43
44 permissions:
45 contents: read
46 id-token: write
47
48 steps:
49 - name: Checkout
50 uses: actions/checkout@v4
51
52 - name: Setup pnpm
53 uses: pnpm/action-setup@v3
54 with:
55 version: 8
56
57 - name: Setup Node.js
58 uses: actions/setup-node@v4
59 with:
60 node-version: '20.x'
61 cache: 'pnpm'
62
63 - name: Install Dependencies
64 run: pnpm install --ignore-scripts --frozen-lockfile
65
66 - name: Read package.json version
67 id: package-version
68 uses: jaywcjlove/github-action-package@main
69
70 - name: Production Build
71 run: pnpm build:prod
72
73 - name: Publish Release
74 if: ${{ contains(steps.package-version.outputs.version, '-') == false }}
75 run: npx jsr publish
76
77 publish-npm:
78 needs: build
79 runs-on: ubuntu-latest
80
81 steps:
82 - name: Checkout
83 uses: actions/checkout@v4
84
85 - name: Setup pnpm
86 uses: pnpm/action-setup@v3
87 with:
88 version: 8
89
90 - name: Setup Node.js
91 uses: actions/setup-node@v4
92 with:
93 node-version: '20.x'
94 registry-url: https://registry.npmjs.org/
95 cache: 'pnpm'
96
97 - name: Install Dependencies
98 run: pnpm install --ignore-scripts --frozen-lockfile
99
100 - name: Read package.json version
101 id: package-version
102 uses: jaywcjlove/github-action-package@main
103
104 - name: Publish Release
105 if: ${{ contains(steps.package-version.outputs.version, '-') == false }}
106 run: pnpm publish --no-git-checks
107 env:
108 NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
109
110 - name: Publish Pre-Release
111 if: ${{ contains(steps.package-version.outputs.version, '-') == true && contains(steps.package-version.outputs.version, '-beta') == false }}
112 run: pnpm publish --no-git-checks --tag next
113 env:
114 NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
115
116 - name: Publish Beta Release
117 if: ${{ contains(steps.package-version.outputs.version, '-beta') == true }}
118 run: pnpm publish --no-git-checks --tag beta
119 env:
120 NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}