Files
w3cjandClaude Opus 5.5 bc185ec80e fix(release): every file release.sh writes is 0755 or 0644, whatever the umask
minisign writes its signatures with the process umask, so on a host
whose umask is 0002, as Ubuntu's is, dist/SHA256SUMS.minisig came out
0664, and --ci-sign's SHA256SUMS.ci.minisig, --sign-legacy's signature,
--formula-from's formulas and --ci's folder for the co-signer were
group-writable too. release.sh now sets umask 022 once at its top, for
the host and the container alike, in place of the two copies in build
and modules.

release_head.txtar's modes check builds under umask 0002, checks the
signature is 0644, and labels the catch-all lines so a stray mode can't
pass as an expected one; release_ci.txtar's --ci-sign runs under umask
0002 and checks its signature is 0644. Both failed before the fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-01 07:35:02 -07:00

256 lines
11 KiB
Plaintext

# scripts/release.sh --ci and --ci-sign, CI's release workflow's build and
# signature: the tag checked against DEVVM_RELEASE_SIGNERS alone, --tag's
# build, the folder the co-signer gets, and SHA256SUMS signed with CI's
# release key read from standard input. A throwaway repo whose origin is
# a local bare repo, SSH-signed tags, minisign keys without a password
# and a goreleaser and podman that write a small build.
# 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
env DEVVM_RELEASE_TEST_FILE_URLS=$WORK/tools
chmod 755 bin/goreleaser
chmod 755 bin/podman
exec bash repo.sh
env DEVVM_RELEASE_SIGNERS=$WORK/keys/signers
cd repo
# The signers come from DEVVM_RELEASE_SIGNERS alone, never the tag's or
# git's config: a tag signed by a key git trusts, but which isn't there,
# is refused.
env DEVVM_RELEASE_SIGNERS=
! exec scripts/release.sh --ci v1.2.3 $WORK/out
stderr '^release: --ci needs DEVVM_RELEASE_SIGNERS, an allowed signers file of the keys that sign release tags$'
env DEVVM_RELEASE_SIGNERS=$WORK/keys/signers
exec bash ../tag.sh other v1.2.3
! exec scripts/release.sh --ci v1.2.3 $WORK/out
stderr '^release: tag v1\.2\.3 isn''t signed by a key in DEVVM_RELEASE_SIGNERS$'
# A tag that isn't a release's, a lightweight tag, a tag object of another
# tag, and a commit that isn't on main: refused.
! exec scripts/release.sh --ci 1.2.3 $WORK/out
stderr '^release: --ci needs a release''s tag, v<version>, not ''1\.2\.3''$'
exec git tag -f v1.2.3
! exec scripts/release.sh --ci v1.2.3 $WORK/out
stderr '^release: no annotated tag v1\.2\.3 \(git tag -s v1\.2\.3\)$'
exec bash ../tag.sh good v1.2.3
exec bash -c 'git update-ref refs/tags/v1.2.4 "$(git rev-parse refs/tags/v1.2.3)"'
! exec scripts/release.sh --ci v1.2.4 $WORK/out
stderr '^release: the tag v1\.2\.4 is the tag object of v1\.2\.3, not its own$'
exec git tag -d v1.2.4
exec git checkout -q -b side
exec git commit -q --allow-empty -m side
exec bash ../tag.sh good v1.2.5
! exec scripts/release.sh --ci v1.2.5 $WORK/out
stderr '^release: tag v1\.2\.5''s commit [0-9a-f]{12} isn''t on main \(refs/remotes/origin/main\)$'
exec git checkout -q main
# A folder that's there already, or a relative one: refused.
! exec scripts/release.sh --ci v1.2.3 out
stderr '^release: --ci''s folder isn''t an absolute path that doesn''t exist yet: ''out''$'
mkdir $WORK/there
! exec scripts/release.sh --ci v1.2.3 $WORK/there
stderr 'doesn''t exist yet: ''\S+/there''$'
! exists $WORK/log
# The build: the folder holds SHA256SUMS and exactly the files it lists,
# with their SHA-256s, and not the formulas, which the co-signer renders.
exec scripts/release.sh --ci v1.2.3 $WORK/out
stdout '^==> .*/out/ for the co-signer: SHA256SUMS and the 6 files it lists, from v1\.2\.3$'
exec bash -c 'cd $WORK/out && LC_ALL=C ls'
cmp stdout ../out.want
exec bash -c 'cd $WORK/out && { sha256sum -c SHA256SUMS 2>/dev/null || shasum -a 256 -c SHA256SUMS; }'
! exists dist
# --ci-sign: CI's release key on standard input, never a file, and only
# the one that the tag's packaging/keys/release-ci.pub checks.
! exec scripts/release.sh --ci-sign v1.2.3 $WORK/out
stderr '^release: --ci-sign read no key on its standard input: CI''s release key, an unencrypted minisign secret key$'
stdin ../keys/cosign.key
! exec scripts/release.sh --ci-sign v1.2.3 $WORK/out
stderr '^release: \S+/SHA256SUMS\.ci\.minisig doesn''t verify with v1\.2\.3''s packaging/keys/release-ci\.pub: the key on standard input isn''t CI''s release key$'
! exists $WORK/out/SHA256SUMS.ci.minisig
stdin ../keys/ci.key
exec bash -c 'umask 0002 && exec scripts/release.sh --ci-sign v1.2.3 $WORK/out'
stdout '^==> \S+/SHA256SUMS\.ci\.minisig, signed as devvm-release 1\.2\.3$'
exec find $WORK/out/SHA256SUMS.ci.minisig -perm 0644
stdout 'SHA256SUMS\.ci\.minisig$'
exec minisign -V -p packaging/keys/release-ci.pub -m $WORK/out/SHA256SUMS -x $WORK/out/SHA256SUMS.ci.minisig
stdout '^Trusted comment: devvm-release 1\.2\.3$'
stdin ../keys/ci.key
! exec scripts/release.sh --ci-sign v1.2.3 $WORK/out
stderr 'already has SHA256SUMS\.ci\.minisig$'
# A tag whose commit has no release keys is refused before anything is
# built, as its devvm couldn't check CI's and the co-signer's signatures.
exec bash ../nokeys.sh
rm $WORK/log
! exec scripts/release.sh --ci v1.2.3 $WORK/nokeys
stderr '^release: v1\.2\.3 has no release keys in packaging/keys, so its devvm can''t check CI''s and the co-signer''s signatures: make them first \(docs/content/docs/contributing/github-setup\.md, step 1\), or publish it with scripts/publish\.sh --local$'
! exists $WORK/log
! exists $WORK/nokeys
rm $WORK/out/SHA256SUMS.ci.minisig
stdin ../keys/ci.key
! exec scripts/release.sh --ci-sign v1.2.3 $WORK/out
stderr '^release: v1\.2\.3 has no packaging/keys/release-ci\.pub: make the release keys first \(docs/content/docs/contributing/github-setup\.md, step 1\)$'
! exists $WORK/out/SHA256SUMS.ci.minisig
exec git reset -q --hard HEAD~1
exec git push -q -f origin main
exec git fetch -q origin
exec bash ../tag.sh good v1.2.3
# A tag whose CI key is marked PLACEHOLDER is refused before anything is
# signed, even with the key that checks it.
exec bash ../placeholder.sh
stdin ../keys/ci.key
! exec scripts/release.sh --ci-sign v1.2.3 $WORK/out
stderr '^release: v1\.2\.3''s packaging/keys/release-ci\.pub is a placeholder key: make the real release keys first \(docs/content/docs/contributing/github-setup\.md, step 1\)$'
! exists $WORK/out/SHA256SUMS.ci.minisig
-- out.want --
SHA256SUMS
devvm-1.2.3-darwin-amd64.tar.gz
devvm-1.2.3-darwin-arm64.tar.gz
devvm-1.2.3-linux-amd64.tar.gz
devvm-1.2.3-linux-arm64.tar.gz
devvm-1.2.3.tar.gz
install.sh
-- repo.sh --
# The repo (VERSION 1.2.3, release.sh, the formula, the release keys and
# install.sh's lines), its origin, two SSH keys git trusts (good, which
# packaging/release-signer pins and keys/signers holds, and other), and
# the tag v1.2.3, signed with good, at main's HEAD.
set -eu
mkdir -p repo/scripts repo/packaging/homebrew repo/packaging/keys keys
cp "$DEVVM_REPO/scripts/release.sh" repo/scripts/
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
bash tools.sh > repo/mise.lock
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 'e@e %s\n' "$(cat keys/good.pub)" > keys/signers
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
lines=
for r in ci cosign recovery; do
minisign -G -W -p "repo/packaging/keys/release-$r.pub" -s "keys/$r.key" >/dev/null
lines+="release_${r}_key=$(sed -n 2p "repo/packaging/keys/release-$r.pub")"$'\n'
done
printf '#!/bin/sh\nrelease_version=""\nminisign_key=""\n%s' "$lines" > repo/install.sh
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
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
git -C repo fetch -q origin
(cd repo && bash ../tag.sh good v1.2.3)
-- tag.sh --
# Tag $2 at HEAD (again), signed with key $1.
set -eu
git tag -d "$2" >/dev/null 2>&1 || true
git -c user.signingkey="$WORK/keys/$1" tag -s "$2" -m "$2"
-- nokeys.sh --
# No release keys and no install.sh lines, in a commit on main, tagged
# v1.2.3.
set -eu
git rm -q -r packaging/keys
printf '#!/bin/sh\nrelease_version=""\nminisign_key=""\n' > install.sh
git add -A
git commit -qm 'no keys'
git push -q origin main
git fetch -q origin
bash ../tag.sh good v1.2.3
-- placeholder.sh --
# CI's release key marked PLACEHOLDER in its comment, in a commit on main,
# tagged v1.2.3.
set -eu
printf 'untrusted comment: PLACEHOLDER\n%s\n' "$(sed -n 2p packaging/keys/release-ci.pub)" > packaging/keys/release-ci.pub.new
mv packaging/keys/release-ci.pub.new packaging/keys/release-ci.pub
git add -A
git commit -qm placeholders
git push -q origin main
git fetch -q origin
bash ../tag.sh good v1.2.3
-- tools.sh --
# A mise.lock's go and goreleaser, for both Linux processors: tarballs of a
# go that does nothing and of bin/goreleaser, by file URL and SHA-256.
set -eu
mkdir -p tools/go/bin
printf '#!/bin/sh\n' > tools/go/bin/go
chmod 755 tools/go/bin/go
tar -czf tools/go.tar.gz -C tools go
tar -czf tools/goreleaser.tar.gz -C bin goreleaser
for t in go goreleaser; do
sum=$({ sha256sum "tools/$t.tar.gz" 2>/dev/null || shasum -a 256 "tools/$t.tar.gz"; } | cut -c1-64)
printf '[[tools.%s]]\nversion = "1.30.0"\n\n' "$t"
for p in linux-arm64 linux-x64; do
printf '[tools.%s."platforms.%s"]\nchecksum = "sha256:%s"\nurl = "file://%s"\n\n' "$t" "$p" "$sum" "$PWD/tools/$t.tar.gz"
done
done
-- bin/podman --
#!/bin/bash
# Rootless podman, here: --version and info say so, and run runs
# --entrypoint, then the command, with each -v's container folder replaced
# by its host folder, in -w's folder, with each -e's variable set.
set -eu
case $1 in
--version) echo 'podman version 5.6.0'; exit 0 ;;
info) echo true; exit 0 ;;
run) ;;
*) echo "podman: no fake for $*" >&2; exit 1 ;;
esac
shift
from=() to=() dir= entry=()
while [[ $1 == -* ]]; do
case $1 in
--rm) shift ;;
--platform | --user | --name | --security-opt | --cap-drop | --pids-limit | --memory | --network) shift 2 ;;
--entrypoint) entry=("$2"); shift 2 ;;
-v) IFS=: read -r h c _ <<<"$2"; from+=("$c"); to+=("$h"); shift 2 ;;
-w) dir=$2; shift 2 ;;
-e) export "${2?}"; shift 2 ;;
*) echo "podman: no fake for $1" >&2; exit 1 ;;
esac
done
shift
set -- ${entry[@]+"${entry[@]}"} "$@"
map() {
local a=$1 i
for i in "${!from[@]}"; do [[ $a != "${from[i]}"* ]] || a=${to[i]}${a#"${from[i]}"}; done
printf '%s' "$a"
}
args=()
for a in "$@"; do args+=("$(map "$a")"); done
cd "$(map "$dir")"
exec "${args[@]}"
-- bin/goreleaser --
#!/bin/bash
# Logs its call, and writes a dist/ like GoReleaser's, the same each time:
# each system's and processor's build, a script printing $DEVVM_VERSION,
# an archive for each (a line of text), the source tarball and SHA256SUMS.
set -eu
echo "$*" >> "$WORK/log"
rm -rf dist
mkdir dist
for os in darwin linux; do
for a in arm64 amd64; do
mkdir -p "dist/devvm_${os}_$a"
printf '#!/bin/sh\necho %s\n' "$DEVVM_VERSION" > "dist/devvm_${os}_$a/devvm"
chmod 755 "dist/devvm_${os}_$a/devvm"
echo "devvm $DEVVM_VERSION $os $a" > "dist/devvm-$DEVVM_VERSION-$os-$a.tar.gz"
done
done
git archive --prefix="devvm-$DEVVM_VERSION/" HEAD | gzip -n > "dist/devvm-$DEVVM_VERSION.tar.gz"
(cd dist && { sha256sum devvm-*.tar.gz 2>/dev/null || shasum -a 256 devvm-*.tar.gz; } > SHA256SUMS)