-
Notifications
You must be signed in to change notification settings - Fork 9
88 lines (83 loc) · 2.38 KB
/
Copy pathnpmpublish.yml
File metadata and controls
88 lines (83 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# This workflow will run tests using node and then publish a package to the npm registry when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
name: Node.js Package
on:
pull_request:
push:
branches:
- main
- master
env:
PNPM_HOME: ~/.pnpm-store
jobs:
test:
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v7
- uses: actions/cache@v5
name: Cache pnpm store
with:
path: ${{ env.PNPM_HOME }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- uses: pnpm/action-setup@v6
name: Install pnpm
with:
run_install: false
-
uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
-
run: pnpm i
-
run: pnpm run build
-
run: pnpm run lint
publish-npm:
if: github.event_name == 'push'
needs: test
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/cache@v5
name: Cache pnpm store
with:
path: ${{ env.PNPM_HOME }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- uses: pnpm/action-setup@v6
name: Install pnpm
with:
run_install: false
-
uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
registry-url: https://registry.npmjs.org/
-
name: Tag the version in package.json (if not already tagged)
run: |
PKG_VER=$(node -p "require('./package.json').version")
if git rev-parse -q --verify "refs/tags/v${PKG_VER}" >/dev/null; then
echo "v${PKG_VER} already tagged; nothing to do."
exit 0
fi
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git tag "v${PKG_VER}"
git push origin "v${PKG_VER}"
-
run: pnpm i --frozen-lockfile
-
run: pnpm publish --no-git-checks
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}