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
|
exit 1
|
||||||
fi
|
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"
|
cd "$repository"
|
||||||
"$verifier" \
|
"$verifier" \
|
||||||
|
|||||||
@@ -93,10 +93,8 @@ if [[ "$target_type" != commit ||
|
|||||||
fi
|
fi
|
||||||
git cat-file -e "$tag_target^{commit}"
|
git cat-file -e "$tag_target^{commit}"
|
||||||
|
|
||||||
signature=$(
|
if ! git cat-file tag "$tag_object" |
|
||||||
git for-each-ref --count=1 --format='%(contents:signature)' "$tag_ref"
|
grep -q '^-----BEGIN SSH SIGNATURE-----$'; then
|
||||||
)
|
|
||||||
if [[ "$signature" != '-----BEGIN SSH SIGNATURE-----'* ]]; then
|
|
||||||
printf '%s\n' \
|
printf '%s\n' \
|
||||||
'verify-gitea-release-tag: annotated tag must use an SSH signature' >&2
|
'verify-gitea-release-tag: annotated tag must use an SSH signature' >&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -118,23 +116,40 @@ if [[ "$event_sha" != "$tag_object" && "$event_sha" != "$tag_target" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
subject=$(
|
python3 - "$tag_object" "$notes_output" <<'PY'
|
||||||
git for-each-ref --count=1 --format='%(contents:subject)' "$tag_ref"
|
from pathlib import Path
|
||||||
)
|
import subprocess
|
||||||
body=$(
|
import sys
|
||||||
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
|
|
||||||
|
|
||||||
{
|
|
||||||
printf '%s\n' "$subject"
|
def fail(message: str) -> None:
|
||||||
if [[ -n "$body" ]]; then
|
print(f"verify-gitea-release-tag: {message}", file=sys.stderr)
|
||||||
printf '\n%s\n' "$body"
|
raise SystemExit(1)
|
||||||
fi
|
|
||||||
} >"$notes_output"
|
|
||||||
|
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"
|
printf '%s\n' "$tag_target"
|
||||||
Reference in new issue
Block a user