File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Deploy to npm
2+
3+ on :
4+ workflow_dispatch :
5+ push :
6+ branches :
7+ - main
8+
9+ jobs :
10+ publish :
11+ runs-on : ubuntu-latest
12+
13+ permissions :
14+ contents : read
15+ id-token : write
16+
17+ steps :
18+ - name : Checkout code
19+ uses : actions/checkout@v4
20+
21+ - name : Setup Node
22+ uses : actions/setup-node@v4
23+ with :
24+ node-version : " 18"
25+ cache : " npm"
26+ registry-url : " https://registry.npmjs.org"
27+
28+ - name : Install dependencies
29+ run : npm ci
30+
31+ - name : Lint
32+ run : npm run lint
33+
34+ - name : Build
35+ run : npm run build
36+
37+ - name : Test
38+ run : npm run test:only
39+
40+ - name : Publish to npm
41+ run : |
42+ VERSION=$(node -p "require('./package.json').version")
43+ PACKAGE=$(node -p "require('./package.json').name")
44+ OUTPUT=$(npm publish --provenance --access public 2>&1) || {
45+ if echo "$OUTPUT" | grep -q "cannot publish over the previously published"; then
46+ echo "${PACKAGE}@${VERSION} already published, skipping"
47+ exit 0
48+ fi
49+ echo "$OUTPUT" >&2
50+ exit 1
51+ }
52+ echo "$OUTPUT"
You can’t perform that action at this time.
0 commit comments