File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- name : Release
1+ name : Publish Package
22
33on :
44 push :
5- tags :
6- - ' v*'
5+ branches :
6+ - main
7+ paths :
8+ - " package.json"
79
810jobs :
9- release :
11+ publish :
1012 runs-on : ubuntu-latest
13+ permissions :
14+ contents : read
15+ id-token : write
1116 steps :
12- - uses : actions/checkout@v4
17+ - name : Checkout
18+ uses : actions/checkout@v4
1319
14- - uses : oven-sh/setup-bun@v2
20+ - name : Setup Node
21+ uses : actions/setup-node@v4
22+ with :
23+ registry-url : " https://registry.npmjs.org"
1524
16- - run : bun install
25+ - name : Setup Bun
26+ uses : oven-sh/setup-bun@v2
1727
18- - run : bun run typecheck
28+ - name : Install dependencies
29+ run : bun install
1930
20- - run : bun run build
31+ - name : Check if version changed
32+ id : version-check
33+ run : |
34+ PACKAGE_NAME=$(jq -r '.name' package.json)
35+ LOCAL_VERSION=$(jq -r '.version' package.json)
36+ NPM_VERSION=$(npm view "$PACKAGE_NAME" version 2>/dev/null || echo "0.0.0")
37+ if [ "$LOCAL_VERSION" = "$NPM_VERSION" ]; then
38+ echo "Version $LOCAL_VERSION already published, skipping."
39+ echo "changed=false" >> "$GITHUB_OUTPUT"
40+ else
41+ echo "Publishing $LOCAL_VERSION (npm has $NPM_VERSION)"
42+ echo "changed=true" >> "$GITHUB_OUTPUT"
43+ fi
2144
22- - run : npm publish --access public
45+ - name : Type check
46+ if : steps.version-check.outputs.changed == 'true'
47+ run : bun run typecheck
48+
49+ - name : Build
50+ if : steps.version-check.outputs.changed == 'true'
51+ run : bun run build
52+
53+ - name : Publish
54+ if : steps.version-check.outputs.changed == 'true'
55+ run : npm publish --access public
2356 env :
57+ NPM_CONFIG_PROVENANCE : true
2458 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
You can’t perform that action at this time.
0 commit comments