-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (47 loc) · 1.31 KB
/
Copy pathpublish.yml
File metadata and controls
56 lines (47 loc) · 1.31 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
name: build and publish
on:
push:
branches:
- main
permissions:
contents: read
id-token: write
jobs:
bp:
name: build and publish to npm
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check if version changed
id: version-check
run: |
if git diff HEAD^ HEAD -- package.json | grep -q '"version"'; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Setup Node.js
if: steps.version-check.outputs.changed == 'true'
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Setup pnpm
if: steps.version-check.outputs.changed == 'true'
uses: pnpm/action-setup@v4
with:
version: 9
- name: install
if: steps.version-check.outputs.changed == 'true'
run: pnpm install --frozen-lockfile
- name: build and publish
if: steps.version-check.outputs.changed == 'true'
working-directory: ./
run: |
pnpm build
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}