Skip to content

Commit 7e2eedd

Browse files
committed
refactor publish workflow
1 parent c73306e commit 7e2eedd

File tree

1 file changed

+49
-66
lines changed

1 file changed

+49
-66
lines changed

.github/workflows/publish.yml

Lines changed: 49 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,56 @@
11
name: Publish to NPM
22

33
on:
4-
workflow_run:
5-
workflows: ["Tests"]
6-
branches: [main]
7-
types:
8-
- completed
4+
workflow_run:
5+
workflows: ["Tests"]
6+
branches: [main]
7+
types:
8+
- completed
99

1010
permissions:
11-
contents: write
11+
contents: write
1212

1313
jobs:
14-
build-and-publish:
15-
runs-on: ubuntu-latest
16-
if: github.event.workflow_run.conclusion == 'success' && !contains(github.event.workflow_run.head_commit.message, '[skip ci]')
17-
steps:
18-
- name: Checkout code
19-
uses: actions/checkout@v4
20-
with:
21-
token: ${{ secrets.GITHUB_TOKEN }}
22-
23-
- name: Setup Node.js
24-
uses: actions/setup-node@v4
25-
with:
26-
node-version: "24"
27-
registry-url: "https://registry.npmjs.org"
28-
29-
- name: Install pnpm
30-
uses: pnpm/action-setup@v4
31-
with:
32-
version: 9
33-
34-
- name: Get pnpm store directory
35-
id: pnpm-cache
36-
shell: bash
37-
run: |
38-
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
39-
40-
- name: Setup pnpm cache
41-
uses: actions/cache@v4
42-
with:
43-
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
44-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
45-
restore-keys: |
46-
${{ runner.os }}-pnpm-store-
47-
48-
- name: Install dependencies
49-
run: pnpm install --frozen-lockfile
50-
51-
- name: Configure Git
52-
run: |
53-
git config --global user.name "github-actions[bot]"
54-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
55-
56-
- name: Bump version and create tag
57-
run: |
58-
pnpm version patch --no-git-tag-version
59-
NEW_VERSION=$(node -p "require('./package.json').version")
60-
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
61-
git add package.json
62-
git commit -m "chore: bump version to $NEW_VERSION [skip ci]"
63-
git tag "v$NEW_VERSION"
64-
git push origin main
65-
git push origin "v$NEW_VERSION"
66-
67-
- name: Build
68-
run: pnpm run build
69-
70-
- name: Publish to NPM
71-
run: pnpm publish --no-git-checks --access public
72-
env:
73-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
14+
build-and-publish:
15+
runs-on: ubuntu-latest
16+
if: github.event.workflow_run.conclusion == 'success' && !contains(github.event.workflow_run.head_commit.message, '[skip ci]')
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: "24"
27+
registry-url: "https://registry.npmjs.org"
28+
29+
- name: Setup Bun
30+
uses: oven-sh/setup-bun@v2
31+
with:
32+
bun-version: 1.3.1
33+
34+
- name: Configure Git
35+
run: |
36+
git config --global user.name "github-actions[bot]"
37+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
38+
39+
- name: Bump version and create tag
40+
run: |
41+
npm version patch --no-git-tag-version
42+
NEW_VERSION=$(node -p "require('./package.json').version")
43+
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
44+
git add package.json
45+
git commit -m "chore: bump version to $NEW_VERSION [skip ci]"
46+
git tag "v$NEW_VERSION"
47+
git push origin main
48+
git push origin "v$NEW_VERSION"
49+
50+
- name: Build
51+
run: bun install --frozen-lockfile && bun run build && bun run postbuild
52+
53+
- name: Publish to NPM
54+
run: npm publish --no-git-checks --access public
55+
env:
56+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)