Skip to content

Commit b61864a

Browse files
committed
fix: 修复GitHub Actions workflow问题
- 修复examples脚本中timeout命令在macOS上不兼容的问题 - 更新所有workflow中的action版本到最新版本 - 修复release workflow中过时的action使用 - 改进跨平台兼容性 fix: resolve GitHub Actions workflow issues - Fix timeout command compatibility in examples script for macOS - Update all action versions to latest in workflows - Fix deprecated actions in release workflow - Improve cross-platform compatibility
1 parent cf8a464 commit b61864a

File tree

6 files changed

+162
-48
lines changed

6 files changed

+162
-48
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
go-version: 1.23
6767

6868
- name: Run golangci-lint
69-
uses: golangci/golangci-lint-action@v3
69+
uses: golangci/golangci-lint-action@v4
7070
with:
7171
version: latest
7272
args: --timeout=5m

.github/workflows/quality.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
go tool cover -html=coverage.out -o coverage.html
3030
3131
- name: Upload coverage to Codecov
32-
uses: codecov/codecov-action@v3
32+
uses: codecov/codecov-action@v4
3333
with:
3434
file: ./coverage.out
3535
flags: unittests
@@ -44,7 +44,7 @@ jobs:
4444
echo "```" >> $GITHUB_STEP_SUMMARY
4545
4646
- name: Upload coverage artifacts
47-
uses: actions/upload-artifact@v3
47+
uses: actions/upload-artifact@v4
4848
with:
4949
name: coverage-report
5050
path: |
@@ -102,7 +102,7 @@ jobs:
102102
go-licenses csv ./... > licenses.csv
103103
104104
- name: Upload license report
105-
uses: actions/upload-artifact@v3
105+
uses: actions/upload-artifact@v4
106106
with:
107107
name: license-report
108108
path: licenses.csv
@@ -188,7 +188,7 @@ jobs:
188188
echo "```" >> $GITHUB_STEP_SUMMARY
189189
190190
- name: Upload benchmark results
191-
uses: actions/upload-artifact@v3
191+
uses: actions/upload-artifact@v4
192192
with:
193193
name: benchmark-comparison
194194
path: |

