Skip to content

Commit a701c41

Browse files
committed
Add GitHub Actions workflow to publish to NPM
1 parent 9f89fea commit a701c41

File tree

3 files changed

+56
-3
lines changed

3 files changed

+56
-3
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will do a clean install of node dependencies and run tests
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3-
41
name: CI
52

63
on:

.github/workflows/publish.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
id-token: write
9+
10+
jobs:
11+
publish:
12+
name: Publish
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
19+
- name: Cache .yarn/cache
20+
uses: actions/cache@v3
21+
env:
22+
cache-name: yarn-cache
23+
with:
24+
path: .yarn/cache
25+
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
26+
restore-keys: |
27+
${{ runner.os }}-${{ env.cache-name }}
28+
29+
- name: Use Node.js
30+
uses: actions/setup-node@v3
31+
with:
32+
node-version: '18'
33+
34+
- name: Enable Corepack
35+
run: corepack enable
36+
37+
- name: Install dependencies
38+
run: yarn --immutable
39+
env:
40+
HUSKY: 0
41+
42+
- name: Publish with latest tag
43+
if: github.event.release.prelease == false
44+
run: yarn npm publish --tag latest
45+
env:
46+
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
47+
48+
- name: Publish with next tag
49+
if: github.event.release.prelease == true
50+
run: yarn npm publish --tag next
51+
env:
52+
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
7676
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
7777
},
78+
"publishConfig": {
79+
"access": "public",
80+
"provenance": true
81+
},
7882
"files": [
7983
"dist",
8084
"src"

0 commit comments

Comments
 (0)