-
Notifications
You must be signed in to change notification settings - Fork 1
55 lines (45 loc) · 1.33 KB
/
publish.yml
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
name: Publish to npm
on:
push:
branches:
- main
- beta
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org/'
- name: Install dependencies
run: npm install
- name: Run typecheck
run: npm run typecheck
- name: Run linter
run: npm run lint
- name: Run tests
run: npm test
- name: Check if version has been bumped
id: version-check
run: |
VERSION=$(node -p "require('./package.json').version")
NPM_VERSION=$(npm view $(node -p "require('./package.json').name") version)
if [ "$VERSION" = "$NPM_VERSION" ]; then
echo "Version has not been bumped."
echo "bumped=false" >> $GITHUB_OUTPUT
else
echo "Version has been bumped."
echo "bumped=true" >> $GITHUB_OUTPUT
fi
- name: Build
if: steps.version-check.outputs.bumped == 'true'
run: npm run build
- name: Publish to npm
if: steps.version-check.outputs.bumped == 'true'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}