ci(release): throwaway toolchain home, isolated signer, fail on missing deps
This commit is contained in:
parent
a8efb69b7f
commit
80d16ece80
2 changed files with 20 additions and 13 deletions
|
|
@ -46,7 +46,10 @@ jobs:
|
|||
run: |
|
||||
# Self-hosted host: install packages only if we may; otherwise assume they are preinstalled.
|
||||
if [ "$(id -u)" != 0 ] && ! sudo -n true 2>/dev/null; then
|
||||
echo "::warning::no root/passwordless sudo on the runner, skipping apt (dependencies must be preinstalled)"
|
||||
echo "::warning::no root/passwordless sudo, verifying preinstalled dependencies instead of installing"
|
||||
for t in cmake protoc zip x86_64-w64-mingw32-gcc pkg-config; do
|
||||
command -v "$t" >/dev/null || { echo "::error::missing required tool: $t"; exit 1; }
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
SUDO=$(command -v sudo || true)
|
||||
|
|
@ -63,16 +66,18 @@ jobs:
|
|||
$SUDO update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix || true
|
||||
$SUDO update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix || true
|
||||
|
||||
- name: Install Rust toolchain
|
||||
- name: Install pinned Rust toolchain into a throwaway home
|
||||
run: |
|
||||
if ! command -v rustup >/dev/null; then
|
||||
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
|
||||
fi
|
||||
. "$HOME/.cargo/env" 2>/dev/null || true
|
||||
rustup toolchain install stable --profile minimal
|
||||
rustup default stable
|
||||
rustup target add x86_64-pc-windows-gnu
|
||||
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
||||
set -euo pipefail
|
||||
# Never reuse a persistent toolchain/config from the shared runner host.
|
||||
export CARGO_HOME="$RUNNER_TEMP/cargo" RUSTUP_HOME="$RUNNER_TEMP/rustup"
|
||||
mkdir -p "$CARGO_HOME" "$RUSTUP_HOME"
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o "$RUNNER_TEMP/rustup-init.sh"
|
||||
sh "$RUNNER_TEMP/rustup-init.sh" -y --no-modify-path --profile minimal --default-toolchain stable
|
||||
"$CARGO_HOME/bin/rustup" target add x86_64-pc-windows-gnu
|
||||
echo "CARGO_HOME=$CARGO_HOME" >> "$GITHUB_ENV"
|
||||
echo "RUSTUP_HOME=$RUSTUP_HOME" >> "$GITHUB_ENV"
|
||||
echo "$CARGO_HOME/bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Build Linux x86_64
|
||||
run: cargo build --release --locked --bin vnox-client
|
||||
|
|
@ -137,7 +142,7 @@ jobs:
|
|||
run: |
|
||||
# Self-hosted host: install packages only if we may; otherwise assume they are preinstalled.
|
||||
if [ "$(id -u)" != 0 ] && ! sudo -n true 2>/dev/null; then
|
||||
echo "::warning::no root/passwordless sudo on the runner, skipping apt (dependencies must be preinstalled)"
|
||||
python3 -I -c 'import cryptography' || { echo "::error::python3 cryptography is not installed and cannot be installed"; exit 1; }
|
||||
exit 0
|
||||
fi
|
||||
SUDO=$(command -v sudo || true)
|
||||
|
|
@ -163,13 +168,13 @@ jobs:
|
|||
exit 1
|
||||
fi
|
||||
cd dist
|
||||
python3 ../scripts/release/manifest.py build \
|
||||
python3 -I ../scripts/release/manifest.py build \
|
||||
--version "$VERSION" --channel "$CHANNEL" \
|
||||
--min-version "${MIN_VERSION:-0.0.0}" \
|
||||
--base-url "$SERVER_URL/$REPO/releases/download/$TAG" \
|
||||
--dir . --out manifest.json \
|
||||
"$LIN_ASSET=linux-x86_64" "$WIN_ASSET=windows-x86_64"
|
||||
python3 ../scripts/release/manifest.py sign \
|
||||
python3 -I ../scripts/release/manifest.py sign \
|
||||
--manifest manifest.json --out manifest.json.sig
|
||||
ls -l
|
||||
|
||||
|
|
|
|||
|
|
@ -183,3 +183,5 @@ Workflow используют метку `self-hosted` (раннер `pink-star-
|
|||
### Риски self-hosted раннера
|
||||
|
||||
Раннер работает на хосте без изоляции, поэтому: CI пропускает PR из форков; в настройках репозитория отключите workflow для форков и требуйте одобрения для первых участников; раннер не должен работать от root; секреты лежат только в репозитории и доступны лишь job `publish`. Лучшее решение — отдельные метки (`ci-ephemeral` для CI и `release-signing` для публикации) и контейнерный раннер для CI, когда появится второй хост.
|
||||
|
||||
Сборка релиза использует одноразовые `CARGO_HOME`/`RUSTUP_HOME` в `$RUNNER_TEMP` (тулчейн ставится с нуля, постоянные настройки хоста игнорируются); подпись запускается как `python3 -I`; при отсутствии зависимостей job падает, а не продолжается. Остаточный риск: одна машина и для CI, и для подписи. Для полной изоляции нужны отдельные раннеры с метками `ci-untrusted` и `release-signing`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue