@@ -60,38 +60,26 @@ jobs:
6060 path : dist/PS2Code-*-x64.exe
6161 if-no-files-found : error
6262
63- # 汇总:列出所有构建产物
63+ # 汇总:展示 mac + win 产物下载链接
6464 summarize :
6565 needs : [build-mac-arm64, build-win-x64]
6666 runs-on : ubuntu-latest
67+ permissions :
68+ actions : read
6769 steps :
68- - name : Download all artifacts
69- uses : actions/download-artifact@v4
70-
71- - name : List artifacts in summary
72- shell : bash
73- run : |
74- echo "## ✅ 构建完成" >> $GITHUB_STEP_SUMMARY
75- echo "" >> $GITHUB_STEP_SUMMARY
76- echo "### 下载产物" >> $GITHUB_STEP_SUMMARY
77- echo "" >> $GITHUB_STEP_SUMMARY
78- echo "| 平台 | 文件 | 大小 |" >> $GITHUB_STEP_SUMMARY
79- echo "|------|------|------|" >> $GITHUB_STEP_SUMMARY
80- for dir in PS2Code-*/; do
81- if [ -d "$dir" ]; then
82- file=$(ls "$dir" 2>/dev/null | head -1)
83- if [ -n "$file" ]; then
84- size=$(du -h "$dir/$file" 2>/dev/null | cut -f1)
85- echo "| $dir | $file | $size |" >> $GITHUB_STEP_SUMMARY
86- fi
87- fi
88- done
89- echo "" >> $GITHUB_STEP_SUMMARY
90- echo "> 产物可从 Actions 页面 Artifacts 区域下载" >> $GITHUB_STEP_SUMMARY
91- echo ""
92- echo "=== 构建产物清单 ==="
93- for dir in PS2Code-*/; do
94- if [ -d "$dir" ]; then
95- ls -lh "$dir"
96- fi
97- done
70+ - uses : actions/github-script@v7
71+ with :
72+ script : |
73+ const { data } = await github.rest.actions.listWorkflowRunArtifacts({
74+ owner: context.repo.owner,
75+ repo: context.repo.repo,
76+ run_id: context.runId,
77+ });
78+ let summary = '## ✅ 构建完成\n\n';
79+ for (const art of data.artifacts) {
80+ const url = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/artifacts/${art.id}`;
81+ summary += `- **${art.name}** (<code>${art.sizeInBytes > 1048576 ? (art.sizeInBytes / 1048576).toFixed(1) + ' MB' : (art.sizeInBytes / 1024).toFixed(1) + ' KB'}</code>) — Artifact download URL: ${url}\n`;
82+ }
83+ core.summary = summary;
84+ await core.summary.write();
85+ console.log(summary);
0 commit comments