Skip to content

Commit f7f4895

Browse files
committed
feat: 将npm发布放到release流程
1 parent 41dcd19 commit f7f4895

2 files changed

Lines changed: 63 additions & 76 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 63 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,63 @@
1-
name: Release
2-
3-
on:
4-
push:
5-
tags:
6-
- "v*"
7-
8-
permissions:
9-
contents: write
10-
11-
jobs:
12-
release:
13-
name: Release
14-
runs-on: ubuntu-latest
15-
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v6
18-
with:
19-
fetch-depth: 0
20-
21-
- name: Set up Go
22-
uses: actions/setup-go@v6
23-
with:
24-
go-version: "1.24"
25-
cache: true
26-
27-
- name: Run GoReleaser
28-
uses: goreleaser/goreleaser-action@v6
29-
with:
30-
distribution: goreleaser
31-
version: "~> v2"
32-
args: release --clean
33-
env:
34-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35-
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
36-
SCOOP_BUCKET_TOKEN: ${{ secrets.SCOOP_BUCKET_TOKEN }}
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
name: Release
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v6
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v6
23+
with:
24+
go-version: "1.24"
25+
cache: true
26+
27+
- name: Run GoReleaser
28+
uses: goreleaser/goreleaser-action@v6
29+
with:
30+
distribution: goreleaser
31+
version: "~> v2"
32+
args: release --clean
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
36+
SCOOP_BUCKET_TOKEN: ${{ secrets.SCOOP_BUCKET_TOKEN }}
37+
38+
npm-publish:
39+
name: Publish to npm
40+
needs: release
41+
runs-on: ubuntu-latest
42+
permissions:
43+
contents: read
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v6
47+
48+
- name: Set up Node.js
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: "20"
52+
registry-url: "https://registry.npmjs.org"
53+
54+
- name: Configure npm auth
55+
run: echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
56+
env:
57+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
58+
59+
- name: Publish to npm
60+
run: node scripts/npm-publish.js "${{ github.ref_name }}"
61+
env:
62+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
63+

0 commit comments

Comments
 (0)