Skip to content

Commit 3bec7b6

Browse files
committed
add github action
1 parent c65778b commit 3bec7b6

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/workflows/release.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
workflow_dispatch: # 允许手动触发 workflow
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
goos: [windows, linux, darwin]
16+
goarch: [amd64, arm64]
17+
exclude:
18+
- goos: windows
19+
goarch: arm64
20+
- goos: darwin
21+
goarch: amd64
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: Set up Go
25+
uses: actions/setup-go@v3
26+
with:
27+
go-version: '1.24'
28+
- name: Build
29+
env:
30+
GOOS: ${{ matrix.goos }}
31+
GOARCH: ${{ matrix.goarch }}
32+
GOARM: 7
33+
CGO_ENABLED: 0 # 禁用 CGO 以进行静态链接
34+
run: |
35+
output_name="godoc-mcp-server-${GOOS}-${GOARCH}"
36+
if [ "${GOOS}" = "windows" ]; then
37+
output_name="${output_name}.exe"
38+
fi
39+
go build -ldflags="-s -w" -o "${output_name}" ./cmd/godoc-mcp-server
40+
- name: Upload binaries to release
41+
uses: svenstaro/upload-release-action@v2
42+
with:
43+
repo_token: ${{ secrets.GITHUB_TOKEN }}
44+
file: godoc-mcp-server-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }}
45+
tag: latest
46+
overwrite: true
47+
file_glob: true
48+
release_name: "Latest Release"
49+
body: "Automatically built binaries for different platforms."

0 commit comments

Comments
 (0)