Skip to content

Commit 4bb2dfe

Browse files
committed
ci: add CI and release workflows
1 parent 997edf5 commit 4bb2dfe

2 files changed

Lines changed: 74 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
name: CI
22

3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-node@v4
15+
with:
16+
node-version: '20'
17+
- name: Install
18+
run: |
19+
if [ -f pnpm-lock.yaml ]; then
20+
npm i -g pnpm && pnpm install --no-frozen-lockfile
21+
elif [ -f package-lock.json ]; then
22+
npm ci
23+
else
24+
npm install
25+
fi
26+
- name: Lint
27+
run: npm run lint --if-present
28+
- name: Test
29+
run: npm test --if-present
30+
31+
name: CI
32+
333
on:
434
push:
535
branches: [ master ]

.github/workflows/release-on-tag.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,49 @@
11
name: Publish on tag
22

3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: read
10+
id-token: write
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: '20'
20+
registry-url: 'https://registry.npmjs.org'
21+
- name: Install
22+
run: |
23+
if [ -f pnpm-lock.yaml ]; then
24+
npm i -g pnpm && pnpm install --no-frozen-lockfile
25+
elif [ -f package-lock.json ]; then
26+
npm ci
27+
else
28+
npm install
29+
fi
30+
- name: Build
31+
run: npm run build --if-present
32+
- name: Test
33+
run: npm test --if-present
34+
- name: Publish
35+
run: |
36+
pkg_private=$(node -e "try{console.log(require('./package.json').private===true?'true':'false')}catch(e){console.log('false')}")
37+
if [ "$pkg_private" = "true" ]; then
38+
echo "package.json is private; skipping publish."
39+
exit 0
40+
fi
41+
npm publish --provenance --access public
42+
env:
43+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
44+
45+
name: Publish on tag
46+
347
on:
448
push:
549
tags:

0 commit comments

Comments
 (0)