release and the images: the agent only for cargo fetch, stopped after the builds, never on a runner that may print the key

release.yml checks the runner version before any step names the secret (same
gate as ci.yml), starts the ssh-agent only on the positive flag, and stops it in
an always() step right after the last build, so the artifact upload and the
release draft have neither the key nor the socket. The four Dockerfiles (linux,
windows, android, the gateway image) give the agent to `RUN cargo fetch --locked`
only; the build after it has no ssh mount and is offline (--offline, and
CARGO_NET_OFFLINE for the Android Gradle task, which starts cargo-ndk).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Sonnet 5.5 committed 2026-10-28 02:55:23 +03:00
1 parent cfde421af4
commit 91dce84b36
6 files changed
+119 -23

No files matched your search

+70 -12
View File
@@ -33,13 +33,56 @@ jobs:
# Remove only output owned by this workflow in its checkout.
rm -rf dist
# The workspace depends on the private VoelinProtocol repository over SSH
# (docs/ci.md, "VoelinProtocol access"). The Docker builds fetch it with
# this agent (`docker build --ssh default`): the key lives in the agent's
# memory, never on disk and never in an image layer. Stopped by the last
# step; the lifetime below ends the key anyway if the runner dies first.
- name: Start ssh-agent with the VoelinProtocol deploy key
# (docs/ci.md, "VoelinProtocol access"). The Docker builds fetch it with an
# ssh-agent (`docker build --ssh default`): the key lives in the agent's
# memory, never on disk and never in an image layer, and only the
# `cargo fetch` of each Dockerfile is given the agent (the build that
# follows is --offline and has no ssh mount, so the build scripts and
# procedural macros run without the key). The agent is stopped by the step
# right after the last build, whatever the builds did; the lifetime below
# ends the key anyway if the runner dies first.
#
# A runner prints the `env:` of a step in the job log when the step starts,
# and the runner "gitea-runner-docker" v0.6.1 printed a multi-line secret
# there in clear (2026-10-27; the keys were rotated the next day). It
# carries the same labels as the release runner, so `runs-on` cannot keep
# the job off it: this step decides, before any step names the secret, and
# writes the one positive flag that the agent step asks for. Without the
# flag the job stops here (no package can be built without voelin-identity).
# ci.yml has the same step, with the check of a pull request's head repository
# that a release (tags and manual runs only) does not need.
- name: Check that this runner may hold the VoelinProtocol deploy key
env:
PROTOCOL_DEPLOY_KEY: ${{ secrets.VOELIN_PROTOCOL_DEPLOY_KEY }}
# The oldest runner version known to mask a multi-line secret in the
# log. Lower it only after a canary secret has been shown masked on
# that runner (docs/ci.md, "VoelinProtocol access"). ci.yml has the
# same line.
MIN_MASKING_RUNNER_VERSION: 3.1.0
run: |
set -euo pipefail
version="${GITEA_ACTIONS_RUNNER_VERSION:-}"
name="${RUNNER_NAME:-an unnamed runner}"
if [[ "$version" =~ ^v?([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
oldest="$(printf '%s\n%s\n' "$MIN_MASKING_RUNNER_VERSION" "${BASH_REMATCH[1]}" | sort -V | head -n 1)"
if [[ "$oldest" == "$MIN_MASKING_RUNNER_VERSION" ]]; then
echo "Runner $name reports version $version, which masks secrets in the log (at least $MIN_MASKING_RUNNER_VERSION)."
echo "VOELIN_KEY_ALLOWED=yes" >> "$GITHUB_ENV"
exit 0
fi
fi
echo "::error::The VoelinProtocol deploy key is not given to this job: the runner ($name) reports version '${version:-none}', and only a runner of version $MIN_MASKING_RUNNER_VERSION or newer is known to keep the deploy key out of the job log (gitea-runner-docker v0.6.1 printed it in clear). Run the job again: it may be given another runner." >&2
echo "::error::The job stops here: no package can be built without the private VoelinProtocol repository (docs/ci.md, VoelinProtocol access)." >&2
exit 1
- name: Start ssh-agent with the VoelinProtocol deploy key
# Both lines below ask for the positive flag of the check above: on a
# runner that is not known to mask the secret (or whose expression context
# does not hold what an earlier step wrote to GITHUB_ENV) the step is not
# started and the expression is empty as well, in case a runner prints a
# header anyway. The key reaches the step through the environment only:
# never in the script text, never echoed, no `set -x`.
if: env.VOELIN_KEY_ALLOWED == 'yes'
env:
PROTOCOL_DEPLOY_KEY: ${{ env.VOELIN_KEY_ALLOWED == 'yes' && secrets.VOELIN_PROTOCOL_DEPLOY_KEY || '' }}
run: |
set -euo pipefail
if [[ -z "${PROTOCOL_DEPLOY_KEY//[[:space:]]/}" ]]; then
@@ -112,6 +155,27 @@ jobs:
DOCKER_BUILDKIT=1 docker build --ssh default -f crates/voelin-gateway/Dockerfile -t "tsgw:$version" -t tsgw:latest .
mkdir -p dist/gateway
docker save "tsgw:$version" tsgw:latest | gzip > dist/gateway/tsgw-image.tar.gz
# Right after the builds, the only steps that use the agent, and whatever
# they did (a failed build, a cancelled job): the steps after this one
# (the artifact upload, the release draft with its token) have neither the
# key nor the socket.
- name: Stop the ssh-agent
if: always()
run: |
if [[ -n "${VOELIN_AGENT_STARTED:-}" && -n "${SSH_AGENT_PID:-}" ]]; then
if ssh-agent -k > /dev/null; then
echo "The ssh-agent with the deploy key is stopped."
else
echo "::warning::ssh-agent -k failed; the agent ends by itself when its lifetime (nine hours) is over." >&2
fi
else
echo "No ssh-agent of this job is running."
fi
{
echo "SSH_AUTH_SOCK="
echo "SSH_AGENT_PID="
echo "VOELIN_AGENT_STARTED="
} >> "$GITHUB_ENV"
- name: Collect packages and checksums
run: |
set -euo pipefail
@@ -136,9 +200,3 @@ jobs:
# Gitea refuses secret names starting with GITEA_ or GITHUB_.
GITEA_RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: scripts/gitea-release.sh dist/release
- name: Stop the ssh-agent
if: always()
run: |
if [[ -n "${VOELIN_AGENT_STARTED:-}" && -n "${SSH_AGENT_PID:-}" ]]; then
ssh-agent -k > /dev/null || true
fi
+8 -3
View File
@@ -17,13 +17,18 @@ RUN apt-get update && apt-get install -y --no-install-recommends cmake git libas
# `docker build --ssh default` forwards (scripts/docker-build.sh passes it):
# the key stays in the agent and never reaches a layer. The host key is the
# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so
# every cargo command needs this, although this crate does not use
# voelin-identity.
# the first cargo command needs this, although this crate does not use
# voelin-identity: the `cargo fetch` below, the only step that is given the agent.
COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
COPY . .
# Only this step is given the agent, and it only fetches: no build script,
# procedural macro or test of the workspace runs in it. The build below has no
# ssh mount (so no agent socket and no key in reach of the code it compiles and
# runs) and is --offline, so it uses what this step fetched or fails.
RUN --mount=type=ssh,required=true \
cargo build --release --locked -p voelin-gateway && cp target/release/tsgw /tsgw && mkdir /data
cargo fetch --locked
RUN cargo build --release --locked --offline -p voelin-gateway && cp target/release/tsgw /tsgw && mkdir /data
FROM gcr.io/distroless/cc-debian12:nonroot
COPY --from=build /tsgw /usr/local/bin/tsgw
+15 -2
View File
@@ -90,13 +90,26 @@ WORKDIR /src
# `docker build --ssh default` forwards (scripts/docker-build.sh passes it):
# the key stays in the agent and never reaches a layer. The host key is the
# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so
# every cargo command needs this (Gradle's cargo-ndk inherits the agent and the
# variable below).
# the first cargo command needs this: the `cargo fetch` below, the only step
# that is given the agent.
COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
COPY . .
# Only this step is given the agent, and it only fetches (the packages of every
# target, so the Android ones too): no build script, procedural macro or test of
# the workspace runs in it. The build below has no ssh mount (so no agent socket
# and no key in reach of the code it compiles and runs).
RUN --mount=type=ssh,required=true \
--mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
cargo fetch --locked
# Gradle starts cargo-ndk, which starts cargo: the variable makes every one of
# them offline, as `--offline` does for the other Dockerfiles (the Gradle task
# is left as it is, because a developer's own build has network and no
# `cargo fetch`). The build uses what the step above fetched (the registry in
# the cache mount shared with it, the git checkout of VoelinProtocol in its
# layer) or fails.
ENV CARGO_NET_OFFLINE=true
RUN --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
--mount=type=cache,id=voelin-target-android,target=/src/target \
--mount=type=cache,id=voelin-gradle,target=/root/.gradle \
--mount=type=secret,id=keystore,required=false \
+11 -2
View File
@@ -45,14 +45,23 @@ WORKDIR /src
# `docker build --ssh default` forwards (scripts/docker-build.sh passes it):
# the key stays in the agent and never reaches a layer. The host key is the
# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so
# every cargo command needs this.
# the first cargo command needs this: the `cargo fetch` below, the only step
# that is given the agent.
COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
COPY . .
# Only this step is given the agent, and it only fetches: no build script,
# procedural macro or test of the workspace runs in it. It shares the registry
# cache with the build below, which has no ssh mount (so no agent socket and no
# key in reach of the code it compiles and runs) and is --offline: it uses what
# this step fetched (the registry in the cache mount, the git checkout of
# VoelinProtocol in this step's layer) or fails.
RUN --mount=type=ssh,required=true \
--mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
cargo fetch --locked
RUN --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
--mount=type=cache,id=voelin-target-linux,target=/src/target \
cargo build --release --locked -p voelin-ui -p voelin-gateway \
cargo build --release --locked --offline -p voelin-ui -p voelin-gateway \
&& scripts/package.sh linux /out
FROM scratch AS artifacts
+12 -3
View File
@@ -98,15 +98,24 @@ WORKDIR /src
# `docker build --ssh default` forwards (scripts/docker-build.sh passes it):
# the key stays in the agent and never reaches a layer. The host key is the
# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so
# every cargo command needs this.
# the first cargo command needs this: the `cargo fetch` below, the only step
# that is given the agent.
COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
COPY . .
# FFmpeg's LGPL DLLs go into the packages (scripts/fetch-ffmpeg-windows.sh).
# Only this step is given the agent, and it only fetches (the packages of every
# target, so the Windows ones too): no build script, procedural macro or test of
# the workspace runs in it. The build below has no ssh mount (so no agent socket
# and no key in reach of the code it compiles and runs) and is --offline: it
# uses what this step fetched (the registry in the cache mount shared with it,
# the git checkout of VoelinProtocol in this step's layer) or fails.
RUN --mount=type=ssh,required=true \
--mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
cargo fetch --locked
# FFmpeg's LGPL DLLs go into the packages (scripts/fetch-ffmpeg-windows.sh).
RUN --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
--mount=type=cache,id=voelin-target-windows,target=/src/target \
cargo build --release --locked --target x86_64-pc-windows-gnu -p voelin-ui \
cargo build --release --locked --offline --target x86_64-pc-windows-gnu -p voelin-ui \
&& scripts/fetch-ffmpeg-windows.sh /tmp/ffmpeg \
&& FFMPEG_DLL_DIR=/tmp/ffmpeg WINDOWS_TARGET=x86_64-pc-windows-gnu scripts/package.sh windows /out
+3 -1
View File
@@ -10,7 +10,9 @@
# The workspace depends on the private VoelinProtocol repository, which the
# build fetches over SSH with your ssh-agent (`docker build --ssh default`):
# the agent must hold a key that can read it (docs/building.md, "Depending on
# VoelinProtocol"). The key stays in the agent, never in the image.
# VoelinProtocol"). The key stays in the agent, never in the image, and only the
# Dockerfile's `cargo fetch` step is given the agent: the build after it is
# offline.
#
# Behind an HTTPS proxy, HTTPS_PROXY/HTTP_PROXY/NO_PROXY are passed on to the
# build; a proxy on this machine's loopback is reached with host networking.