Skip to content

Commit ebe5813

Browse files
committed
fix workflow
1 parent cd420b0 commit ebe5813

File tree

1 file changed

+51
-11
lines changed

1 file changed

+51
-11
lines changed

.github/workflows/sign-release-assets.yml

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,68 @@ jobs:
3636
id: find
3737
shell: bash
3838
run: |
39+
set -euo pipefail
3940
shopt -s nullglob
40-
files=(dist/*.whl dist/*.tar.gz)
41-
if [ ${#files[@]} -eq 0 ]; then
41+
# Gather candidate distribution files
42+
candidates=(dist/*.whl dist/*.tar.gz)
43+
if [ ${#candidates[@]} -eq 0 ]; then
4244
echo "No distribution files found in dist/." >&2
43-
exit 1
45+
# Nothing to do; expose empty outputs
46+
echo 'inputs=' >> "$GITHUB_OUTPUT"
47+
echo 'bundles=' >> "$GITHUB_OUTPUT"
48+
exit 0
4449
fi
45-
printf '%s\n' "${files[@]}"
50+
# Filter to only those missing their .sigstore.json bundle
51+
to_sign=()
52+
bundles=()
53+
for f in "${candidates[@]}"; do
54+
b="${f}.sigstore.json"
55+
if [ ! -f "$b" ]; then
56+
to_sign+=("$f")
57+
bundles+=("$b")
58+
fi
59+
done
60+
if [ ${#to_sign[@]} -eq 0 ]; then
61+
echo "All bundles already present; nothing to sign."
62+
echo 'inputs=' >> "$GITHUB_OUTPUT"
63+
echo 'bundles=' >> "$GITHUB_OUTPUT"
64+
exit 0
65+
fi
66+
printf 'Will sign %d file(s):\n' "${#to_sign[@]}"
67+
printf '%s\n' "${to_sign[@]}"
68+
# Emit multiline outputs for subsequent steps
69+
{
70+
echo 'inputs<<EOF'
71+
printf '%s\n' "${to_sign[@]}"
72+
echo 'EOF'
73+
} >> "$GITHUB_OUTPUT"
4674
{
47-
echo 'files<<EOF'
48-
printf '%s\n' "${files[@]}"
75+
echo 'bundles<<EOF'
76+
printf '%s\n' "${bundles[@]}"
4977
echo 'EOF'
5078
} >> "$GITHUB_OUTPUT"
5179
5280
- name: Sign assets with Sigstore
81+
if: ${{ steps.find.outputs.inputs != '' }}
5382
uses: sigstore/gh-action-sigstore-python@v3.0.0
5483
with:
55-
inputs: ${{ steps.find.outputs.files }}
84+
inputs: ${{ steps.find.outputs.inputs }}
5685

5786
- name: Upload signatures to GitHub Release
87+
if: ${{ steps.find.outputs.bundles != '' }}
5888
env:
5989
GITHUB_TOKEN: ${{ github.token }}
60-
run: >-
61-
gh release upload
62-
'${{ inputs.tag }}' dist/**/*.sigstore.json
63-
--repo '${{ github.repository }}'
90+
run: |
91+
set -euo pipefail
92+
# Read bundle list from the step output and upload only new ones
93+
mapfile -t paths < <(printf '%s\n' "${{ steps.find.outputs.bundles }}")
94+
# Filter out any empty lines
95+
cleaned=()
96+
for p in "${paths[@]}"; do
97+
[ -n "$p" ] && cleaned+=("$p")
98+
done
99+
if [ ${#cleaned[@]} -gt 0 ]; then
100+
gh release upload "${{ inputs.tag }}" "${cleaned[@]}" --repo "${{ github.repository }}"
101+
else
102+
echo "No new bundles to upload."
103+
fi

0 commit comments

Comments
 (0)