build: fix publishing on JSR
[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: Publish Release
71 if: ${{ contains(steps.package-version.outputs.version, '-') == false }}
72 run: npx jsr publish
73
74 publish-npm:
75 needs: build
76 runs-on: ubuntu-latest
77
78 steps:
79 - name: Checkout
80 uses: actions/checkout@v4
81
82 - name: Setup pnpm
83 uses: pnpm/action-setup@v3
84 with:
85 version: 8
86
87 - name: Setup Node.js
88 uses: actions/setup-node@v4
89 with:
90 node-version: '20.x'
91 registry-url: https://registry.npmjs.org/
92 cache: 'pnpm'
93
94 - name: Install Dependencies
95 run: pnpm install --ignore-scripts --frozen-lockfile
96
97 - name: Read package.json version
98 id: package-version
99 uses: jaywcjlove/github-action-package@main
100
101 - name: Publish Release
102 if: ${{ contains(steps.package-version.outputs.version, '-') == false }}
103 run: pnpm publish --no-git-checks
104 env:
105 NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
106
107 - name: Publish Pre-Release
108 if: ${{ contains(steps.package-version.outputs.version, '-') == true && contains(steps.package-version.outputs.version, '-beta') == false }}
109 run: pnpm publish --no-git-checks --tag next
110 env:
111 NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
112
113 - name: Publish Beta Release
114 if: ${{ contains(steps.package-version.outputs.version, '-beta') == true }}
115 run: pnpm publish --no-git-checks --tag beta
116 env:
117 NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}