Skip to content

Commit 9ce8605

Browse files
author
OCWatch Dev
committed
ci: auto-publish to npm on push to main
1 parent f8cdbba commit 9ce8605

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
# Skip automated version bump commits (pushed by GITHUB_TOKEN, which
14+
# doesn't trigger workflows anyway — this is defense-in-depth)
15+
if: "!contains(github.event.head_commit.message, '[release]')"
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- uses: oven-sh/setup-bun@v2
21+
22+
- name: Install dependencies
23+
run: |
24+
bun install
25+
cd src/client && bun install
26+
27+
- name: Build client
28+
run: cd src/client && bun run build
29+
30+
- name: Bump version
31+
id: version
32+
run: |
33+
npm version patch --no-git-tag-version
34+
echo "version=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"
35+
36+
- name: Publish to npm
37+
run: |
38+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
39+
bun publish --access public
40+
env:
41+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
42+
43+
- name: Commit version bump
44+
run: |
45+
git config user.name "github-actions[bot]"
46+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
47+
git add package.json
48+
git commit -m "v${{ steps.version.outputs.version }} [release]"
49+
git tag "v${{ steps.version.outputs.version }}"
50+
git push
51+
git push --tags

0 commit comments

Comments
 (0)