Fix subject-only signed release tags
Modular container CI / release-build (push) Failing after 23m53s
Modular container CI / release-build (push) Failing after 23m53s
This commit is contained in:
2 files changed
+52
-21
No files matched your search
@@ -62,6 +62,22 @@ if grep -Fq -- 'SSH SIGNATURE' "$temporary/notes.md"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Git 2.34 can underflow while formatting %(contents:body) for an SSH-signed
|
||||
# tag with only a subject. Subject-only release notes must remain supported.
|
||||
git -C "$repository" switch -q main
|
||||
git -C "$repository" tag -s -a v1.2.4 -m 'Echoion 1.2.4'
|
||||
subject_only_tag=$(git -C "$repository" rev-parse 'refs/tags/v1.2.4^{tag}')
|
||||
(
|
||||
cd "$repository"
|
||||
"$verifier" \
|
||||
--tag v1.2.4 \
|
||||
--event-sha "$subject_only_tag" \
|
||||
--allowed-signers "$temporary/allowed-signers" \
|
||||
--notes-output "$temporary/subject-only-notes.md" \
|
||||
>/dev/null
|
||||
)
|
||||
test "$(<"$temporary/subject-only-notes.md")" = 'Echoion 1.2.4'
|
||||
|
||||
(
|
||||
cd "$repository"
|
||||
"$verifier" \
|
||||
|
||||
@@ -93,10 +93,8 @@ if [[ "$target_type" != commit ||
|
||||
fi
|
||||
git cat-file -e "$tag_target^{commit}"
|
||||
|
||||
signature=$(
|
||||
git for-each-ref --count=1 --format='%(contents:signature)' "$tag_ref"
|
||||
)
|
||||
if [[ "$signature" != '-----BEGIN SSH SIGNATURE-----'* ]]; then
|
||||
if ! git cat-file tag "$tag_object" |
|
||||
grep -q '^-----BEGIN SSH SIGNATURE-----$'; then
|
||||
printf '%s\n' \
|
||||
'verify-gitea-release-tag: annotated tag must use an SSH signature' >&2
|
||||
exit 1
|
||||
@@ -118,23 +116,40 @@ if [[ "$event_sha" != "$tag_object" && "$event_sha" != "$tag_target" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
subject=$(
|
||||
git for-each-ref --count=1 --format='%(contents:subject)' "$tag_ref"
|
||||
)
|
||||
body=$(
|
||||
git for-each-ref --count=1 --format='%(contents:body)' "$tag_ref"
|
||||
)
|
||||
if [[ -z "$subject" ]]; then
|
||||
printf '%s\n' \
|
||||
'verify-gitea-release-tag: annotated tag has no release-note subject' >&2
|
||||
exit 1
|
||||
fi
|
||||
python3 - "$tag_object" "$notes_output" <<'PY'
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
{
|
||||
printf '%s\n' "$subject"
|
||||
if [[ -n "$body" ]]; then
|
||||
printf '\n%s\n' "$body"
|
||||
fi
|
||||
} >"$notes_output"
|
||||
|
||||
def fail(message: str) -> None:
|
||||
print(f"verify-gitea-release-tag: {message}", file=sys.stderr)
|
||||
raise SystemExit(1)
|
||||
|
||||
|
||||
tag = subprocess.run(
|
||||
["git", "cat-file", "tag", sys.argv[1]],
|
||||
check=True,
|
||||
stdout=subprocess.PIPE,
|
||||
).stdout
|
||||
try:
|
||||
_, message = tag.split(b"\n\n", 1)
|
||||
except ValueError:
|
||||
fail("annotated tag has no release-note subject")
|
||||
|
||||
marker = b"\n-----BEGIN SSH SIGNATURE-----\n"
|
||||
signature_offset = message.rfind(marker)
|
||||
if signature_offset < 0:
|
||||
fail("annotated tag must use an SSH signature")
|
||||
notes = message[:signature_offset]
|
||||
try:
|
||||
text = notes.decode("utf-8").rstrip("\n")
|
||||
except UnicodeDecodeError:
|
||||
fail("release notes are not valid UTF-8")
|
||||
if not text or not text.splitlines()[0]:
|
||||
fail("annotated tag has no release-note subject")
|
||||
|
||||
Path(sys.argv[2]).write_text(text + "\n", encoding="utf-8")
|
||||
PY
|
||||
|
||||
printf '%s\n' "$tag_target"
|
||||
Reference in new issue
Block a user