diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index eea4818..1bf5c2a 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -32,6 +32,34 @@ jobs: docker info >/dev/null # 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 + env: + PROTOCOL_DEPLOY_KEY: ${{ secrets.VOELIN_PROTOCOL_DEPLOY_KEY }} + run: | + set -euo pipefail + if [[ -z "${PROTOCOL_DEPLOY_KEY//[[:space:]]/}" ]]; then + echo "::error::The repository secret VOELIN_PROTOCOL_DEPLOY_KEY is missing or empty. It holds the private key of the read-only deploy key on Voelin/VoelinProtocol (docs/ci.md, VoelinProtocol access)." >&2 + exit 1 + fi + command -v ssh-agent ssh-add > /dev/null + eval "$(ssh-agent -s -t 32400)" > /dev/null + started= + trap '[[ -n "$started" ]] || ssh-agent -k > /dev/null' EXIT + # LF lines and one final newline, whatever the secret store did. + printf '%s\n' "$PROTOCOL_DEPLOY_KEY" | tr -d '\r' | sed '/^[[:space:]]*$/d' | ssh-add -q - + unset PROTOCOL_DEPLOY_KEY + # The fingerprint of the public half, to compare with the deploy key. + ssh-add -l + { + echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" + echo "SSH_AGENT_PID=$SSH_AGENT_PID" + } >> "$GITHUB_ENV" + started=1 - name: Linux packages run: scripts/docker-build.sh linux --progress=plain - name: Windows packages (MinGW) @@ -77,7 +105,7 @@ jobs: set -euo pipefail version=$(sed -n 's/^version = "\(.*\)"$/\1/p' crates/voelin-gateway/Cargo.toml | head -n 1) test -n "$version" - docker build -f crates/voelin-gateway/Dockerfile -t "tsgw:$version" -t tsgw:latest . + 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 - name: Collect packages and checksums @@ -104,3 +132,9 @@ 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 "${SSH_AGENT_PID:-}" ]]; then + ssh-agent -k > /dev/null || true + fi