@@ -15,17 +15,42 @@ jobs:
1515 id : get_run_id
1616 run : |
1717 run_id=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
18- "https://api.github.com/repos/${OWNER}/${REPO_NAME}/actions/workflows/binaries.yml/runs?status=success" | \
19- jq -r '.workflow_runs|sort_by(.updated_at)[-1].id')
18+ "https://api.github.com/repos/${{ github.repository }}/actions/workflows/binaries.yml/runs?status=success&per_page=1" | \
19+ jq -r '.workflow_runs[0].id')
20+ if [ -z "$run_id" ] || [ "$run_id" = "null" ]; then
21+ printf >&2 'No successful workflow runs found for binaries.yml. Cannot create release.\n'
22+ exit 1
23+ fi
2024 printf 'run_id=%s\n' "$run_id" >>"$GITHUB_OUTPUT"
2125 - name : Download all workflow run artifacts
2226 uses : actions/download-artifact@v4
2327 with :
2428 path : ./artifacts
2529 run-id : ${{ steps.get_run_id.outputs.run_id }}
26- - name : Create Release
27- uses : softprops/action-gh-release@v2
30+ github-token : ${{ secrets.GITHUB_TOKEN }}
31+ - name : Archive artifacts
32+ run : |
33+ cd artifacts || {
34+ printf >&2 'No artifacts directory. Cannot create release.\n';
35+ exit 1
36+ }
37+ found=0
38+ for dir in */; do
39+ if [ -n "$(ls -A "$dir" 2>/dev/null)" ]; then
40+ (cd "$dir" && zip -r "../${dir%/}.zip" .) || { echo "Failed to create zip for $dir"; exit 1; }
41+ found=1
42+ else
43+ echo "Skipping $dir: directory is empty"
44+ fi
45+ done
46+ if [ $found -eq 0 ]; then
47+ printf >&2 'No files to archive. Cannot create release.\n'
48+ exit 1
49+ fi
50+ - name : Create release and upload assets
51+ id : create_release
52+ uses : ncipollo/release-action@v1
2853 with :
29- files : ./artifacts/**/*
30- env :
31- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
54+ token : ${{ secrets.GITHUB_TOKEN }}
55+ artifacts : " artifacts/*.zip "
56+ tag : ${{ github.ref_name }}
0 commit comments