#!/usr/bin/env bash # Pulls the Windows installer and payload from the latest green run of .github/workflows/windows.yml on master and # copies them into the downloads folder (dl//), where the other packages live. Run on the Mac: # # packaging/windows/fetch-ci-artifacts.sh [--deploy] [run-id] # # Without --deploy it prints the deploy command for the main session to run; with --deploy it deploys the folder with # the Vercel CLI itself. A run id (gh run list) picks a specific run instead of the latest green one. # Reads ~/.config/igneum/dl-token, ~/.config/igneum/dlsite-dir (IGNEUM_DLSITE overrides) and the gh login, which must # be igneum-labs (gh auth switch --user igneum-labs). set -euo pipefail REPO="igneum-network/igneum" DEPLOY=0 RUN_ID="" for a in "$@"; do case "$a" in --deploy) DEPLOY=1 ;; *) RUN_ID="$a" ;; esac done TOKEN_FILE="$HOME/.config/igneum/dl-token" DLSITE="${IGNEUM_DLSITE:-}" [ -n "$DLSITE" ] || { [ -f "$HOME/.config/igneum/dlsite-dir" ] && DLSITE="$(tr -d '[:space:]' < "$HOME/.config/igneum/dlsite-dir")"; } || true [ -f "$TOKEN_FILE" ] || { echo "no $TOKEN_FILE" >&2; exit 1; } TOKEN="$(tr -d '[:space:]' < "$TOKEN_FILE")" DEST="$DLSITE/dl/$TOKEN" [ -n "$DLSITE" ] && [ -d "$DEST" ] || { echo "no downloads folder: set IGNEUM_DLSITE or ~/.config/igneum/dlsite-dir (must hold dl//)" >&2; exit 1; } gh auth status 2>&1 | grep -q 'Active account: true' || { echo "gh is not logged in" >&2; exit 1; } gh auth status 2>&1 | grep -B1 'Active account: true' | grep -q 'igneum-labs' || { echo "gh active account is not igneum-labs: run gh auth switch --user igneum-labs" >&2; exit 1; } if [ -z "$RUN_ID" ]; then RUN_ID="$(gh run list --repo "$REPO" --workflow windows.yml --branch master --status success --limit 1 --json databaseId --jq '.[0].databaseId')" [ -n "$RUN_ID" ] && [ "$RUN_ID" != "null" ] || { echo "no green windows.yml run on master yet" >&2; exit 1; } fi gh run view "$RUN_ID" --repo "$REPO" --json headSha,displayTitle,updatedAt,url,conclusion --jq '"run \(.url)\n\(.displayTitle)\n\(.headSha[0:12]) \(.updatedAt) \(.conclusion)"' TMP="$(mktemp -d)" gh run download "$RUN_ID" --repo "$REPO" --name igneum-windows-installer --name igneum-windows-payload --dir "$TMP" SETUP="$(find "$TMP" -name 'Igneum-Miner-Setup-*.exe' | head -1)" PAYLOAD="$(find "$TMP" -name 'igneum-windows-app.zip' | head -1)" [ -n "$SETUP" ] && [ -n "$PAYLOAD" ] || { echo "the run has no installer or payload artifact" >&2; ls -R "$TMP"; exit 1; } cp "$SETUP" "$DEST/" cp "$PAYLOAD" "$DEST/igneum-windows-app.zip" cat > "$DEST/igneum-windows-ci.json" <&1 | grep -v "$TOKEN" || true) echo "live: https://dl.igneum.network/dl//$(basename "$SETUP")" else echo "deploy: cd $DLSITE && npx vercel@latest --global-config ~/.config/igneum/vercel deploy --prod --yes" fi