feat(release): the switch: the maintainer signs and pushes the tag, and CI and the co-signer do the rest

scripts/publish.sh's default is now the maintainer's whole part of a
release that CI builds and the co-signer publishes: the tag's checks,
then main and the tag pushed to origin, which starts the Release
workflow, and what comes next. It needs git alone. It refuses a tag
whose commit has no release keys, which CI's workflow would refuse, and
a version with no changelog entry, which the co-signer takes the notes
from.

- scripts/publish.sh --sign-legacy, the one command for the bridge:
  VERSION's draft release, which the co-signer made, has SHA256SUMS,
  SHA256SUMS.ci.minisig and SHA256SUMS.cosign.minisig downloaded, and
  scripts/release.sh --sign-legacy checks both signatures with this
  checkout's packaging/keys and devvm-release <version>, then signs
  SHA256SUMS with the old key, devvm <version>, and checks that with
  packaging/minisign.pub; after asking once, SHA256SUMS.minisig goes on
  the draft, which the co-signer waits for, then publishes. A draft
  that has it already, or a published release, or a draft without the
  co-signer's signature yet, is said so, and nothing is uploaded. A
  checkout without the release keys is refused before anything is
  signed, pointing at github-setup.md's step 1, as is the default
  mode's tag without them.
- scripts/publish.sh --local, the old path, as it was: built, signed
  with the old key alone and published from this machine. It stays
  until the GitHub setup for CI and the co-signer is done, and goes
  when the bridge ends, as a release that only the old key signed is
  then one no devvm accepts. A flag, not the default, because the
  default is what's documented and what's safe to run at any time: it
  publishes nothing itself, so run before the setup it only pushes a
  tag whose workflow run fails; and a --local release after the
  co-signer starts is one it alerts on, as it didn't publish it.
- scripts/release.sh --check-tag: --check's tag and keys checks alone,
  with no container runtime or signing key, which the default mode runs.
- The shared parts are one function each: check_tag (the tag, main
  and origin), notes (the changelog entry), ask (the question), needs_gh.
- release.sh's closing line names publish.sh --local, and --tag's build,
  CI's and the co-signer's, has none.

Tests: testdata/script/publish_tag.txtar (the modes in --help, two
modes refused, no tag, another signer, a dirty tree, no release keys,
no changelog entry, a tag off main's HEAD, --dry-run, n, y and the
pushes in order, again with nothing to push, origin's other tag;
--sign-legacy: gh logged out, no draft, no co-signer signature yet, a
co-signer signature by another key, CI's for another version, --dry-run,
y and the upload, which verifies as devvm 1.2.3, again with nothing to
do, a published release, a checkout without the release keys), failing
before the code; publish.txtar runs the old path as --local, in a repo
without release keys, as devvm is until they're made: SHA256SUMS signed
with the old key alone, no role signatures, install.sh's key lines
empty.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
w3cjandClaude Opus 5.5 committed 2026-11-30 21:36:37 -07:00
1 parent 5b2786c758
commit 19ae9a7071
4 files changed
+568 -72

No files matched your search

+161 -37
View File
@@ -1,11 +1,28 @@
#!/bin/bash
# Publish the release VERSION names, after git tag -s v<version> on main's HEAD:
# scripts/publish.sh check, build dist/ (scripts/release.sh, which asks for the minisign
# password), show what it publishes, ask once, then publish
# scripts/publish.sh --dry-run everything up to the question: nothing is pushed or published, and the
# tap gets no commit
# scripts/publish.sh --help this
# It pushes main and the tag to origin, makes the GitHub release devvmhq/devvm v<version> with the archives,
# Release the version VERSION names, after git tag -s v<version> on main's HEAD. CI's Release workflow
# builds and signs it, and the co-signer rebuilds it, signs it and publishes it, with the tap
# (docs/content/docs/contributing/maintaining.md):
# scripts/publish.sh check the tag, show what it pushes, ask once, then push main and the
# tag to origin, which starts CI's Release workflow, and say what's next
# scripts/publish.sh --sign-legacy
# while releases bridge from the old release key: VERSION's draft
# release, which the co-signer made, has its SHA256SUMS checked against
# CI's and the co-signer's signatures and signed with the old key
# (scripts/release.sh --sign-legacy, which asks for its password), then,
# after asking once, SHA256SUMS.minisig is uploaded to the draft, and the
# co-signer publishes the release at its next run
# scripts/publish.sh --local the release built, signed with the old key alone and published from
# this machine, as before CI and the co-signer, for as long as their
# GitHub setup isn't done (docs/content/docs/contributing/github-setup.md)
# --dry-run with any of them, everything up to the question: nothing is pushed,
# uploaded or published, and the tap gets no commit
# scripts/publish.sh --help this
# Without --local, it needs git alone, and --sign-legacy needs gh, logged in, and minisign. Both refuse
# a tag whose commit has no release keys in packaging/keys, which CI's workflow refuses, and say where
# making them is described (docs/content/docs/contributing/github-setup.md, step 1); --local doesn't
# need them, and signs with the old release key alone while there are none.
# --local builds dist/ (scripts/release.sh, which asks for the minisign password), shows what it
# publishes, asks once, then publishes: it pushes main and the tag to origin, makes the GitHub release devvmhq/devvm v<version> with the archives,
# the source tarball, SHA256SUMS, SHA256SUMS.minisig and install.sh, its notes CHANGELOG.md's entry, then
# commits dist/devvm.rb to the tap's Formula/devvm.rb, and dist/devvm-rc.rb to its Formula/devvm-rc.rb when
# the tap's devvm-rc is older, so devvm-rc's users get the release too, and pushes the tap. Each step skips
@@ -25,10 +42,13 @@ repo=devvmhq/devvm
die() { echo "publish: $*" >&2; exit 1; }
usage() { awk 'NR > 1 && /^#/ { sub(/^# ?/, ""); print; next } NR > 1 { exit }' "$root/scripts/publish.sh"; }
dry=false
dry=false mode=
for a in "$@"; do
case $a in
--dry-run) dry=true ;;
--local | --sign-legacy)
[[ -z $mode || $mode == "$a" ]] || { echo "publish: $mode and $a are two modes: give one" >&2; exit 2; }
mode=$a ;;
-h | --help) usage; exit 0 ;;
*) echo "publish: unknown argument '$a'" >&2; usage >&2; exit 2 ;;
esac
@@ -72,24 +92,137 @@ newer() {
((10#${a[4]} > 10#${b[4]}))
}
# The preconditions, before anything asks for the password.
# needs_gh: gh, logged in, and minisign, which every mode but the default needs.
needs_gh() {
command -v gh >/dev/null || die "needs gh, GitHub's command line (brew install gh)"
gh auth status >/dev/null 2>&1 || die "gh isn't logged in to GitHub: run gh auth login"
command -v minisign >/dev/null || die "needs minisign (mise exec -- scripts/publish.sh)"
}
# check_tag CHECK: the tag exists, is signed, and by a key in packaging/release-signer, by release.sh's
# own checks, CHECK (--check, or --check-tag, which needs no container runtime); its commit is main's
# HEAD, origin's main is an ancestor of it, and origin has no other tag of its name. It sets commit,
# tagobj, origin_main and origin_tag.
check_tag() {
local main
commit=$(scripts/release.sh "$1") || exit 1
main=$(git rev-parse -q --verify refs/heads/main) || die "no branch main"
[[ $main == "$commit" ]] || die "tag $tag is at ${commit:0:12}, not main's HEAD (${main:0:12}): tag main's HEAD"
tagobj=$(git rev-parse "refs/tags/$tag")
origin_main=$(remote_ref . refs/heads/main) || die "can't read origin (git ls-remote origin)"
if [[ -n $origin_main && $origin_main != "$commit" ]]; then
git merge-base --is-ancestor "$origin_main" "$commit" 2>/dev/null ||
die "origin's main has commits main lacks: pull, then tag main's HEAD again"
fi
origin_tag=$(remote_ref . "refs/tags/$tag") || die "can't read origin (git ls-remote origin)"
[[ -z $origin_tag || $origin_tag == "$tagobj" ]] ||
die "origin has another tag $tag: this one is $tagobj, origin's $origin_tag"
}
# notes FILE: the release's notes, the tag's CHANGELOG.md entry ## <version>, in FILE, without the
# heading or the blank lines at either end; FILE is empty for no entry.
notes() {
git show "$commit:CHANGELOG.md" | awk -v h="## $v" '
$0 == h { on = 1; next }
on && /^## / { exit }
on && NF { if (started) for (; blank > 0; blank--) print ""; print; started = 1; blank = 0; next }
on { blank++ }' > "$1"
}
# ask QUESTION REFUSED: QUESTION on the terminal, [y/N]; any answer but y stops it, saying REFUSED.
ask() {
local answer=
{ : </dev/tty; } 2>/dev/null || die "no terminal to ask on: $2"
printf '%s [y/N] ' "$1" >/dev/tty
read -r answer </dev/tty || true
[[ $answer == y || $answer == Y ]] || die "$2"
}
# push_tag: the default mode, the maintainer's part of a release that CI builds and the co-signer
# publishes: the tag's checks, then main and the tag pushed to origin, and what comes next.
push_tag() {
local done_main=false done_tag=false tmp
[[ -z $(git status --porcelain) ]] || die "the working tree isn't clean: commit or remove what git status lists"
check_tag --check-tag
# CI's workflow builds only a commit with the three release keys, which its devvm checks CI's and
# the co-signer's signatures with.
git cat-file -e "$commit:packaging/keys/release-ci.pub" 2>/dev/null ||
die "$tag's commit has no release keys in packaging/keys, so CI's Release workflow refuses it: make them first (docs/content/docs/contributing/github-setup.md, step 1), or publish it from this machine with --local"
# The co-signer takes the release's notes from the changelog.
tmp=$(mktemp "${TMPDIR:-/tmp}/devvm-publish.XXXXXX")
notes "$tmp"
[[ -s $tmp ]] || { rm -f "$tmp"; die "CHANGELOG.md has no entry ## $v: nothing pushed"; }
rm -f "$tmp"
[[ $origin_main != "$commit" ]] || done_main=true
[[ $origin_tag != "$tagobj" ]] || done_tag=true
echo
echo "==> devvm $v, to push"
if $pre; then echo "Version: $v, a prerelease"; else echo "Version: $v"; fi
echo "Tag: $tag, signed, at commit $commit"
echo
echo "Steps:"
echo " 1. git push origin main: $(state $done_main "to do")"
echo " 2. git push origin $tag: $(state $done_tag "to do")"
echo
if $done_main && $done_tag; then
echo "$tag and main are already on origin: nothing to push."
else
if $dry; then echo "--dry-run: nothing pushed."; exit 0; fi
ask "Push main and $tag to origin?" "nothing pushed"
$done_main || git push origin main
$done_tag || git push origin "refs/tags/$tag"
echo
echo "==> $tag is on origin. What comes next:"
fi
echo " 1. Approve the Release workflow's run for $tag in its release environment, at https://github.com/$repo/actions/workflows/release.yml."
echo " 2. Within the hour, the co-signer rebuilds it, signs it and makes its draft release, or tells you why not."
echo " 3. While releases bridge from the old release key, sign the draft's SHA256SUMS with it: scripts/publish.sh --sign-legacy."
echo " 4. At its next run, the co-signer publishes the release and updates the tap."
}
# sign_legacy: --sign-legacy, the old release key's signature on the co-signer's draft of VERSION's
# release, checked against CI's and the co-signer's signatures first, then uploaded.
sign_legacy() {
# tmp isn't local: the trap reads it once sign_legacy has returned.
local out assets f
needs_gh
if ! out=$(gh release view "$tag" --repo "$repo" --json isDraft,assets --jq '(.isDraft | tostring), .assets[].name' 2>&1); then
grep -qi 'not found' <<<"$out" || die "can't read the GitHub release $tag (gh release view): $out"
die "devvm $tag has no draft release yet: the co-signer makes it once CI's build and its own match"
fi
[[ $(head -n1 <<<"$out") == true ]] || die "devvm $tag's GitHub release is already published"
assets=$(tail -n +2 <<<"$out")
if grep -qxF SHA256SUMS.minisig <<<"$assets"; then
echo "devvm $tag's draft already has SHA256SUMS.minisig: nothing to do. The co-signer publishes it at its next run."
return 0
fi
for f in SHA256SUMS SHA256SUMS.ci.minisig SHA256SUMS.cosign.minisig; do
grep -qxF "$f" <<<"$assets" ||
die "devvm $tag's draft has no $f yet: the co-signer uploads it with its signature, so wait for its next run"
done
tmp=$(mktemp -d "${TMPDIR:-/tmp}/devvm-publish.XXXXXX")
trap 'rm -rf "$tmp"' EXIT
gh release download "$tag" --repo "$repo" --dir "$tmp" --pattern SHA256SUMS --pattern SHA256SUMS.ci.minisig \
--pattern SHA256SUMS.cosign.minisig >/dev/null || die "can't download the draft's SHA256SUMS and its signatures: nothing signed or uploaded"
scripts/release.sh --sign-legacy "$tmp" || die "nothing signed or uploaded"
echo
echo "==> devvm $v's SHA256SUMS, which CI and the co-signer signed, signed with the old release key:"
sed 's/^/ /' "$tmp/SHA256SUMS"
echo
if $dry; then echo "--dry-run: nothing uploaded."; exit 0; fi
ask "Upload SHA256SUMS.minisig to devvm $v's draft release?" "nothing uploaded"
gh release upload "$tag" --repo "$repo" "$tmp/SHA256SUMS.minisig" ||
die "the upload failed: run scripts/publish.sh --sign-legacy again"
echo "==> uploaded: the co-signer publishes devvm $v at its next run, within the hour."
}
state() { if $1; then echo "done"; else echo "$2"; fi; }
case $mode in
"") push_tag; exit 0 ;;
--sign-legacy) sign_legacy; exit 0 ;;
esac
# --local: the preconditions, before anything asks for the password.
[[ -z $(git status --porcelain) ]] || die "the working tree isn't clean: commit or remove what git status lists"
command -v gh >/dev/null || die "needs gh, GitHub's command line (brew install gh)"
gh auth status >/dev/null 2>&1 || die "gh isn't logged in to GitHub: run gh auth login"
command -v minisign >/dev/null || die "needs minisign (mise exec -- scripts/publish.sh)"
# The tag: it exists, is signed, and by a key in packaging/release-signer; release.sh's own checks.
commit=$(scripts/release.sh --check) || exit 1
main=$(git rev-parse -q --verify refs/heads/main) || die "no branch main"
[[ $main == "$commit" ]] || die "tag $tag is at ${commit:0:12}, not main's HEAD (${main:0:12}): tag main's HEAD"
tagobj=$(git rev-parse "refs/tags/$tag")
origin_main=$(remote_ref . refs/heads/main) || die "can't read origin (git ls-remote origin)"
if [[ -n $origin_main && $origin_main != "$commit" ]]; then
git merge-base --is-ancestor "$origin_main" "$commit" 2>/dev/null ||
die "origin's main has commits main lacks: pull, then tag main's HEAD again"
fi
origin_tag=$(remote_ref . "refs/tags/$tag") || die "can't read origin (git ls-remote origin)"
[[ -z $origin_tag || $origin_tag == "$tagobj" ]] ||
die "origin has another tag $tag: this one is $tagobj, origin's $origin_tag"
needs_gh
check_tag --check
files=()
for os in darwin linux; do
@@ -147,11 +280,7 @@ for f in "${files[@]}" ${tap_files[@]+"${tap_files[@]}"}; do [[ -f dist/$f ]] ||
tmp=$(mktemp -d "${TMPDIR:-/tmp}/devvm-publish.XXXXXX")
trap 'rm -rf "$tmp"' EXIT
notes=$tmp/notes.md
git show "$commit:CHANGELOG.md" | awk -v h="## $v" '
$0 == h { on = 1; next }
on && /^## / { exit }
on && NF { if (started) for (; blank > 0; blank--) print ""; print; started = 1; blank = 0; next }
on { blank++ }' > "$notes"
notes "$notes"
[[ -s $notes ]] || die "CHANGELOG.md has no entry ## $v: nothing published"
# A published release is this build's only if its SHA256SUMS is dist/'s.
if [[ $release == published ]]; then
@@ -172,7 +301,6 @@ if ((${#tap_files[@]})); then
else
done_tap=true
fi
state() { if $1; then echo "done"; else echo "$2"; fi; }
echo
echo "==> devvm $v, to publish"
@@ -237,11 +365,7 @@ if $done_main && $done_tag && $done_release && $done_tap; then
fi
if $dry; then echo "--dry-run: nothing published."; exit 0; fi
{ : </dev/tty; } 2>/dev/null || die "no terminal to ask on: nothing published"
printf 'Publish devvm %s? [y/N] ' "$v" >/dev/tty
answer=
read -r answer </dev/tty || true
[[ $answer == y || $answer == Y ]] || die "nothing published"
ask "Publish devvm $v?" "nothing published"
step_main() {
$done_main && { echo "origin's main is already at ${commit:0:12}"; return 0; }
@@ -290,7 +414,7 @@ for i in "${!names[@]}"; do
echo "publish: ${labels[$i]} failed."
if ((i > 0)); then printf ' published: %s\n' "${labels[@]:0:i}"; fi
printf ' not published: %s\n' "${labels[@]:i}"
echo "Fix what failed, then run scripts/publish.sh again, which skips what's done, or finish by hand (docs/content/docs/contributing/maintaining.md)."
echo "Fix what failed, then run scripts/publish.sh --local again, which skips what's done, or finish by hand (docs/content/docs/contributing/maintaining.md)."
} >&2
exit 1
fi
+51 -6
View File
@@ -31,7 +31,17 @@
# scripts/release.sh --commit COMMIT
# the same, from COMMIT
# scripts/release.sh --check only the tag's checks and what the build needs, then prints the tag's commit
# (scripts/publish.sh runs it first); nothing is built
# (scripts/publish.sh --local runs it first); nothing is built
# scripts/release.sh --check-tag
# only the tag's checks, the release keys' among them, then prints the tag's
# commit, needing no container runtime (scripts/publish.sh runs it first)
# scripts/release.sh --sign-legacy DIR
# while releases bridge from the old release key: VERSION's SHA256SUMS in
# DIR, whose SHA256SUMS.ci.minisig and SHA256SUMS.cosign.minisig have to
# check out with packaging/keys and the trusted comment devvm-release
# <version>, signed with the old key (DEVVM_MINISIGN_KEY, which asks for its
# password) as DIR/SHA256SUMS.minisig, devvm <version>, and checked with
# packaging/minisign.pub (scripts/publish.sh --sign-legacy runs it)
# scripts/release.sh --formula-from DIR
# only the formulas, for VERSION's published release, from its SHA256SUMS
# and SHA256SUMS.minisig downloaded into DIR, checked against minisign.pub
@@ -299,10 +309,37 @@ ci_sign() {
echo "==> $sig, signed as devvm-release $v"
}
# sign_legacy DIR: VERSION's SHA256SUMS in DIR, which CI and the co-signer signed, signed with the old
# release key for devvm 0.1 and 0.2, while releases bridge from it (--sign-legacy). Both signatures
# are checked with this checkout's packaging/keys first, so the old key signs only what two builders
# built and signed.
sign_legacy() {
local dir=$1 key=${DEVVM_MINISIGN_KEY:-$HOME/.minisign/devvm.key} r f out got
version_file
[[ -f $dir/SHA256SUMS ]] || die "--sign-legacy needs $dir/SHA256SUMS"
[[ ! -e $dir/SHA256SUMS.minisig ]] || die "$dir already has SHA256SUMS.minisig"
command -v minisign >/dev/null || die "needs minisign to sign SHA256SUMS (mise exec -- scripts/release.sh)"
[[ -f $key ]] || die "no release key at $key (DEVVM_MINISIGN_KEY)"
[[ -f $root/packaging/keys/release-ci.pub && -f $root/packaging/keys/release-cosign.pub ]] ||
die "--sign-legacy checks CI's and the co-signer's signatures with the release keys in packaging/keys, which has none: make them first (docs/content/docs/contributing/github-setup.md, step 1)"
for r in ci cosign; do
f=$dir/SHA256SUMS.$r.minisig
[[ -f $f ]] || die "--sign-legacy needs $f"
out=$(minisign -V -p "$root/packaging/keys/release-$r.pub" -m "$dir/SHA256SUMS" -x "$f" 2>/dev/null) ||
die "$f doesn't verify with packaging/keys/release-$r.pub"
got=$(sed -n 's/^Trusted comment: //p' <<<"$out")
[[ $got == "devvm-release $v" ]] || die "$f is signed as '$got', not 'devvm-release $v'"
done
minisign -Sm "$dir/SHA256SUMS" -s "$key" -x "$dir/SHA256SUMS.minisig" -t "devvm $v" ||
{ rm -f "$dir/SHA256SUMS.minisig"; die "couldn't sign $dir/SHA256SUMS"; }
minisign -Vm "$dir/SHA256SUMS" -x "$dir/SHA256SUMS.minisig" -p "$root/packaging/minisign.pub" >/dev/null ||
{ rm -f "$dir/SHA256SUMS.minisig"; die "$dir/SHA256SUMS.minisig doesn't verify with packaging/minisign.pub"; }
}
# What's built: the tag ref, or a snapshot of the commit ref (--head, --commit), which takes its
# version from the commit's VERSION. A release is signed, --tag's build never is, and a snapshot only
# with a test key.
check=false snapshot=false unsigned=false
check=false tagonly=false snapshot=false unsigned=false
case ${1:-} in
--head) snapshot=true ref=HEAD ;;
--commit)
@@ -339,8 +376,13 @@ case ${1:-} in
[[ $# == 3 ]] || die "--ci-sign needs a tag and a folder: --ci-sign v<version> DIR"
ci_sign "$2" "$3"
exit 0 ;;
--check-tag) check=true tagonly=true unsigned=true ;;
--sign-legacy)
[[ $# == 2 ]] || die "--sign-legacy needs one folder"
sign_legacy "$2"
exit 0 ;;
"") ;;
*) die "unknown argument '$1' (--head, --commit COMMIT, --tag TAG, --check, --formula-from DIR, --ci TAG DIR, --ci-sign TAG DIR)" ;;
*) die "unknown argument '$1' (--head, --commit COMMIT, --tag TAG, --check, --check-tag, --formula-from DIR, --ci TAG DIR, --ci-sign TAG DIR, --sign-legacy DIR)" ;;
esac
if [[ -z ${ref:-} ]]; then version_file; ref=v$v; fi
@@ -424,6 +466,7 @@ if ! $snapshot; then
[[ $line == "release_${r}_key=$k" ]] || die "$ref's install.sh has ${line:-no release_${r}_key=}, not $f's key"
done
fi
if $tagonly; then echo "$commit"; exit 0; fi
# The container image is the built commit's, as its build is (the header says why), pinned by its
# digest. A commit from before reproducible builds names none, and builds with its own release.sh.
image=$(git show "$commit:scripts/release.sh" 2>/dev/null | sed -n 's/^release_image=//p') || true
@@ -691,8 +734,10 @@ echo "==> ${DEVVM_RELEASE_DIST:-dist}/ for devvm $v (from $ref):"
(cd "$out" && ls -l devvm-*.tar.gz SHA256SUMS* install.sh devvm*.rb 2>/dev/null) || true
if $unsigned; then echo "(not signed: --tag builds the release without its signature)"
elif ! $sign; then echo "(not signed: a test build without DEVVM_MINISIGN_KEY)"; fi
if [[ $v == *-* ]]; then
echo "scripts/publish.sh publishes them: the archives, SHA256SUMS, SHA256SUMS.minisig and install.sh to the GitHub prerelease v$v, devvm-rc.rb to devvmhq/homebrew-tap's Formula/; the formula devvm keeps the last release."
# --tag's build, CI's among them, is the co-signer's to publish; the rest, publish.sh --local's.
if $unsigned; then :
elif [[ $v == *-* ]]; then
echo "scripts/publish.sh --local publishes them: the archives, SHA256SUMS, SHA256SUMS.minisig and install.sh to the GitHub prerelease v$v, devvm-rc.rb to devvmhq/homebrew-tap's Formula/; the formula devvm keeps the last release."
else
echo "scripts/publish.sh publishes them: the archives, SHA256SUMS, SHA256SUMS.minisig and install.sh to the GitHub release v$v, devvm.rb to devvmhq/homebrew-tap's Formula/, and devvm-rc.rb too when the tap's devvm-rc is older."
echo "scripts/publish.sh --local publishes them: the archives, SHA256SUMS, SHA256SUMS.minisig and install.sh to the GitHub release v$v, devvm.rb to devvmhq/homebrew-tap's Formula/, and devvm-rc.rb too when the tap's devvm-rc is older."
fi
+43 -29
View File
@@ -1,8 +1,10 @@
# scripts/publish.sh: the checks, --dry-run, the question, and each step,
# scripts/publish.sh --local, a release built, signed and published from
# this machine: the checks, --dry-run, the question, and each step,
# against a throwaway repo whose origin is a local bare repo, a local bare
# tap, a gh that keeps its release in $WORK/gh, SSH-signed tags, a
# minisign key without a password and a goreleaser that writes a small
# dist/. Pushes and gh's calls go in $WORK/calls, in order.
# publish_tag.txtar has the release CI builds and the co-signer publishes.
# The system's commands, not the stubs (ssh-keygen's): git signs with
# ssh-keygen. minisign is linked in from PATH first.
[!exec:git] skip
@@ -19,25 +21,25 @@ env DEVVM_TAP_DIR=$WORK/tap
env DEVVM_MINISIGN_KEY=$WORK/keys/release.key
# --help: the script's header.
exec repo/scripts/publish.sh --help
stdout '^ scripts/publish.sh --dry-run '
! exec repo/scripts/publish.sh --publish
exec repo/scripts/publish.sh --local --help
stdout '^ scripts/publish.sh --local '
! exec repo/scripts/publish.sh --local --publish
stderr '^publish: unknown argument ''--publish''$'
# No tag yet: refused, by release.sh's check.
! exec repo/scripts/publish.sh --dry-run
! exec repo/scripts/publish.sh --local --dry-run
stderr '^release: no tag v1.2.3: tag the release first'
# A tag by a key git trusts but packaging/release-signer doesn't pin:
# refused.
exec bash tag.sh other
! exec repo/scripts/publish.sh --dry-run
! exec repo/scripts/publish.sh --local --dry-run
stderr '^release: tag v1.2.3 is signed by SHA256:\S+, not a key in packaging/release-signer$'
exec bash tag.sh good
# A working tree that isn't clean: refused.
exec touch repo/stray
! exec repo/scripts/publish.sh --dry-run
! exec repo/scripts/publish.sh --local --dry-run
stderr '^publish: the working tree isn''t clean'
rm repo/stray
@@ -45,19 +47,19 @@ rm repo/stray
# refused.
mkdir gh/release
exec touch gh/release/notes.txt
! exec repo/scripts/publish.sh --dry-run
! exec repo/scripts/publish.sh --local --dry-run
stderr '^publish: devvm v1.2.3 already has a GitHub release, without devvm-1.2.3-darwin-arm64.tar.gz'
rm gh/release
# gh not logged in: refused.
exec touch gh/no-auth
! exec repo/scripts/publish.sh --dry-run
! exec repo/scripts/publish.sh --local --dry-run
stderr '^publish: gh isn''t logged in to GitHub: run gh auth login$'
rm gh/no-auth
# No tap checkout: refused.
env DEVVM_TAP_DIR=$WORK/nowhere
! exec repo/scripts/publish.sh --dry-run
! exec repo/scripts/publish.sh --local --dry-run
stderr '^publish: no tap checkout at '
env DEVVM_TAP_DIR=$WORK/tap
@@ -67,7 +69,7 @@ env DEVVM_TAP_DIR=$WORK/tap
# --dry-run: everything it would publish, then nothing published: no
# push, no release, no tap commit.
rm calls
exec repo/scripts/publish.sh --dry-run
exec repo/scripts/publish.sh --local --dry-run
stdout '^Version: 1\.2\.3$'
stdout '^Tag: v1\.2\.3, signed, at commit [0-9a-f]{40}$'
stdout '^ devvm-1\.2\.3-linux-amd64\.tar\.gz +[0-9]+ bytes [0-9a-f]{64}$'
@@ -86,6 +88,18 @@ exec bash refs.sh
cmp stdout refs.before
exists repo/dist/SHA256SUMS.minisig
# The repo has no release keys, as devvm has none until they're made:
# the release is signed with the release key alone, as before them, and
# its install.sh trusts no release key.
exec minisign -Vm repo/dist/SHA256SUMS -p repo/packaging/minisign.pub
stdout 'Trusted comment: devvm 1\.2\.3'
! exists repo/dist/SHA256SUMS.ci.minisig
! exists repo/dist/SHA256SUMS.cosign.minisig
! exists repo/dist/SHA256SUMS.recovery.minisig
grep '^release_ci_key=$' repo/dist/install.sh
grep '^release_cosign_key=$' repo/dist/install.sh
grep '^release_recovery_key=$' repo/dist/install.sh
# The build's repository held the tag alone, though the repo has a stray
# one at the same commit.
grep '^release --clean --skip=publish tags=v1\.2\.3$' log
@@ -114,7 +128,7 @@ stderr '^release: --tag needs a release''s tag, v<version>, not ''1\.2\.3''$'
# Answering n: nothing published.
rm calls
ttyin -stdin no.txt
! exec repo/scripts/publish.sh
! exec repo/scripts/publish.sh --local
ttyout 'Publish devvm 1\.2\.3\? \[y/N\] '
stderr '^publish: nothing published$'
cmp calls calls.view
@@ -126,7 +140,7 @@ cmp stdout refs.before
rm calls
exec touch gh/fail-create
ttyin -stdin yes.txt
! exec repo/scripts/publish.sh
! exec repo/scripts/publish.sh --local
stderr '^publish: the GitHub release v1\.2\.3 failed\.$'
stderr '^ published: main on origin$'
stderr '^ published: the tag v1\.2\.3 on origin$'
@@ -139,7 +153,7 @@ stderr '^ not published: the tap''s Formula/devvm\.rb and Formula/devvm-rc\.rb$
rm gh/fail-create
exec touch gh/fail-edit
ttyin -stdin yes.txt
! exec repo/scripts/publish.sh
! exec repo/scripts/publish.sh --local
stdout '^origin''s main is already at [0-9a-f]{12}$'
stdout '^origin already has v1\.2\.3$'
stderr '^ not published: the GitHub release v1\.2\.3$'
@@ -150,7 +164,7 @@ exists gh/release/SHA256SUMS.minisig
# the formulas to the tap, devvm's and devvm-rc's, and pushes it.
rm gh/fail-edit
ttyin -stdin yes.txt
exec repo/scripts/publish.sh
exec repo/scripts/publish.sh --local
stdout '^ 3\. the GitHub release v1\.2\.3: to do, the draft''s files replaced$'
stdout '^==> devvm 1\.2\.3 is published$'
stdout '^Check it with Homebrew, brew update && brew upgrade devvm \(or brew trust --formula devvmhq/tap/devvm, then brew install devvmhq/tap/devvm\), or the install script:$'
@@ -169,7 +183,7 @@ stdout '^devvm 1\.2\.3$'
# And once more: everything's done, so it asks nothing.
rm calls
exec repo/scripts/publish.sh
exec repo/scripts/publish.sh --local
stdout '^devvm 1\.2\.3 is already published: nothing to do\.$'
stdout '^Formula/devvm-rc\.rb:\n \(already this release''s\)$'
grep '^gh release download v1\.2\.3 ' calls
@@ -183,10 +197,10 @@ rm gh/release
rm gh/notes
rm calls
env DEVVM_TAP_DIR=$WORK/nowhere
! exec repo/scripts/publish.sh --dry-run
! exec repo/scripts/publish.sh --local --dry-run
stderr '^publish: no tap checkout at '
env DEVVM_TAP_DIR=$WORK/tap
exec repo/scripts/publish.sh --dry-run
exec repo/scripts/publish.sh --local --dry-run
stdout '^Version: 1\.3\.0-rc\.1, a prerelease$'
stdout '^Formula/devvm\.rb: stays on the last release, as this is a prerelease\.$'
stdout '^Formula/devvm-rc\.rb:$'
@@ -199,7 +213,7 @@ stdout '^ - \*\*New:\*\* another thing\.$'
! exists repo/dist/devvm.rb
rm calls
ttyin -stdin yes.txt
exec repo/scripts/publish.sh
exec repo/scripts/publish.sh --local
stdout '^==> devvm 1\.3\.0-rc\.1 is published$'
stdout '^Check it with Homebrew, brew update && brew upgrade devvm-rc \(or brew trust --formula devvmhq/tap/devvm-rc, then brew install devvmhq/tap/devvm-rc\), or the install script:$'
cmp calls calls.pre
@@ -214,13 +228,13 @@ grep 'download/v1\.2\.3/' tap/Formula/devvm.rb
# Run again: everything's done.
rm calls
exec repo/scripts/publish.sh
exec repo/scripts/publish.sh --local
stdout '^devvm 1\.3\.0-rc\.1 is already published: nothing to do\.$'
! grep 'push|create|edit' calls
# A published prerelease that GitHub doesn't mark as one: refused.
rm gh/prerelease
! exec repo/scripts/publish.sh --dry-run
! exec repo/scripts/publish.sh --local --dry-run
stderr '^publish: devvm v1\.3\.0-rc\.1 is a prerelease, but its GitHub release isn''t marked as one'
# A release older than devvm-rc's prerelease, 1.2.4: devvm moves to it,
@@ -228,13 +242,13 @@ stderr '^publish: devvm v1\.3\.0-rc\.1 is a prerelease, but its GitHub release i
exec bash version.sh 1.2.4 'A fix.' 'a fix'
rm gh/release
rm gh/notes
exec repo/scripts/publish.sh --dry-run
exec repo/scripts/publish.sh --local --dry-run
stdout '^Formula/devvm\.rb:$'
stdout '^Formula/devvm-rc\.rb: stays at 1\.3\.0-rc\.1, which is newer than 1\.2\.4\.$'
stdout '^ 4\. the tap''s commit, devvm 1\.2\.4, and git push: to do$'
rm calls
ttyin -stdin yes.txt
exec repo/scripts/publish.sh
exec repo/scripts/publish.sh --local
stdout '^==> the tap''s Formula/devvm\.rb$'
exec git --git-dir=tap.git show --name-only --format= main
stdout '^Formula/devvm\.rb\n\z'
@@ -245,12 +259,12 @@ grep 'download/v1\.3\.0-rc\.1/' tap/Formula/devvm-rc.rb
exec bash version.sh 1.2.5-rc.1 'An older candidate.' 'an older thing'
rm gh/release
rm gh/notes
exec repo/scripts/publish.sh --dry-run
exec repo/scripts/publish.sh --local --dry-run
stdout '^Formula/devvm-rc\.rb: stays at 1\.3\.0-rc\.1, which is newer than 1\.2\.5-rc\.1\.$'
stdout '^ 4\. the tap: nothing to change$'
rm calls
ttyin -stdin yes.txt
exec repo/scripts/publish.sh
exec repo/scripts/publish.sh --local
stdout '^Check it with the install script, or devvm upgrade --to 1\.2\.5-rc\.1:$'
! grep 'push tap' calls
@@ -260,12 +274,12 @@ exec bash version.sh 1.3.0 'The release.' 'the release'
rm gh/release
rm gh/notes
rm gh/prerelease
exec repo/scripts/publish.sh --dry-run
exec repo/scripts/publish.sh --local --dry-run
stdout '^Formula/devvm-rc\.rb, which moves from 1\.3\.0-rc\.1 to this release too:$'
stdout '^\+ url "https://github.com/devvmhq/devvm/releases/download/v1\.3\.0/devvm-1\.3\.0-darwin-arm64\.tar\.gz"$'
rm calls
ttyin -stdin yes.txt
exec repo/scripts/publish.sh
exec repo/scripts/publish.sh --local
exec git --git-dir=tap.git log -1 --format=%s main
stdout '^devvm 1\.3\.0$'
exec git --git-dir=tap.git show --name-only --format= main
@@ -273,7 +287,7 @@ cmp stdout both.changed
cmp tap/Formula/devvm.rb repo/dist/devvm.rb
cmp tap/Formula/devvm-rc.rb repo/dist/devvm-rc.rb
rm calls
exec repo/scripts/publish.sh
exec repo/scripts/publish.sh --local
stdout '^devvm 1\.3\.0 is already published: nothing to do\.$'
! grep 'push|create|edit' calls
@@ -310,7 +324,7 @@ cp "$DEVVM_REPO/packaging/homebrew/devvm.rb" repo/packaging/homebrew/
echo 1.2.3 > repo/VERSION
printf 'module example.com/x\n\ngo 1.22\n' > repo/go.mod
echo dist/ > repo/.gitignore
printf '#!/bin/sh\nrelease_version=""\nminisign_key=""\n' > repo/install.sh
printf '#!/bin/sh\nrelease_version=""\nminisign_key=""\nrelease_ci_key=\nrelease_cosign_key=\nrelease_recovery_key=\n' > repo/install.sh
bash tools.sh > repo/mise.lock
printf '# Changelog\n\n## 1.2.3\n\nReleased today.\n\n- **New:** a thing.\n\n## 1.2.2\n\nOlder.\n' > repo/CHANGELOG.md
for n in good other; do ssh-keygen -q -t ed25519 -N '' -C "$n" -f "keys/$n"; done
+313
View File
@@ -0,0 +1,313 @@
# scripts/publish.sh without --local: the maintainer's part of a release
# that CI builds and the co-signer publishes, the tag's checks, then main
# and the tag pushed to origin, which starts CI's Release workflow; and
# --sign-legacy, the old release key's signature on the co-signer's draft
# while releases bridge from that key. A throwaway repo whose origin is a
# local bare repo, SSH-signed tags, minisign keys without a password, and
# a gh that keeps one release in $WORK/gh. Pushes and gh's calls go in
# $WORK/calls, in order.
# The system's commands, not the stubs (ssh-keygen's): git signs with
# ssh-keygen. minisign is linked in from PATH first.
[!exec:git] skip
[!exec:minisign] skip
exec bash -c 'ln -s "$(command -v minisign)" bin/minisign'
env GIT_CONFIG_NOSYSTEM=1
env PATH=$WORK/bin:/usr/bin:/bin
chmod 755 bin/gh
exec bash repo.sh
env DEVVM_MINISIGN_KEY=$WORK/keys/release.key
# --help: the script's header, with each mode.
exec repo/scripts/publish.sh --help
stdout '^ scripts/publish.sh --sign-legacy$'
stdout '^ scripts/publish.sh --local '
! exec repo/scripts/publish.sh --local --sign-legacy
stderr '^publish: --local and --sign-legacy are two modes: give one$'
# No tag yet: refused, by release.sh's check, which needs no container
# runtime, as nothing is built here.
! exec repo/scripts/publish.sh --dry-run
stderr '^release: no tag v1\.2\.3: tag the release first'
# A tag by a key git trusts but packaging/release-signer doesn't pin:
# refused.
exec bash tag.sh other
! exec repo/scripts/publish.sh --dry-run
stderr '^release: tag v1\.2\.3 is signed by SHA256:\S+, not a key in packaging/release-signer$'
exec bash tag.sh good
# A working tree that isn't clean: refused.
exec touch repo/stray
! exec repo/scripts/publish.sh --dry-run
stderr '^publish: the working tree isn''t clean'
rm repo/stray
# A tag whose commit has no release keys: CI's workflow would refuse it.
exec bash keys.sh none
! exec repo/scripts/publish.sh --dry-run
stderr '^publish: v1\.2\.3''s commit has no release keys in packaging/keys, so CI''s Release workflow refuses it: make them first \(docs/content/docs/contributing/github-setup\.md, step 1\), or publish it from this machine with --local$'
exec bash keys.sh real
# No changelog entry for the version: refused, as the co-signer takes the
# release's notes from it.
exec bash changelog.sh 1.2.2
! exec repo/scripts/publish.sh --dry-run
stderr '^publish: CHANGELOG\.md has no entry ## 1\.2\.3: nothing pushed$'
exec bash changelog.sh 1.2.3
# A tag that isn't main's HEAD: refused.
exec git -C repo commit -q --allow-empty -m after
! exec repo/scripts/publish.sh --dry-run
stderr '^publish: tag v1\.2\.3 is at [0-9a-f]{12}, not main''s HEAD \([0-9a-f]{12}\): tag main''s HEAD$'
exec bash tag.sh good
# --dry-run: what it pushes and what comes next, then nothing pushed.
rm calls
exec repo/scripts/publish.sh --dry-run
stdout '^Version: 1\.2\.3$'
stdout '^Tag: v1\.2\.3, signed, at commit [0-9a-f]{40}$'
stdout '^ 1\. git push origin main: to do$'
stdout '^ 2\. git push origin v1\.2\.3: to do$'
stdout '^--dry-run: nothing pushed\.$'
! exists calls
exec bash refs.sh
cmp stdout refs.before
# Answering n: nothing pushed.
ttyin -stdin no.txt
! exec repo/scripts/publish.sh
ttyout 'Push main and v1\.2\.3 to origin\? \[y/N\] '
stderr '^publish: nothing pushed$'
! exists calls
# Answering y: main, then the tag, and what comes next. It builds and
# publishes nothing itself, and calls no gh.
ttyin -stdin yes.txt
exec repo/scripts/publish.sh
stdout '^==> v1\.2\.3 is on origin\. What comes next:$'
stdout '^ 1\. Approve the Release workflow''s run for v1\.2\.3 in its release environment, at https://github\.com/devvmhq/devvm/actions/workflows/release\.yml\.$'
stdout 'scripts/publish\.sh --sign-legacy'
cmp calls calls.push
exec bash refs.sh
cmp stdout refs.after
! exists repo/dist
# Again: nothing to push, and what comes next.
rm calls
exec repo/scripts/publish.sh
stdout '^v1\.2\.3 and main are already on origin: nothing to push\.$'
stdout '^ 1\. Approve the Release workflow'
! exists calls
# origin with another tag of that name: refused.
exec bash -c 'git --git-dir=origin.git tag -f v1.2.3 "$(git --git-dir=origin.git rev-parse main~1)"'
! exec repo/scripts/publish.sh --dry-run
stderr '^publish: origin has another tag v1\.2\.3: this one is [0-9a-f]{40}, origin''s [0-9a-f]{40}$'
exec bash -c 'git -C repo push -q -f origin refs/tags/v1.2.3'
rm calls
# --sign-legacy: gh not logged in, or no draft yet: refused.
exec touch gh/no-auth
! exec repo/scripts/publish.sh --sign-legacy
stderr '^publish: gh isn''t logged in to GitHub: run gh auth login$'
rm gh/no-auth
! exec repo/scripts/publish.sh --sign-legacy
stderr '^publish: devvm v1\.2\.3 has no draft release yet: the co-signer makes it once CI''s build and its own match$'
# A draft without the co-signer's signature: refused, until it's there.
exec bash draft.sh
rm gh/release/SHA256SUMS.cosign.minisig
! exec repo/scripts/publish.sh --sign-legacy
stderr '^publish: devvm v1\.2\.3''s draft has no SHA256SUMS\.cosign\.minisig yet: the co-signer uploads it with its signature, so wait for its next run$'
# Signatures that don't check out: another key's for the co-signer, or
# CI's for another version. Nothing is signed or uploaded.
exec bash draft.sh recovery
! exec repo/scripts/publish.sh --sign-legacy
stderr '^release: \S+/SHA256SUMS\.cosign\.minisig doesn''t verify with packaging/keys/release-cosign\.pub$'
stderr '^publish: nothing signed or uploaded$'
exec bash draft.sh cosign 1.2.4
! exec repo/scripts/publish.sh --sign-legacy
stderr '^release: \S+/SHA256SUMS\.ci\.minisig is signed as ''devvm-release 1\.2\.4'', not ''devvm-release 1\.2\.3''$'
! grep upload calls
# A checkout without the release keys can't check those signatures, so
# the old key signs nothing.
exec bash draft.sh
exec mv repo/packaging/keys keys.aside
! exec repo/scripts/publish.sh --sign-legacy
stderr '^release: --sign-legacy checks CI''s and the co-signer''s signatures with the release keys in packaging/keys, which has none: make them first \(docs/content/docs/contributing/github-setup\.md, step 1\)$'
stderr '^publish: nothing signed or uploaded$'
exec mv keys.aside repo/packaging/keys
! grep upload calls
# --dry-run: both signatures check out, and the old key signs, but
# nothing is uploaded.
exec bash draft.sh
rm calls
exec repo/scripts/publish.sh --sign-legacy --dry-run
stdout '^==> devvm 1\.2\.3''s SHA256SUMS, which CI and the co-signer signed, signed with the old release key:$'
stdout '^--dry-run: nothing uploaded\.$'
! grep upload calls
! exists gh/release/SHA256SUMS.minisig
# Answering y: SHA256SUMS.minisig, signed as devvm 1.2.3, on the draft,
# which stays a draft for the co-signer to publish.
ttyin -stdin yes.txt
exec repo/scripts/publish.sh --sign-legacy
ttyout 'Upload SHA256SUMS\.minisig to devvm 1\.2\.3''s draft release\? \[y/N\] '
stdout '^==> uploaded: the co-signer publishes devvm 1\.2\.3 at its next run, within the hour\.$'
grep '^gh release upload v1\.2\.3 --repo devvmhq/devvm SHA256SUMS\.minisig$' calls
exec minisign -V -p repo/packaging/minisign.pub -m gh/release/SHA256SUMS -x gh/release/SHA256SUMS.minisig
stdout '^Trusted comment: devvm 1\.2\.3$'
exists gh/draft
# Again: it's there, so there's nothing to do; and a published release
# is refused.
exec repo/scripts/publish.sh --sign-legacy
stdout '^devvm v1\.2\.3''s draft already has SHA256SUMS\.minisig: nothing to do\.'
rm gh/draft
! exec repo/scripts/publish.sh --sign-legacy
stderr '^publish: devvm v1\.2\.3''s GitHub release is already published$'
-- no.txt --
n
-- yes.txt --
y
-- calls.push --
push origin.git refs/heads/main
push origin.git refs/tags/v1.2.3
-- refs.before --
r
-- refs.after --
after
v1.2.3
-- repo.sh --
# The repo (VERSION 1.2.3, a changelog, release.sh and publish.sh, the
# release keys and install.sh's lines, the old release key), its origin
# one commit behind, and two SSH keys git trusts (good, which
# packaging/release-signer pins, and other).
set -eu
mkdir -p repo/scripts repo/packaging/keys keys gh
cp "$DEVVM_REPO/scripts/release.sh" "$DEVVM_REPO/scripts/publish.sh" repo/scripts/
echo 1.2.3 > repo/VERSION
for n in good other; do ssh-keygen -q -t ed25519 -N '' -C "$n" -f "keys/$n"; done
{ printf 'e@e %s\n' "$(cat keys/good.pub)"; printf 'e@e %s\n' "$(cat keys/other.pub)"; } > keys/allowed
printf '# the release signer\n%s\n' "$(ssh-keygen -lf keys/good.pub | awk '{ print $2 }')" > repo/packaging/release-signer
minisign -G -W -p repo/packaging/minisign.pub -s keys/release.key >/dev/null
for r in ci cosign recovery; do minisign -G -W -p "keys/release-$r.pub" -s "keys/$r.key" >/dev/null; done
git config --global user.email e@e
git config --global user.name e
git config --global gpg.format ssh
git config --global gpg.ssh.allowedSignersFile "$PWD/keys/allowed"
git config --global init.defaultBranch main
git init -q --bare origin.git
printf '#!/bin/sh\nwhile read -r o n r; do echo "push %s $r" >> "$WORK/calls"; done\n' origin.git > origin.git/hooks/post-receive
chmod 755 origin.git/hooks/post-receive
lines=
for r in ci cosign recovery; do
cp "keys/release-$r.pub" repo/packaging/keys/
lines+="release_${r}_key=$(sed -n 2p "keys/release-$r.pub")"$'\n'
done
printf '#!/bin/sh\nrelease_version=""\nminisign_key=""\n%s' "$lines" > repo/install.sh
bash changelog.sh 1.2.3 nocommit
git init -q repo
git -C repo add -A
git -C repo commit -qm r
git -C repo remote add origin "$PWD/origin.git"
git -C repo push -q origin main
echo more > repo/more
git -C repo add more
git -C repo commit -qm 'release 1.2.3'
rm -f calls
-- keys.sh --
# The release keys in packaging/keys and install.sh's lines (real), or
# none, in a commit release 1.2.3 with its changelog entry, tagged v1.2.3
# with the good key.
set -eu
rm -rf repo/packaging/keys
lines=
if [[ $1 == real ]]; then
mkdir -p repo/packaging/keys
for r in ci cosign recovery; do
cp "keys/release-$r.pub" repo/packaging/keys/
lines+="release_${r}_key=$(sed -n 2p "keys/release-$r.pub")"$'\n'
done
fi
printf '#!/bin/sh\nrelease_version=""\nminisign_key=""\n%s' "$lines" > repo/install.sh
bash changelog.sh 1.2.3 nocommit
git -C repo add -A
git -C repo commit -qm 'release 1.2.3'
bash tag.sh good
-- changelog.sh --
# CHANGELOG.md with an entry ## $1, committed and tagged v1.2.3 with the
# good key, unless $2 is nocommit.
set -eu
printf '# Changelog\n\n## %s\n\nReleased today.\n\n- **New:** a thing.\n' "$1" > repo/CHANGELOG.md
[[ ${2:-} == nocommit ]] && exit 0
git -C repo commit -qam "release 1.2.3"
bash tag.sh good
-- tag.sh --
# Tag v1.2.3 at HEAD (again), signed with key $1.
set -eu
git -C repo tag -d v1.2.3 >/dev/null 2>&1 || true
git -C repo -c user.signingkey="$PWD/keys/$1" tag -s v1.2.3 -m v1.2.3
-- draft.sh --
# The co-signer's draft release v1.2.3 in gh/: SHA256SUMS, CI's signature
# and the co-signer's, signed with key $1 (cosign by default) as the
# co-signer's, and both for version $2 (1.2.3 by default).
set -eu
rm -rf gh/release
mkdir -p gh/release
touch gh/draft
printf '%064d devvm-1.2.3.tar.gz\n' 1 > gh/release/SHA256SUMS
v=${2:-1.2.3}
minisign -S -s keys/ci.key -m gh/release/SHA256SUMS -x gh/release/SHA256SUMS.ci.minisig -t "devvm-release $v" >/dev/null
minisign -S -s "keys/${1:-cosign}.key" -m gh/release/SHA256SUMS -x gh/release/SHA256SUMS.cosign.minisig -t "devvm-release $v" >/dev/null
-- refs.sh --
# What origin holds: main's commit message and its tags.
git --git-dir=origin.git log -1 --format=%s main
git --git-dir=origin.git tag -l
-- bin/gh --
#!/bin/bash
# A gh that logs each call to $WORK/calls (paths as their base names) and
# keeps one release in $WORK/gh: release/ its files, draft while it's a
# draft. gh/no-auth fails gh auth status.
set -eu
s=$WORK/gh
line=gh
for a in "$@"; do
[[ $a != /* ]] || a=${a##*/}
line+=" $a"
done
echo "$line" >> "$WORK/calls"
case "$1 $2" in
"auth status") [[ ! -e $s/no-auth ]] ;;
"release view")
[[ -d $s/release ]] || { echo "release not found" >&2; exit 1; }
if [[ -e $s/draft ]]; then echo true; else echo false; fi
ls "$s/release" ;;
"release download")
dir= pats=()
while (($#)); do
case $1 in
--dir) dir=$2; shift ;;
--pattern) pats+=("$2"); shift ;;
esac
shift
done
mkdir -p "$dir"
for p in "${pats[@]}"; do cp "$s/release/$p" "$dir/"; done ;;
"release upload")
[[ -d $s/release ]] || { echo "release not found" >&2; exit 1; }
shift 3
while (($#)); do
case $1 in
--repo) shift 2 ;;
--*) shift ;;
*) [[ ! -e $s/release/${1##*/} ]] || { echo "asset under the same name already exists: ${1##*/}" >&2; exit 1; }
cp "$1" "$s/release/"; shift ;;
esac
done ;;
*) echo "gh: no fake for $*" >&2; exit 1 ;;
esac