#!/usr/bin/env bash # One-time setup: generate the GPG key used to sign the GitHub Pages apt repo. # # Run this locally once. After running: # 1. Commit public.gpg.key to the gh-pages branch (instructions printed below) # 2. Add APT_SIGNING_KEY to GitHub Actions secrets # 3. Add APT_SIGNING_KEY_PASSPHRASE to GitHub Actions secrets (empty string if no passphrase) # # Re-running is safe — it checks for an existing key first. set -euo pipefail REPO="TheGrandWazoo/freenas-proxmox" KEY_NAME="truenas-proxmox" KEY_EMAIL="packages@ksatechnologies.com" KEY_COMMENT="truenas-proxmox apt repo signing key" # ── Check for existing key ──────────────────────────────────────────────────── EXISTING="$(gpg --list-secret-keys --with-colons 2>/dev/null \ | awk -F: -v name="$KEY_NAME" '$1=="uid" && $10 ~ name {found=1} END {print found+0}')" if [[ "$EXISTING" == "1" ]]; then echo "Key '$KEY_NAME' already exists in your keyring — skipping generation." KEY_ID="$(gpg --list-secret-keys --with-colons 2>/dev/null \ | awk -F: '/^sec/{print $5; exit}')" else # ── Generate key ───────────────────────────────────────────────────────────── echo "Generating GPG key for apt repo signing..." read -r -s -p "Enter a passphrase (leave empty for no passphrase): " PASSPHRASE echo gpg --batch --gen-key < Exporting public key..." gpg --export --armor "$KEY_ID" > /tmp/truenas-proxmox-public.gpg.key echo "Public key written to /tmp/truenas-proxmox-public.gpg.key" # ── Export private key (base64) ─────────────────────────────────────────────── echo echo "==> Exporting private key (base64) for GitHub Actions secret..." PRIVATE_KEY_B64="$(gpg --export-secret-keys --armor "$KEY_ID" | base64 -w 0)" # ── Instructions ───────────────────────────────────────────────────────────── cat <