Skip to content

Commit bb3174b

Browse files
committed
fixed ci
Signed-off-by: Polina Simonenko <rabarbrablad@gmail.com>
1 parent 7c3e508 commit bb3174b

1 file changed

Lines changed: 61 additions & 18 deletions

File tree

bin/adopt-release.sh

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,45 @@ echo "==> reading ${download}/SHA256SUMS"
4141
curl --fail --silent --show-error --location --proto '=https' --tlsv1.2 \
4242
--max-time 120 --output "$scratch/SHA256SUMS" "${download}/SHA256SUMS"
4343

44-
adopted=0
44+
# repositoryFor decides where an artifact belongs, or reports that it is not a
45+
# package at all.
46+
#
47+
# A release carries more than packages — checksums, signatures, SBOMs,
48+
# provenance — and those are not failures, they are simply not ours. An artifact
49+
# this workspace could serve but has nowhere to put is a different thing: that
50+
# is a repository someone meant to configure and did not.
51+
repositoryFor() {
52+
case "$1" in
53+
*.deb) echo apt ;;
54+
*.rpm) echo yum ;;
55+
*.apk) echo alpine ;;
56+
*.tgz) echo charts ;;
57+
*.tar.gz|*.tar.xz|*.tar.zst|*.tar.bz2|*.zip) echo releases ;;
58+
*) echo "" ;;
59+
esac
60+
}
61+
62+
configured() {
63+
grep -q "^\[repo\.$1\]" snailmail.toml
64+
}
65+
66+
# Everything is classified before anything is adopted, so a missing repository
67+
# stops the run while the workspace is still untouched rather than half way
68+
# through it.
69+
plan="$scratch/plan"
70+
: > "$plan"
71+
missing=""
72+
skipped=0
4573
while read -r digest name; do
46-
# sha256sum writes "<digest> ./<name>"; drop the leading marker.
4774
name=${name#\*}
4875
name=${name#./}
4976
case "$name" in
50-
''|SHA256SUMS) continue ;;
77+
''|SHA256SUMS|*.sig|*.asc|*.pem|*.sbom.json|*.spdx.json|*.cdx.json|*.intoto.jsonl)
78+
[ -n "$name" ] && [ "$name" != SHA256SUMS ] && {
79+
echo " not a package, leaving alone: $name"
80+
skipped=$((skipped + 1))
81+
}
82+
continue ;;
5183
esac
5284
case "$digest" in
5385
[0-9a-f]*) ;;
@@ -58,26 +90,37 @@ while read -r digest name; do
5890
exit 1
5991
fi
6092

61-
# Which repository serves an artifact is decided by what it is, so a new
62-
# asset type fails here rather than landing somewhere arbitrary.
63-
case "$name" in
64-
*.deb) target=apt ;;
65-
*.rpm) target=yum ;;
66-
*.apk) target=alpine ;;
67-
*.tgz) target=charts ;;
68-
*.tar.gz|*.tar.xz|*.tar.zst|*.tar.bz2|*.zip) target=releases ;;
69-
*)
70-
echo "$0: no repository serves '$name'; add a rule to $0" >&2
71-
exit 1 ;;
72-
esac
93+
target=$(repositoryFor "$name")
94+
if [ -z "$target" ]; then
95+
echo " unrecognised, leaving alone: $name"
96+
skipped=$((skipped + 1))
97+
continue
98+
fi
99+
if ! configured "$target"; then
100+
missing="${missing} ${name} needs a '${target}' repository"$'\n'
101+
continue
102+
fi
103+
printf '%s %s %s\n' "$digest" "$target" "$name" >> "$plan"
104+
done < "$scratch/SHA256SUMS"
73105

106+
if [ -n "$missing" ]; then
107+
{
108+
echo "$0: this release carries packages with nowhere to go:"
109+
printf '%s' "$missing"
110+
echo "configure them with 'snailmail setup', or nothing will publish them."
111+
} >&2
112+
exit 1
113+
fi
114+
115+
adopted=0
116+
while read -r digest target name; do
74117
echo "==> adopt ${target}: ${name}"
75118
"$snailmail" adopt --sha256 "$digest" --public-origin "$target" "${download}/${name}"
76119
adopted=$((adopted + 1))
77-
done < "$scratch/SHA256SUMS"
120+
done < "$plan"
78121

79122
if [ "$adopted" -eq 0 ]; then
80-
echo "$0: SHA256SUMS listed no adoptable assets" >&2
123+
echo "$0: SHA256SUMS listed no adoptable packages" >&2
81124
exit 1
82125
fi
83-
echo "==> adopted ${adopted} artifacts from ${repository} ${tag}"
126+
echo "==> adopted ${adopted} artifacts from ${repository} ${tag} (${skipped} left alone)"

0 commit comments

Comments
 (0)