Skip to content

Commit e46aded

Browse files
committed
ci: auto publish to npm
1 parent 0dbf01c commit e46aded

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

.github/workflows/publish.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Automatic Publish
2+
on:
3+
push:
4+
branches:
5+
- master
6+
tags-ignore:
7+
- '**'
8+
paths-ignore:
9+
- '**/*.md'
10+
- LICENSE
11+
- '**/*.gitignore'
12+
- .editorconfig
13+
- docs/**
14+
pull_request: null
15+
jobs:
16+
publish:
17+
name: Publish
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
id-token: write
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: pnpm/action-setup@v4
25+
- uses: actions/setup-node@v4
26+
with:
27+
node-version-file: '.node-version'
28+
check-latest: true
29+
cache: 'pnpm'
30+
registry-url: 'https://registry.npmjs.org'
31+
- run: npm install -g npm
32+
- run: pnpm install
33+
- run: pnpm run build
34+
- run: pnpm run lint
35+
- name: Publish
36+
run: |
37+
if git log -1 --pretty=%B | grep "^release: [0-9]\+\.[0-9]\+\.[0-9]\+$";
38+
then
39+
pnpm -r publish --provenance --access public
40+
elif git log -1 --pretty=%B | grep "^release: [0-9]\+\.[0-9]\+\.[0-9]\+";
41+
then
42+
pnpm -r publish --provenance --access public --tag next
43+
else
44+
echo "Not a release, skipping publish"
45+
fi
46+
env:
47+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
48+
NPM_CONFIG_PROVENANCE: true

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

0 commit comments

Comments
 (0)