From 25c2fc66be295b59c9ae9a37d5ccc241096983d1 Mon Sep 17 00:00:00 2001 From: "tao.chen" <93983997+taochen-ct@users.noreply.github.com> Date: Tue, 14 Jul 2026 19:03:29 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E6=94=B9=20workflow=20=E7=94=A8=E5=9B=BD?= =?UTF-8?q?=E5=86=85=E9=95=9C=E5=83=8F=E8=A3=85=20Go=20+=20goproxy.cn=20?= =?UTF-8?q?=E5=8A=A0=E9=80=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前 ci/release 两个 job 用 actions/setup-go@v5 从 go.mod 装 Go, 内置 cache. 在 Gitea runner 所在网络区域 (ping 23ms 短, 推测 国内) 跑得动但慢. 改用用户提供的脚本手动装 Go 1.25.5 (NJU 镜像) + goproxy.cn 代理 + GITHUB_PATH/GITHUB_ENV (Gitea runner 也兼容这俩 env var). actions/setup-go 整个去掉, 因为手动装后 PATH 跟 GOPROXY 都设好, go build 直接可跑. GITBUB_PATH/GITHUB_ENV 是 GitHub Actions 的特殊 file path env var, Gitea Actions 兼容 (api-compatible). 写到这两个文件等价于在 后续 step 设置 PATH 和 环境变量. 保留 go build / go vet / go test / gofmt -l . 四项 CI gate. 保留 release job 的 tag 触发 + softprops/action-gh-release@v2 上传. Co-Authored-By: Claude --- .github/workflows/build.yml | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b3f68f0..c5afb49 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,10 @@ # This workflow runs on Gitea Actions, which is API-compatible with GitHub Actions. # It performs CI on every push to main and every pull request, and automatically # builds and attaches a Linux amd64 release binary when a version tag (v*) is pushed. +# +# Go is installed manually from a Chinese mirror (NJU) instead of using +# actions/setup-go, because the runner is in a region where the official Go +# download endpoint is slow. GOPROXY is set to goproxy.cn for the same reason. name: CI / Release on: @@ -19,11 +23,15 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - cache: true + - name: Install Go (Mirror in China) + run: | + if [ ! -d "/usr/local/go" ]; then + wget https://mirrors.nju.edu.cn/golang/go1.25.5.linux-amd64.tar.gz + sudo tar -C /usr/local -xzf go1.25.5.linux-amd64.tar.gz + rm go1.25.5.linux-amd64.tar.gz + fi + echo "/usr/local/go/bin" >> $GITHUB_PATH + echo "GOPROXY=https://goproxy.cn,direct" >> $GITHUB_ENV - name: Build run: go build ./... @@ -50,11 +58,15 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - cache: true + - name: Install Go (Mirror in China) + run: | + if [ ! -d "/usr/local/go" ]; then + wget https://mirrors.nju.edu.cn/golang/go1.25.5.linux-amd64.tar.gz + sudo tar -C /usr/local -xzf go1.25.5.linux-amd64.tar.gz + rm go1.25.5.linux-amd64.tar.gz + fi + echo "/usr/local/go/bin" >> $GITHUB_PATH + echo "GOPROXY=https://goproxy.cn,direct" >> $GITHUB_ENV - name: Build release binary run: GOOS=linux GOARCH=amd64 go build -o spark-mcp-linux-amd64 ./main.go