55 tags :
66 - ' v*'
77
8+ permissions :
9+ contents : write
10+
811jobs :
912 build :
1013 name : Build and Release
@@ -57,13 +60,21 @@ jobs:
5760 - name : Cache Go modules
5861 uses : actions/cache@v4
5962 with :
60- path : ~/go/pkg/mod
61- key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
63+ path : |
64+ ~/.cache/go-build
65+ ~/go/pkg/mod
66+ key : ${{ runner.os }}-go-${{ matrix.goos }}-${{ matrix.goarch }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }}
6267 restore-keys : |
68+ ${{ runner.os }}-go-${{ matrix.goos }}-${{ matrix.goarch }}-
6369 ${{ runner.os }}-go-
70+ fail-on-cache-miss : false
6471
6572 - name : Download dependencies
66- run : go mod download
73+ run : |
74+ go mod download
75+ go mod tidy
76+ go mod verify || true
77+ # 如果verify失败,继续构建,因为可能是CI环境中的临时问题
6778
6879 - name : Build
6980 env :
7485 run : |
7586 mkdir -p dist
7687 output_name="${{ matrix.filename }}"
77- go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o "dist/${output_name}" .
88+ # 确保在构建前重新同步依赖
89+ go mod download
90+ go build -mod=readonly -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o "dist/${output_name}" .
7891
7992 - name : Create archive
8093 run : |
@@ -116,23 +129,7 @@ jobs:
116129 done
117130 ls -la release-assets/
118131
119- - name : Generate changelog
120- id : changelog
121- run : |
122- # 获取上一个tag
123- PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
124- if [ -n "$PREVIOUS_TAG" ]; then
125- echo "## 更新内容" > CHANGELOG.md
126- echo "" >> CHANGELOG.md
127- git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD >> CHANGELOG.md
128- else
129- echo "## 首次发布" > CHANGELOG.md
130- echo "" >> CHANGELOG.md
131- git log --pretty=format:"- %s (%h)" >> CHANGELOG.md
132- fi
133- echo "changelog<<EOF" >> $GITHUB_OUTPUT
134- cat CHANGELOG.md >> $GITHUB_OUTPUT
135- echo "EOF" >> $GITHUB_OUTPUT
132+
136133
137134 - name : Create Release
138135 uses : softprops/action-gh-release@v2
@@ -141,8 +138,6 @@ jobs:
141138 body : |
142139 # 🎉 Release ${{ github.ref_name }}
143140
144- ${{ steps.changelog.outputs.changelog }}
145-
146141 ## 📦 下载
147142
148143 选择适合您系统的二进制文件:
@@ -163,8 +158,8 @@ jobs:
163158
164159 1. 下载适合您系统的压缩包
165160 2. 解压后获得可执行文件
166- 3. 根据需要配置 `defaultConfig .yml`
167- 4. 运行 `./webhookGo` (Linux/macOS) 或 `webhookGo.exe` (Windows)
161+ 3. 根据需要配置 `config .yml`
162+ 4. 运行 `./webhookGo -c config.yml ` (Linux/macOS) 或 `webhookGo.exe -c config.yml ` (Windows)
168163
169164 ---
170165
0 commit comments