.github/workflows/release.yml

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ jobs:
1414
name: Create Release
1515
runs-on: ubuntu-latest
1616
outputs:
17-
upload_url: ${{ steps.create_release.outputs.upload_url }}
1817
tag_name: ${{ steps.get_version.outputs.tag_name }}
1918
steps:
2019
- name: Checkout code
@@ -46,31 +45,31 @@ jobs:
4645
4746
- name: Create Release
4847
id: create_release
49-
uses: actions/create-release@v1
48+
uses: softprops/action-gh-release@v1
5049
env:
5150
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5251
with:
5352
tag_name: ${{ steps.get_version.outputs.tag_name }}
54-
release_name: Release ${{ steps.get_version.outputs.tag_name }}
53+
name: Release ${{ steps.get_version.outputs.tag_name }}
5554
body: |
5655
## Changes in ${{ steps.get_version.outputs.tag_name }}
57-
56+
5857
${{ steps.changelog.outputs.changelog }}
59-
58+
6059
## Installation
61-
60+
6261
```bash
6362
go get github.com/scagogogo/gradle-parser@${{ steps.get_version.outputs.tag_name }}
6463
```
65-
64+
6665
## Documentation
67-
66+
6867
- [API Documentation](https://scagogogo.github.io/gradle-parser/api/)
6968
- [User Guide](https://scagogogo.github.io/gradle-parser/guide/)
7069
- [Examples](https://github.com/scagogogo/gradle-parser/tree/${{ steps.get_version.outputs.tag_name }}/examples)
71-
70+
7271
## Checksums
73-
72+
7473
See the assets below for checksums of the release artifacts.
7574
draft: false
7675
prerelease: ${{ contains(steps.get_version.outputs.tag_name, '-') }}
@@ -109,17 +108,17 @@ jobs:
109108
GOARCH: ${{ matrix.goarch }}
110109
run: |
111110
mkdir -p dist
112-
111+
113112
# Build each example
114113
for example in examples/*/; do
115114
if [ -f "$example/main.go" ]; then
116115
example_name=$(basename "$example")
117116
output_name="gradle-parser-${example_name}-${{ matrix.goos }}-${{ matrix.goarch }}"
118-
117+
119118
if [ "${{ matrix.goos }}" = "windows" ]; then
120119
output_name="${output_name}.exe"
121120
fi
122-
121+
123122
echo "Building $example_name for ${{ matrix.goos }}/${{ matrix.goarch }}"
124123
cd "$example"
125124
go build -ldflags="-s -w" -o "../dist/$output_name" .
@@ -132,44 +131,45 @@ jobs:
132131
cd dist
133132
if [ "${{ matrix.goos }}" = "windows" ]; then
134133
zip -r "gradle-parser-examples-${{ matrix.goos }}-${{ matrix.goarch }}.zip" .
135-
echo "ASSET_NAME=gradle-parser-examples-${{ matrix.goos }}-${{ matrix.goarch }}.zip" >> $GITHUB_ENV
136134
else
137135
tar -czf "gradle-parser-examples-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz" .
138-
echo "ASSET_NAME=gradle-parser-examples-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz" >> $GITHUB_ENV
139136
fi
140137
141-
- name: Upload Release Asset
142-
uses: actions/upload-release-asset@v1
143-
env:
144-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138+
- name: Upload artifacts
139+
uses: actions/upload-artifact@v4
145140
with:
146-
upload_url: ${{ needs.release.outputs.upload_url }}
147-
asset_path: ./dist/${{ env.ASSET_NAME }}
148-
asset_name: ${{ env.ASSET_NAME }}
149-
asset_content_type: application/octet-stream
150-
151-
# Generate and upload checksums
152-
checksums:
153-
name: Generate Checksums
141+
name: release-assets-${{ matrix.goos }}-${{ matrix.goarch }}
142+
path: dist/*
143+
144+
# Upload all assets to release
145+
upload-assets:
146+
name: Upload Release Assets
154147
runs-on: ubuntu-latest
155148
needs: [release, build-assets]
156149
steps:
157150
- name: Download all artifacts
158-
uses: actions/download-artifact@v3
151+
uses: actions/download-artifact@v4
152+
with:
153+
path: artifacts
159154

160-
- name: Generate checksums
155+
- name: Prepare release assets
161156
run: |
162-
find . -name "*.tar.gz" -o -name "*.zip" | xargs sha256sum > checksums.txt
157+
mkdir -p release-assets
158+
find artifacts -name "*.tar.gz" -o -name "*.zip" | while read file; do
159+
cp "$file" release-assets/
160+
done
161+
162+
# Generate checksums
163+
cd release-assets
164+
sha256sum * > checksums.txt
163165
164-
- name: Upload checksums
165-
uses: actions/upload-release-asset@v1
166+
- name: Upload all assets to release
167+
uses: softprops/action-gh-release@v1
166168
env:
167169
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
168170
with:
169-
upload_url: ${{ needs.release.outputs.upload_url }}
170-
asset_path: ./checksums.txt
171-
asset_name: checksums.txt
172-
asset_content_type: text/plain
171+
tag_name: ${{ needs.release.outputs.tag_name }}
172+
files: release-assets/*
173173

174174
# Update documentation
175175
update-docs:
@@ -208,7 +208,7 @@ jobs:
208208
notify:
209209
name: Notify Release
210210
runs-on: ubuntu-latest
211-
needs: [release, build-assets, checksums, update-docs]
211+
needs: [release, build-assets, upload-assets, update-docs]
212212
if: always()
213213
steps:
214214
- name: Release Summary

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,48 @@ This project uses GitHub Actions for comprehensive quality assurance:
273273
- 📈 Performance benchmarking
274274
- 📝 Documentation link validation
275275

276+
## 👥 Contributors
277+
278+
Thanks to all the amazing people who have contributed to this project! 🎉
279+
280+
<table>
281+
<tbody>
282+
<tr>
283+
<td align="center" valign="top" width="14.28%">
284+
<a href="https://github.com/CC11001100">
285+
<img src="https://avatars.githubusercontent.com/u/12819457?v=4" width="100px;" alt="CC11001100"/>
286+
<br />
287+
<sub><b>CC11001100</b></sub>
288+
</a>
289+
<br />
290+
<sub>💻 📖 🎨 🚧</sub>
291+
<br />
292+
<sub>27 commits</sub>
293+
</td>
294+
<td align="center" valign="top" width="14.28%">
295+
<a href="https://github.com/AdamKorcz">
296+
<img src="https://avatars.githubusercontent.com/u/44787359?v=4" width="100px;" alt="AdamKorcz"/>
297+
<br />
298+
<sub><b>Adam Korczynski</b></sub>
299+
</a>
300+
<br />
301+
<sub>🐛 🔧</sub>
302+
<br />
303+
<sub>1 commit</sub>
304+
</td>
305+
</tr>
306+
</tbody>
307+
</table>
308+
309+
### 🏆 Contribution Types
310+
311+
- 💻 Code
312+
- 📖 Documentation
313+
- 🎨 Design
314+
- 🚧 Maintenance
315+
- 🐛 Bug fixes
316+
- 🔧 Tools
317+
276318
## 🤝 Contributing
277319

278320
Contributions are welcome! Please see the [Contributing Guide](CONTRIBUTING.md) for details.

README_zh.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,48 @@ cd examples && ./run-all-examples.sh
273273
- 📈 性能基准测试
274274
- 📝 文档链接验证
275275

276+
## 👥 贡献者
277+
278+
感谢所有为这个项目做出贡献的优秀开发者!🎉
279+
280+
<table>
281+
<tbody>
282+
<tr>
283+
<td align="center" valign="top" width="14.28%">
284+
<a href="https://github.com/CC11001100">
285+
<img src="https://avatars.githubusercontent.com/u/12819457?v=4" width="100px;" alt="CC11001100"/>
286+
<br />
287+
<sub><b>CC11001100</b></sub>
288+
</a>
289+
<br />
290+
<sub>💻 📖 🎨 🚧</sub>
291+
<br />
292+
<sub>27次提交</sub>
293+
</td>
294+
<td align="center" valign="top" width="14.28%">
295+
<a href="https://github.com/AdamKorcz">
296+
<img src="https://avatars.githubusercontent.com/u/44787359?v=4" width="100px;" alt="AdamKorcz"/>
297+
<br />
298+
<sub><b>Adam Korczynski</b></sub>
299+
</a>
300+
<br />
301+
<sub>🐛 🔧</sub>
302+
<br />
303+
<sub>1次提交</sub>
304+
</td>
305+
</tr>
306+
</tbody>
307+
</table>
308+
309+
### 🏆 贡献类型
310+
311+
- 💻 代码贡献
312+
- 📖 文档编写
313+
- 🎨 设计优化
314+
- 🚧 项目维护
315+
- 🐛 错误修复
316+
- 🔧 工具改进
317+
276318
## 🤝 贡献
277319

278320
欢迎贡献!请查看[贡献指南](CONTRIBUTING.md)了解详情。

examples/run-all-examples.sh

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,43 @@ run_example() {
3333
fi
3434

3535
cd "$dir"
36-
37-
# Run the example with timeout
38-
timeout 30s go run main.go
39-
local exit_code=$?
40-
36+
37+
# Run the example with timeout (cross-platform compatible)
38+
if command -v timeout &> /dev/null; then
39+
# Linux/GNU timeout
40+
timeout 30s go run main.go
41+
local exit_code=$?
42+
elif command -v gtimeout &> /dev/null; then
43+
# macOS with GNU coreutils (brew install coreutils)
44+
gtimeout 30s go run main.go
45+
local exit_code=$?
46+
else
47+
# Fallback: run without timeout on macOS
48+
go run main.go &
49+
local pid=$!
50+
local timeout=30
51+
local elapsed=0
52+
53+
while [ $elapsed -lt $timeout ]; do
54+
if ! kill -0 $pid 2>/dev/null; then
55+
wait $pid
56+
local exit_code=$?
57+
break
58+
fi
59+
sleep 1
60+
elapsed=$((elapsed + 1))
61+
done
62+
63+
# If still running after timeout, kill it
64+
if kill -0 $pid 2>/dev/null; then
65+
kill $pid 2>/dev/null
66+
wait $pid 2>/dev/null
67+
local exit_code=124 # timeout exit code
68+
fi
69+
fi
70+
4171
cd ..
42-
72+
4373
if [ $exit_code -eq 0 ]; then
4474
echo -e "${GREEN}$name completed successfully${NC}"
4575
return 0

0 commit comments

Comments
 (0)