Skip to content

Commit 8f828fa

Browse files
authored
Merge pull request #29 from WarnerMedia/bugfix/release-workflow
get automatic release workflow working
2 parents 5b10693 + 39bff74 commit 8f828fa

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

.github/workflows/binaries.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ description: build standalone executables using PyInstaller
44
on:
55
push:
66
branches:
7-
- '*'
8-
pull_request:
9-
branches:
10-
- '*'
7+
- 'master'
118
workflow_dispatch:
129

1310
jobs:

.github/workflows/release.yml

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)