@@ -36,28 +36,68 @@ jobs:
36
36
id : find
37
37
shell : bash
38
38
run : |
39
+ set -euo pipefail
39
40
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
42
44
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
44
49
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"
46
74
{
47
- echo 'files <<EOF'
48
- printf '%s\n' "${files [@]}"
75
+ echo 'bundles <<EOF'
76
+ printf '%s\n' "${bundles [@]}"
49
77
echo 'EOF'
50
78
} >> "$GITHUB_OUTPUT"
51
79
52
80
- name : Sign assets with Sigstore
81
+ if : ${{ steps.find.outputs.inputs != '' }}
53
82
uses : sigstore/gh-action-sigstore-python@v3.0.0
54
83
with :
55
- inputs : ${{ steps.find.outputs.files }}
84
+ inputs : ${{ steps.find.outputs.inputs }}
56
85
57
86
- name : Upload signatures to GitHub Release
87
+ if : ${{ steps.find.outputs.bundles != '' }}
58
88
env :
59
89
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