Compare commits

...
Author SHA1 Message Date
08bf6649df Merge pull request 'release: stage dist before signing, and sign via a named volume' (#188) 2026-10-21 02:59:22 +00:00
Hermes DevOps
46baf67a14
release: stage dist before signing, and sign via a named volume
The publish job has never completed. Two plumbing bugs, no crypto involved:

1. The sign step ran `docker run -v "${GITHUB_WORKSPACE}:/work"`.
   GITHUB_WORKSPACE is a path INSIDE the job container, but docker resolves a
   bind mount's source on the HOST, where that path does not exist — so /work
   arrived empty and the script was absent. Run 768 failed with
   "bash: .ci-tools/scripts/sign-release.sh: No such file or directory" (127).
   Rehearsed locally against the pinned image: the bind mount yields an empty
   /work, the same command with a named volume + docker cp signs and
   self-verifies all four assets. Use the build jobs' pattern.

2. Signing ran before the files it signs existed. The find+cp loop that fills
   dist/ lived in the publish step, after the signature step. Move it into its
   own "Stage both arch artifacts into dist" step before signing, and let
   publish only validate dist/.

Fail-closed design unchanged: no MINISIGN_SECRET_KEY stops before any upload,
signing still precedes publishing, and the tag cleanup step is untouched.
docs/RELEASING.md described the old publish job; it now matches the workflow.
2026-10-20 23:01:09 -04:00
2 changed files with 80 additions and 28 deletions

View file

@ -416,7 +416,11 @@ jobs:
# Pi runner, not docker-amd64: the amd64 dind runner is capacity=1 and # Pi runner, not docker-amd64: the amd64 dind runner is capacity=1 and
# android-release sat in front of run 116's publish for ~1h; the Pi # android-release sat in front of run 116's publish for ~1h; the Pi
# already created the tag over the public API (version job), so publish # already created the tag over the public API (version job), so publish
# uses that same path. This job only curls the Forgejo API — no docker CLI. # uses that same path. This job needs the docker CLI for one thing only —
# running scripts/sign-release.sh in the pinned builder image — and it uses
# a named volume + docker cp, never a bind mount of $GITHUB_WORKSPACE
# (that path exists only inside this container; docker resolves a -v source
# on the host and hands the container an empty /work — run 768).
# Fail-closed tag delete lives as a step here: a sibling cleanup job ran # Fail-closed tag delete lives as a step here: a sibling cleanup job ran
# after a successful publish (act treats needs.publish.result as unset, so # after a successful publish (act treats needs.publish.result as unset, so
# != success) and Early-terminated on run 135. Do not restore that job. # != success) and Early-terminated on run 135. Do not restore that job.
@ -446,49 +450,13 @@ jobs:
with: with:
path: artifacts path: artifacts
- name: Sign the release assets (minisign, fail closed) - name: Stage both arch artifacts into dist
if: needs.version.outputs.dry_run != 'true' && needs.aarch64.result == 'success' && needs.x86_64.result == 'success' if: needs.version.outputs.dry_run != 'true' && needs.aarch64.result == 'success' && needs.x86_64.result == 'success'
env:
MINISIGN_SECRET_KEY: ${{ secrets.MINISIGN_SECRET_KEY }}
RELEASE_TAG: ${{ needs.version.outputs.tag }}
run: |
set -euo pipefail
# Signing runs BEFORE publish on purpose. A run without the key stops
# here, so nothing unsigned ever reaches the release page: an unsigned
# release is indistinguishable from a signed one to anyone who is not
# checking, which makes it worse than no release at all.
if [ -z "${MINISIGN_SECRET_KEY:-}" ]; then
echo "MINISIGN_SECRET_KEY is not set — add it in Settings -> Actions -> Secrets." >&2
echo "See docs/VERIFY.md, \"Maintainer: the signing key\"." >&2
exit 1
fi
# minisign comes from the same pinned image the builds used, so our
# signature and the verifier's check are the same implementation.
docker run --rm \
-v "${GITHUB_WORKSPACE}:/work" \
-e MINISIGN_SECRET_KEY \
-e RELEASE_TAG \
-w /work \
"$RUST_IMAGE" \
bash -c 'apt-get update -qq && apt-get install -y -qq --no-install-recommends minisign >/dev/null \
&& bash .ci-tools/scripts/sign-release.sh \
dist/onionwire-aarch64-unknown-linux-gnu \
dist/onionwire-aarch64-unknown-linux-gnu.sha256 \
dist/onionwire-x86_64-unknown-linux-gnu \
dist/onionwire-x86_64-unknown-linux-gnu.sha256'
# The public key ships as an asset too, so a verifier can get it from
# the release; getting it from the repo instead is stronger, and
# docs/VERIFY.md says so.
cp .ci-tools/scripts/onionwire-signing.pub dist/onionwire-signing.pub
- name: Publish both binaries to one release
if: needs.version.outputs.dry_run != 'true' && needs.aarch64.result == 'success' && needs.x86_64.result == 'success'
env:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
TAG: ${{ needs.version.outputs.tag }}
run: | run: |
set -euo pipefail set -euo pipefail
# Everything the signer signs must already be in dist/ when the sign
# step runs. This loop used to live inside the publish step, i.e.
# AFTER the signature step, so signing ran against an empty dist/.
mkdir -p dist mkdir -p dist
find artifacts -type f -print find artifacts -type f -print
for target in aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu; do for target in aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu; do
@ -502,6 +470,82 @@ jobs:
cp "$src" "dist/$name" cp "$src" "dist/$name"
done done
done done
ls -l dist
- name: Sign the release assets (minisign, fail closed)
if: needs.version.outputs.dry_run != 'true' && needs.aarch64.result == 'success' && needs.x86_64.result == 'success'
env:
MINISIGN_SECRET_KEY: ${{ secrets.MINISIGN_SECRET_KEY }}
RELEASE_TAG: ${{ needs.version.outputs.tag }}
SIGN_VOLUME: onionwire-sign-${{ github.run_id }}
SIGN_CONTAINER: onionwire-sign-${{ github.run_id }}
run: |
set -euo pipefail
# Signing runs BEFORE publish on purpose. A run without the key stops
# here, so nothing unsigned ever reaches the release page: an unsigned
# release is indistinguishable from a signed one to anyone who is not
# checking, which makes it worse than no release at all.
if [ -z "${MINISIGN_SECRET_KEY:-}" ]; then
echo "MINISIGN_SECRET_KEY is not set — add it in Settings -> Actions -> Secrets." >&2
echo "See docs/VERIFY.md, \"Maintainer: the signing key\"." >&2
exit 1
fi
# NO `-v "${GITHUB_WORKSPACE}:/work"`: GITHUB_WORKSPACE is a path
# INSIDE this job container, but docker resolves a bind mount's source
# on the HOST, where it does not exist. Docker then creates an empty
# /work and the sign script is simply absent (run 768: "bash:
# .ci-tools/scripts/sign-release.sh: No such file or directory").
# Same pattern as the build jobs: named volume + docker cp in/out.
# minisign still comes from the same pinned image the builds used, so
# our signature and the verifier's check are the same implementation.
cleanup() {
docker rm -f "$SIGN_CONTAINER" >/dev/null 2>&1 || true
docker volume rm "$SIGN_VOLUME" >/dev/null 2>&1 || true
}
trap cleanup EXIT
docker volume create "$SIGN_VOLUME" >/dev/null
docker rm -f "$SIGN_CONTAINER" >/dev/null 2>&1 || true
docker create --name "$SIGN_CONTAINER" \
-e MINISIGN_SECRET_KEY \
-e RELEASE_TAG \
-v "$SIGN_VOLUME:/work" \
-w /work \
"$RUST_IMAGE" \
bash -c 'apt-get update -qq && apt-get install -y -qq --no-install-recommends minisign >/dev/null \
&& bash /work/scripts/sign-release.sh \
/work/dist/onionwire-aarch64-unknown-linux-gnu \
/work/dist/onionwire-aarch64-unknown-linux-gnu.sha256 \
/work/dist/onionwire-x86_64-unknown-linux-gnu \
/work/dist/onionwire-x86_64-unknown-linux-gnu.sha256'
docker cp .ci-tools/scripts "$SIGN_CONTAINER:/work/scripts"
docker cp dist/. "$SIGN_CONTAINER:/work/dist/"
docker start -a "$SIGN_CONTAINER"
docker cp "$SIGN_CONTAINER:/work/dist/." dist/
# Verify the signatures came back out before anything is published.
for f in \
dist/onionwire-aarch64-unknown-linux-gnu.minisig \
dist/onionwire-aarch64-unknown-linux-gnu.sha256.minisig \
dist/onionwire-x86_64-unknown-linux-gnu.minisig \
dist/onionwire-x86_64-unknown-linux-gnu.sha256.minisig
do
[ -s "$f" ] || { echo "signing produced no $f" >&2; exit 1; }
done
# The public key ships as an asset too, so a verifier can get it from
# the release; getting it from the repo instead is stronger, and
# docs/VERIFY.md says so.
cp .ci-tools/scripts/onionwire-signing.pub dist/onionwire-signing.pub
- name: Publish both binaries to one release
if: needs.version.outputs.dry_run != 'true' && needs.aarch64.result == 'success' && needs.x86_64.result == 'success'
env:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
REPO_API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
TAG: ${{ needs.version.outputs.tag }}
run: |
set -euo pipefail
# dist/ is staged and signed by the two steps above; this step only
# refuses to upload a hole in it.
find dist -type f -print
missing=0 missing=0
for f in \ for f in \
dist/onionwire-aarch64-unknown-linux-gnu \ dist/onionwire-aarch64-unknown-linux-gnu \

View file

@ -110,11 +110,19 @@ The `SOURCE_DATE_EPOCH` step reads the committer time of
`needs.version.outputs.sha`. It is deliberately not "now": a rebuild of this tag `needs.version.outputs.sha`. It is deliberately not "now": a rebuild of this tag
in six months has to hand the compiler the same epoch CI handed it. in six months has to hand the compiler the same epoch CI handed it.
`publish` job (Pi runner) downloads both artifacts, refuses any empty file, `publish` job (Pi runner) downloads both artifacts, stages them into `dist/`,
and calls `scripts/publish-release.sh` to create-or-update the release with all signs every asset with `scripts/sign-release.sh` inside the same digest-pinned
four Linux assets. If this job fails and the tag was created by *this* run, the builder image, and only then calls `scripts/publish-release.sh` to create-or-update
final step deletes the incomplete release and the tag. A failed `aarch64` or the release with all four Linux assets plus the committed public key. Signing runs
`x86_64` job always fails `publish`, so nothing is published half-built. in a container fed by a **named volume + `docker cp`**, not a bind mount of the
workspace: on this runner `$GITHUB_WORKSPACE` is a path inside the job container,
while docker resolves a `-v` source on the host — a bind mount therefore arrives
empty and the sign script is missing (run 768). Signing is also staged *after*
`dist/` is populated, so the files it signs exist; a run with no
`MINISIGN_SECRET_KEY` still stops before anything is uploaded. If this job fails
and the tag was created by *this* run, the final step deletes the incomplete
release and the tag. A failed `aarch64` or `x86_64` job always fails `publish`, so
nothing is published half-built.
## Android (APK + AAR) on the same tag ## Android (APK + AAR) on the same tag