diff --git a/.bazelignore b/.bazelignore new file mode 100644 index 0000000..92d46f3 --- /dev/null +++ b/.bazelignore @@ -0,0 +1,10 @@ +.build +.derived-data +.git +.nscloud-cache +Apple/build +ci-artifacts +dist +publish +release +target diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 0000000..47da986 --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +9.1.0 diff --git a/.forgejo/actions/decrypt-release-secrets/action.yml b/.forgejo/actions/decrypt-release-secrets/action.yml new file mode 100644 index 0000000..f9b8590 --- /dev/null +++ b/.forgejo/actions/decrypt-release-secrets/action.yml @@ -0,0 +1,327 @@ +name: Decrypt Release Secrets +description: Decrypts age-sealed Burrow release secrets and exports CI paths/env. +inputs: + root: + description: Repository root + required: false + default: . +runs: + using: composite + steps: + - shell: bash + run: | + set -euo pipefail + + ROOT_INPUT='${{ inputs.root }}' + ROOT="$(cd "$ROOT_INPUT" && pwd)" + + resolve_nix_bin() { + local candidate + for candidate in \ + "${NIX_BIN:-}" \ + "$(command -v nix 2>/dev/null || true)" \ + /nix/var/nix/profiles/default/bin/nix \ + "${HOME:-}/.nix-profile/bin/nix" \ + "${HOME:-}/.local/state/nix/profile/bin/nix" \ + /Users/runner/.nix-profile/bin/nix \ + /Users/runner/.local/state/nix/profile/bin/nix \ + /home/runner/.nix-profile/bin/nix \ + /home/runner/.local/state/nix/profile/bin/nix \ + ; do + if [[ -n "$candidate" && -x "$candidate" ]]; then + printf '%s\n' "$candidate" + return 0 + fi + done + return 1 + } + + resolve_decrypt_tool() { + local candidate + for candidate in \ + "${AGE_BIN:-}" \ + "$(command -v age 2>/dev/null || true)" \ + /opt/homebrew/bin/age \ + /usr/local/bin/age \ + /usr/bin/age \ + /run/current-system/sw/bin/age \ + /etc/profiles/per-user/runner/bin/age \ + "${HOME:-}/.nix-profile/bin/age" \ + "${HOME:-}/.local/state/nix/profile/bin/age" \ + /Users/runner/.nix-profile/bin/age \ + /Users/runner/.local/state/nix/profile/bin/age \ + /home/runner/.nix-profile/bin/age \ + /home/runner/.local/state/nix/profile/bin/age \ + ; do + if [[ -n "$candidate" && -x "$candidate" ]]; then + printf 'age:%s\n' "$candidate" + return 0 + fi + done + for candidate in \ + "${AGENIX_BIN:-}" \ + "$(command -v agenix 2>/dev/null || true)" \ + ; do + if [[ -n "$candidate" && -x "$candidate" ]]; then + printf 'agenix:%s\n' "$candidate" + return 0 + fi + done + local nix_bin + nix_bin="$(resolve_nix_bin || true)" + if [[ -n "$nix_bin" ]]; then + local built + built="$("$nix_bin" --extra-experimental-features 'nix-command flakes' build --no-link "$ROOT#age" --print-out-paths 2>/dev/null | tail -n 1 || true)" + if [[ -n "$built" && -x "$built/bin/age" ]]; then + printf 'age:%s\n' "$built/bin/age" + return 0 + fi + built="$("$nix_bin" --extra-experimental-features 'nix-command flakes' build --no-link "$ROOT#agenix" --print-out-paths 2>/dev/null | tail -n 1 || true)" + if [[ -n "$built" && -x "$built/bin/agenix" ]]; then + printf 'agenix:%s\n' "$built/bin/agenix" + return 0 + fi + fi + echo "::error ::age or agenix is required to decrypt release secrets but neither is available." >&2 + exit 1 + } + + decrypt_tool="$(resolve_decrypt_tool)" + decrypt_kind="${decrypt_tool%%:*}" + decrypt_bin="${decrypt_tool#*:}" + KEY="${AGE_IDENTITY_PATH:-}" + if [[ -z "$KEY" || ! -s "$KEY" ]]; then + echo "::error ::Missing age identity. Run Scripts/resolve-age-identity.sh before this action." >&2 + exit 1 + fi + + decrypt_age_file() { + local file_path="$1" + if [[ "$decrypt_kind" == "agenix" ]]; then + local agenix_path="$file_path" + if [[ "$file_path" == "$ROOT/"* ]]; then + agenix_path="${file_path#"$ROOT"/}" + fi + (cd "$ROOT" && "$decrypt_bin" --identity "$KEY" --decrypt "$agenix_path") + else + "$decrypt_bin" --decrypt -i "$KEY" "$file_path" + fi + } + + write_env() { + local name="$1" + local value="$2" + echo "${name}=${value}" >> "$GITHUB_ENV" + } + + mask_multiline() { + local value="$1" + echo "::add-mask::${value}" + while IFS= read -r line; do + [[ -n "$line" ]] || continue + echo "::add-mask::${line}" + done <<<"$value" + } + + decrypt_env_optional() { + local name="$1" + local file="$2" + if [[ ! -f "$file" ]]; then + echo "::notice ::Skipping optional release secret ${file}" + return 0 + fi + local value + value="$(decrypt_age_file "$file")" + mask_multiline "$value" + { + echo "${name}<> "$GITHUB_ENV" + } + + decrypt_file_optional() { + local name="$1" + local file="$2" + local suffix="$3" + if [[ ! -f "$file" ]]; then + echo "::notice ::Skipping optional release secret ${file}" + return 0 + fi + local temp_dir="${RUNNER_TEMP:-/tmp}" + local temp_file + temp_file="$(mktemp "${temp_dir}/${name}.XXXXXX")" + if [[ -n "$suffix" ]]; then + local with_suffix="${temp_file}.${suffix}" + mv "$temp_file" "$with_suffix" + temp_file="$with_suffix" + fi + decrypt_age_file "$file" > "$temp_file" + chmod 600 "$temp_file" + write_env "$name" "$temp_file" + } + + decrypt_dotenv_optional() { + local file="$1" + if [[ ! -f "$file" ]]; then + echo "::notice ::Skipping optional release secret ${file}" + return 0 + fi + local temp_file + temp_file="$(mktemp "${RUNNER_TEMP:-/tmp}/burrow-release-dotenv.XXXXXX")" + decrypt_age_file "$file" > "$temp_file" + # shellcheck disable=SC1090 + set -a + source "$temp_file" + set +a + rm -f "$temp_file" + + if [[ -z "${MINIO_ROOT_USER:-}" || -z "${MINIO_ROOT_PASSWORD:-}" ]]; then + echo "::error ::${file} must define MINIO_ROOT_USER and MINIO_ROOT_PASSWORD." >&2 + exit 1 + fi + echo "::add-mask::${MINIO_ROOT_USER}" + echo "::add-mask::${MINIO_ROOT_PASSWORD}" + { + echo "AWS_ACCESS_KEY_ID=${MINIO_ROOT_USER}" + echo "AWS_SECRET_ACCESS_KEY=${MINIO_ROOT_PASSWORD}" + echo "AWS_DEFAULT_REGION=${BLOB_REGION:-hel1}" + echo "AWS_REGION=${BLOB_REGION:-hel1}" + echo "AWS_S3_ENDPOINT_URL=https://${BLOB_ENDPOINT:-hel1.your-objectstorage.com}" + } >> "$GITHUB_ENV" + } + + decode_base64_stream() { + if command -v base64 >/dev/null 2>&1; then + base64 -d 2>/dev/null || base64 -D + elif command -v openssl >/dev/null 2>&1; then + openssl base64 -d -A + else + echo "::error ::base64 or openssl is required to decode release secrets." >&2 + return 127 + fi + } + + decode_base64_to_file() { + local output="$1" + decode_base64_stream > "$output" + } + + decrypt_appstore_connect() { + local file="$ROOT/secrets/apple/appstore-connect.env.age" + if [[ ! -f "$file" ]]; then + echo "::notice ::Skipping optional release secret ${file}" + return 0 + fi + + local temp_file key_path key_value + temp_file="$(mktemp "${RUNNER_TEMP:-/tmp}/burrow-asc-env.XXXXXX")" + decrypt_age_file "$file" > "$temp_file" + # shellcheck disable=SC1090 + set -a + source "$temp_file" + set +a + rm -f "$temp_file" + + if [[ -z "${ASC_API_KEY_ID:-}" || -z "${ASC_API_ISSUER_ID:-}" ]]; then + echo "::error ::${file} must define ASC_API_KEY_ID and ASC_API_ISSUER_ID." >&2 + exit 1 + fi + + key_path="$(mktemp "${RUNNER_TEMP:-/tmp}/burrow-asc-key.XXXXXX.p8")" + if [[ -n "${ASC_API_KEY_BASE64:-}" ]]; then + printf '%s' "$ASC_API_KEY_BASE64" | decode_base64_to_file "$key_path" + elif [[ -n "${ASC_API_KEY_P8_BASE64:-}" ]]; then + printf '%s' "$ASC_API_KEY_P8_BASE64" | decode_base64_to_file "$key_path" + elif [[ -n "${APPSTORE_KEY:-}" ]]; then + printf '%s\n' "$APPSTORE_KEY" > "$key_path" + elif [[ -n "${ASC_API_KEY:-}" ]]; then + printf '%s\n' "$ASC_API_KEY" > "$key_path" + else + echo "::error ::${file} must define ASC_API_KEY_BASE64 or ASC_API_KEY." >&2 + exit 1 + fi + chmod 600 "$key_path" + key_value="$(cat "$key_path")" + mask_multiline "$key_value" + echo "::add-mask::${ASC_API_KEY_ID}" + echo "::add-mask::${ASC_API_ISSUER_ID}" + write_env ASC_API_KEY_ID "$ASC_API_KEY_ID" + write_env ASC_API_ISSUER_ID "$ASC_API_ISSUER_ID" + write_env ASC_API_KEY_PATH "$key_path" + } + + decrypt_distribution_signing() { + local file="$ROOT/secrets/apple/distribution-signing.env.age" + if [[ ! -f "$file" ]]; then + echo "::notice ::Skipping optional release secret ${file}" + return 0 + fi + + local temp_file cert_path cert_password cert_base64 + temp_file="$(mktemp "${RUNNER_TEMP:-/tmp}/burrow-signing-env.XXXXXX")" + decrypt_age_file "$file" > "$temp_file" + # shellcheck disable=SC1090 + set -a + source "$temp_file" + set +a + rm -f "$temp_file" + + cert_base64="${APPLE_SIGNING_CERTIFICATE_BASE64:-${APPLE_DISTRIBUTION_CERTIFICATE_BASE64:-}}" + cert_password="${APPLE_SIGNING_CERTIFICATE_PASSWORD:-${APPLE_DISTRIBUTION_CERTIFICATE_PASSWORD:-}}" + if [[ -z "$cert_password" && -n "${APPLE_SIGNING_CERTIFICATE_PASSWORD_BASE64:-}" ]]; then + cert_password="$(printf '%s' "$APPLE_SIGNING_CERTIFICATE_PASSWORD_BASE64" | decode_base64_stream)" + fi + if [[ -z "$cert_base64" || -z "$cert_password" ]]; then + echo "::error ::${file} must define APPLE_SIGNING_CERTIFICATE_BASE64 and APPLE_SIGNING_CERTIFICATE_PASSWORD." >&2 + exit 1 + fi + + cert_path="$(mktemp "${RUNNER_TEMP:-/tmp}/burrow-apple-signing.XXXXXX.p12")" + printf '%s' "$cert_base64" | decode_base64_to_file "$cert_path" + chmod 600 "$cert_path" + echo "::add-mask::${cert_password}" + write_env APPLE_SIGNING_CERTIFICATE_PATH "$cert_path" + write_env APPLE_SIGNING_CERTIFICATE_PASSWORD "$cert_password" + write_env APPLE_KEYCHAIN_PASSWORD "$cert_password" + } + + decrypt_sparkle() { + local file="$ROOT/secrets/apple/sparkle.env.age" + if [[ ! -f "$file" ]]; then + echo "::notice ::Skipping optional release secret ${file}" + return 0 + fi + + local temp_file key_path key_base64 key_value + temp_file="$(mktemp "${RUNNER_TEMP:-/tmp}/burrow-sparkle-env.XXXXXX")" + decrypt_age_file "$file" > "$temp_file" + # shellcheck disable=SC1090 + set -a + source "$temp_file" + set +a + rm -f "$temp_file" + + key_base64="${SPARKLE_EDDSA_KEY_BASE64:-${SPARKLE_PRIVATE_KEY_BASE64:-}}" + key_path="$(mktemp "${RUNNER_TEMP:-/tmp}/burrow-sparkle-eddsa.XXXXXX.key")" + if [[ -n "$key_base64" ]]; then + printf '%s' "$key_base64" | decode_base64_to_file "$key_path" + elif [[ -n "${SPARKLE_EDDSA_KEY:-}" ]]; then + printf '%s\n' "$SPARKLE_EDDSA_KEY" > "$key_path" + elif [[ -n "${SPARKLE_PRIVATE_KEY:-}" ]]; then + printf '%s\n' "$SPARKLE_PRIVATE_KEY" > "$key_path" + else + echo "::error ::${file} must define SPARKLE_EDDSA_KEY_BASE64 or SPARKLE_EDDSA_KEY." >&2 + exit 1 + fi + chmod 600 "$key_path" + key_value="$(cat "$key_path")" + mask_multiline "$key_value" + write_env SPARKLE_EDDSA_KEY_PATH "$key_path" + } + + decrypt_appstore_connect + decrypt_distribution_signing + decrypt_sparkle + + decrypt_dotenv_optional "$ROOT/secrets/hetzner/object-storage.age" diff --git a/.forgejo/workflows/apple-developer-id-kms-csr.yml b/.forgejo/workflows/apple-developer-id-kms-csr.yml new file mode 100644 index 0000000..4c8901b --- /dev/null +++ b/.forgejo/workflows/apple-developer-id-kms-csr.yml @@ -0,0 +1,98 @@ +name: "Apple: Developer ID KMS CSR" +run-name: "Apple: Developer ID KMS CSR (${{ github.event.inputs.kms_key || 'apple-developer-id-application' }})" + +on: + workflow_dispatch: + inputs: + kms_key: + description: Google KMS key name in the Burrow identity key ring + required: false + default: apple-developer-id-application + kms_version: + description: Google KMS key version + required: false + default: "1" + common_name: + description: CSR common name + required: false + default: Burrow Developer ID Application + email_address: + description: CSR email address + required: false + default: release@burrow.net + +permissions: + contents: read + +concurrency: + group: apple-developer-id-kms-csr-${{ github.ref }} + cancel-in-progress: false + +env: + BURROW_GOOGLE_PROJECT_ID: ${{ vars.GOOGLE_PROJECT_ID || 'project-88c23ce9-918a-470a-b33' }} + GOOGLE_CLOUD_PROJECT: ${{ vars.GOOGLE_PROJECT_ID || 'project-88c23ce9-918a-470a-b33' }} + BURROW_GOOGLE_PROJECT_NUMBER: ${{ vars.GOOGLE_PROJECT_NUMBER || '416198671487' }} + BURROW_GOOGLE_WIF_POOL_ID: ${{ vars.BURROW_GOOGLE_WIF_POOL_ID || 'burrow-authentik' }} + BURROW_GOOGLE_WIF_PROVIDER_ID: ${{ vars.BURROW_GOOGLE_WIF_PROVIDER_ID || 'forgejo-runners' }} + BURROW_GOOGLE_WIF_SERVICE_ACCOUNT: ${{ vars.BURROW_GOOGLE_WIF_SERVICE_ACCOUNT || 'burrow-forgejo-runner@project-88c23ce9-918a-470a-b33.iam.gserviceaccount.com' }} + BURROW_AUTHENTIK_WIF_ISSUER: ${{ vars.BURROW_AUTHENTIK_WIF_ISSUER || 'https://auth.burrow.net/application/o/google-cloud/' }} + BURROW_AUTHENTIK_WIF_AUDIENCE: ${{ vars.BURROW_AUTHENTIK_WIF_AUDIENCE || 'google-wif.burrow.net' }} + BURROW_AUTHENTIK_WIF_CLIENT_ID: ${{ vars.BURROW_AUTHENTIK_WIF_CLIENT_ID || 'google-wif.burrow.net' }} + BURROW_AUTHENTIK_WIF_CLIENT_SECRET: ${{ secrets.BURROW_AUTHENTIK_WIF_CLIENT_SECRET }} + BURROW_KMS_LOCATION: global + BURROW_KMS_KEYRING: burrow-identity + +jobs: + csr: + name: Generate CSR + runs-on: [self-hosted, linux, x86_64, burrow-forge] + timeout-minutes: 20 + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Ensure Nix + shell: bash + run: bash Scripts/ci/ensure-nix.sh + + - name: Authenticate Google WIF + shell: bash + run: nix develop .#ci -c Scripts/ci/google-wif-auth.sh + + - name: Generate KMS-backed CSR + shell: bash + env: + BURROW_APPLE_DEVELOPER_ID_KMS_KEY: ${{ github.event.inputs.kms_key || 'apple-developer-id-application' }} + BURROW_KMS_VERSION: ${{ github.event.inputs.kms_version || '1' }} + BURROW_APPLE_DEVELOPER_ID_CSR_COMMON_NAME: ${{ github.event.inputs.common_name || 'Burrow Developer ID Application' }} + BURROW_APPLE_DEVELOPER_ID_CSR_EMAIL: ${{ github.event.inputs.email_address || 'release@burrow.net' }} + run: | + set -euo pipefail + mkdir -p dist/apple-developer-id + nix develop .#ci -c Scripts/apple/google-kms-csr.py \ + --output dist/apple-developer-id/developer-id-application.certSigningRequest \ + --public-key-output dist/apple-developer-id/google-kms-public-key.pem + if command -v openssl >/dev/null 2>&1; then + openssl req -in dist/apple-developer-id/developer-id-application.certSigningRequest -noout -verify + fi + cat > dist/apple-developer-id/README.txt <<'EOF' + This CSR is backed by a non-exportable Google Cloud KMS key in the Burrow + identity key ring. Apple currently documents Developer ID certificate creation + through the Developer website or Xcode, not App Store Connect API creation. + + Upload developer-id-application.certSigningRequest in: + Certificates, Identifiers & Profiles -> Certificates -> + -> Developer ID -> + Developer ID Application. + + Keep the returned .cer file with release artifacts. The private key remains in + Google Cloud KMS and is never exported as a p12. + EOF + + - name: Upload CSR Artifact + uses: https://code.forgejo.org/actions/upload-artifact@v3 + with: + name: burrow-developer-id-kms-csr + path: dist/apple-developer-id diff --git a/.forgejo/workflows/apple-distribute-testers.yml b/.forgejo/workflows/apple-distribute-testers.yml new file mode 100644 index 0000000..f108237 --- /dev/null +++ b/.forgejo/workflows/apple-distribute-testers.yml @@ -0,0 +1,530 @@ +name: "Apple: Distribute Testers" +run-name: "Apple: Distribute Testers (${{ github.ref_name }})" + +on: + workflow_dispatch: + inputs: + build_number_override: + description: Optional explicit build number + required: false + default: "" + upload_app_store: + description: Upload iOS artifact to App Store Connect and TestFlight + required: false + default: "true" + upload_sparkle: + description: Publish Sparkle appcast and macOS artifact + required: false + default: "true" + sparkle_channel: + description: Sparkle channel, defaults to build- + required: false + default: "" + sparkle_point_main: + description: Update Sparkle main channel pointers + required: false + default: "true" + testflight_distribute_external: + description: Distribute to external TestFlight groups + required: false + default: "false" + testflight_groups: + description: Optional comma-separated TestFlight groups + required: false + default: "" + ios_uses_non_exempt_encryption: + description: Set true only when the iOS build uses non-exempt encryption + required: false + default: "false" + +permissions: + actions: write + contents: read + +concurrency: + group: burrow-apple-distribute-testers-${{ github.ref }} + cancel-in-progress: true + +env: + BURROW_RELEASE_GCS_BUCKET: ${{ vars.BURROW_RELEASE_GCS_BUCKET || 'burrow-net-releases' }} + BURROW_RELEASE_GCS_BACKUP: ${{ vars.BURROW_RELEASE_GCS_BACKUP || 'true' }} + BURROW_RELEASE_GARAGE_BUCKET: ${{ vars.BURROW_RELEASE_GARAGE_BUCKET || 'burrow-releases' }} + BURROW_RELEASE_REQUIRE_GARAGE: ${{ vars.BURROW_RELEASE_REQUIRE_GARAGE || 'true' }} + BURROW_GARAGE_ENDPOINT: ${{ vars.BURROW_GARAGE_ENDPOINT || 'https://objects.burrow.net' }} + BURROW_GARAGE_REGION: ${{ vars.BURROW_GARAGE_REGION || 'garage' }} + AWS_ACCESS_KEY_ID: ${{ secrets.BURROW_GARAGE_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.BURROW_GARAGE_SECRET_ACCESS_KEY }} + BURROW_GOOGLE_PROJECT_ID: ${{ vars.GOOGLE_PROJECT_ID || 'project-88c23ce9-918a-470a-b33' }} + GOOGLE_CLOUD_PROJECT: ${{ vars.GOOGLE_PROJECT_ID || 'project-88c23ce9-918a-470a-b33' }} + BURROW_GOOGLE_PROJECT_NUMBER: ${{ vars.GOOGLE_PROJECT_NUMBER || '416198671487' }} + BURROW_GOOGLE_WIF_POOL_ID: ${{ vars.BURROW_GOOGLE_WIF_POOL_ID || 'burrow-authentik' }} + BURROW_GOOGLE_WIF_PROVIDER_ID: ${{ vars.BURROW_GOOGLE_WIF_PROVIDER_ID || 'forgejo-runners' }} + BURROW_GOOGLE_WIF_SERVICE_ACCOUNT: ${{ vars.BURROW_GOOGLE_WIF_SERVICE_ACCOUNT || 'burrow-forgejo-runner@project-88c23ce9-918a-470a-b33.iam.gserviceaccount.com' }} + BURROW_AUTHENTIK_WIF_ISSUER: ${{ vars.BURROW_AUTHENTIK_WIF_ISSUER || 'https://auth.burrow.net/application/o/google-cloud/' }} + BURROW_AUTHENTIK_WIF_AUDIENCE: ${{ vars.BURROW_AUTHENTIK_WIF_AUDIENCE || 'google-wif.burrow.net' }} + BURROW_AUTHENTIK_WIF_CLIENT_ID: ${{ vars.BURROW_AUTHENTIK_WIF_CLIENT_ID || 'google-wif.burrow.net' }} + BURROW_AUTHENTIK_WIF_CLIENT_SECRET: ${{ secrets.BURROW_AUTHENTIK_WIF_CLIENT_SECRET }} + BURROW_NIX_CACHE_URL: ${{ vars.BURROW_NIX_CACHE_URL || 'https://nix.burrow.net/burrow' }} + BURROW_NIX_CACHE_PUBLIC_KEY: ${{ vars.BURROW_NIX_CACHE_PUBLIC_KEY }} + BURROW_APPLE_BUNDLE_ID: ${{ vars.BURROW_APPLE_BUNDLE_ID || 'net.burrow.app' }} + BURROW_APPLE_NETWORK_EXTENSION_BUNDLE_ID: ${{ vars.BURROW_APPLE_NETWORK_EXTENSION_BUNDLE_ID || 'net.burrow.app.network' }} + BURROW_IOS_DISTRIBUTION_CERTIFICATE_ID: ${{ vars.BURROW_IOS_DISTRIBUTION_CERTIFICATE_ID || '3G42677598' }} + BURROW_DEVELOPER_ID_CERTIFICATE_ID: ${{ vars.BURROW_DEVELOPER_ID_CERTIFICATE_ID || '9JKN6HXBHC' }} + BURROW_APPLE_SIGNING_MODE: google-kms-staged + BURROW_NOTARIZE_MACOS: ${{ vars.BURROW_NOTARIZE_MACOS || 'true' }} + BURROW_SPARKLE_SIGN_WITH_KMS: ${{ vars.BURROW_SPARKLE_SIGN_WITH_KMS || 'true' }} + BURROW_SPARKLE_KMS_KEY: ${{ vars.BURROW_SPARKLE_KMS_KEY || 'sparkle-ed25519' }} + BURROW_SPARKLE_KMS_VERSION: ${{ vars.BURROW_SPARKLE_KMS_VERSION || '1' }} + BURROW_SPARKLE_FEED_URL: ${{ vars.BURROW_SPARKLE_FEED_URL || 'https://releases.burrow.net/sparkle/appcast.xml' }} + BURROW_SPARKLE_PUBLIC_ED_KEY: ${{ vars.BURROW_SPARKLE_PUBLIC_ED_KEY || 'uugZuJeqvvKd91NZ6F1Fv2cQenUbIG/ZW3L9MuaEz30=' }} + BURROW_KMS_LOCATION: ${{ vars.BURROW_KMS_LOCATION || 'global' }} + BURROW_KMS_KEYRING: ${{ vars.BURROW_KMS_KEYRING || 'burrow-identity' }} + TESTFLIGHT_WAIT_PROCESSING_TIMEOUT_SECONDS: ${{ vars.TESTFLIGHT_WAIT_PROCESSING_TIMEOUT_SECONDS || '7200' }} + BURROW_VERSION_REQUIRE_REMOTE: "1" + +jobs: + prepare: + name: Prepare Apple Distribution + runs-on: namespace-profile-linux-medium-apple-v2 + outputs: + build_number: ${{ steps.plan.outputs.build_number }} + sparkle_channel: ${{ steps.plan.outputs.sparkle_channel }} + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Fetch Build Tags + shell: bash + run: git fetch --force --prune origin "+refs/tags/builds/*:refs/tags/builds/*" + + - name: Compute Apple Distribution Plan + id: plan + shell: bash + env: + BUILD_NUMBER_OVERRIDE: ${{ github.event.inputs.build_number_override || '' }} + SPARKLE_CHANNEL_INPUT: ${{ github.event.inputs.sparkle_channel || '' }} + run: | + set -euo pipefail + if [[ -n "$BUILD_NUMBER_OVERRIDE" ]]; then + build_number="$BUILD_NUMBER_OVERRIDE" + else + build_number="$(Scripts/version.sh pre-increment)" + fi + channel="$SPARKLE_CHANNEL_INPUT" + if [[ -z "$channel" ]]; then + channel="build-${build_number}" + fi + echo "build_number=${build_number}" >> "$GITHUB_OUTPUT" + echo "sparkle_channel=${channel}" >> "$GITHUB_OUTPUT" + printf 'build_number=%s\nsparkle_channel=%s\n' "$build_number" "$channel" + + build-ios: + name: Build Apple iOS + needs: prepare + runs-on: namespace-profile-macos-large-apple-v2 + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + submodules: recursive + + - name: Select Apple SDK + shell: bash + run: | + set -euo pipefail + xcrun --find swiftc + xcrun --sdk iphoneos --show-sdk-path + xcrun --sdk iphonesimulator --show-sdk-path + + - name: Prepare Rust Apple Targets + shell: bash + run: | + set -euo pipefail + if ! command -v rustup >/dev/null 2>&1; then + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable + export PATH="$HOME/.cargo/bin:$PATH" + fi + rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios + + - name: Bootstrap Runner Environment + shell: bash + run: | + set -euo pipefail + runner_home="${RUNNER_HOME:-}" + if [[ -z "$runner_home" ]]; then + runner_home="$(python3 -c 'import os,pwd; print(pwd.getpwuid(os.getuid()).pw_dir)' 2>/dev/null || true)" + if [[ -z "$runner_home" ]]; then + runner_home="$PWD/.home" + fi + fi + mkdir -p "$runner_home" "$PWD/.tmp" + { + echo "HOME=$runner_home" + echo "XDG_CACHE_HOME=$runner_home/.cache" + echo "XDG_CONFIG_HOME=$runner_home/.config" + echo "XDG_DATA_HOME=$runner_home/.local/share" + echo "TMPDIR=$PWD/.tmp" + echo "TMP=$PWD/.tmp" + } >> "$GITHUB_ENV" + + - name: Ensure Nix + shell: bash + run: bash Scripts/ci/ensure-nix.sh + + - name: Namespace Cache + shell: bash + run: | + set -euo pipefail + bash Scripts/ci/nscloud-cache.sh bazel + + - name: Build Staged iOS Artifact + shell: bash + env: + BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }} + run: | + set -euo pipefail + bazel_args=() + if [[ -n "${BURROW_BAZEL_NSCCACHE_BAZELRC:-}" && -f "${BURROW_BAZEL_NSCCACHE_BAZELRC:-}" ]]; then + bazel_args+=("--bazelrc=${BURROW_BAZEL_NSCCACHE_BAZELRC}") + fi + NIX_BIN="$(bash Scripts/ci/resolve-nix-bin.sh)" + ci_path="$("$NIX_BIN" develop .#ci --command bash -lc 'printf "%s" "$PATH"')" + ci_protoc="$("$NIX_BIN" develop .#ci --command bash -lc 'command -v protoc')" + "$NIX_BIN" develop .#ci --command bazel "${bazel_args[@]}" build \ + --verbose_failures \ + --show_timestamps \ + --experimental_ui_max_stdouterr_bytes=16777216 \ + --action_env=PATH="$ci_path" \ + --action_env=PROTOC="$ci_protoc" \ + --action_env=BUILD_WORKSPACE_DIRECTORY="$PWD" \ + --action_env=BUILD_NUMBER="$BUILD_NUMBER" \ + --action_env=BURROW_RELEASE_OUT="$PWD/dist/builds/$BUILD_NUMBER" \ + --action_env=BURROW_APPLE_SIGNING_MODE="$BURROW_APPLE_SIGNING_MODE" \ + --action_env=BURROW_APPLE_REQUIRE_SIGNING=true \ + --action_env=BURROW_APPLE_BUNDLE_ID="$BURROW_APPLE_BUNDLE_ID" \ + --action_env=BURROW_APPLE_NETWORK_EXTENSION_BUNDLE_ID="$BURROW_APPLE_NETWORK_EXTENSION_BUNDLE_ID" \ + --action_env=HOME="$HOME" \ + --action_env=XDG_CACHE_HOME="$XDG_CACHE_HOME" \ + //bazel/apple:release_ios_stamp + + - name: Upload Staged iOS Artifact + uses: https://code.forgejo.org/actions/upload-artifact@v3 + with: + name: burrow-apple-ios-${{ needs.prepare.outputs.build_number }} + path: | + dist/builds/${{ needs.prepare.outputs.build_number }}/apple/Burrow-iOS-${{ needs.prepare.outputs.build_number }}.unsigned.ipa + dist/builds/${{ needs.prepare.outputs.build_number }}/apple/Burrow-iOS-${{ needs.prepare.outputs.build_number }}.unsigned.ipa.sha256 + if-no-files-found: error + + build-macos: + name: Build Apple macOS + needs: prepare + runs-on: namespace-profile-macos-large-apple-v2 + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + submodules: recursive + + - name: Select Apple SDK + shell: bash + run: | + set -euo pipefail + xcrun --find swiftc + xcrun --sdk macosx --show-sdk-path + + - name: Prepare Rust Apple Targets + shell: bash + run: | + set -euo pipefail + if ! command -v rustup >/dev/null 2>&1; then + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable + export PATH="$HOME/.cargo/bin:$PATH" + fi + rustup target add aarch64-apple-darwin x86_64-apple-darwin + + - name: Bootstrap Runner Environment + shell: bash + run: | + set -euo pipefail + runner_home="${RUNNER_HOME:-}" + if [[ -z "$runner_home" ]]; then + runner_home="$(python3 -c 'import os,pwd; print(pwd.getpwuid(os.getuid()).pw_dir)' 2>/dev/null || true)" + if [[ -z "$runner_home" ]]; then + runner_home="$PWD/.home" + fi + fi + mkdir -p "$runner_home" "$PWD/.tmp" + { + echo "HOME=$runner_home" + echo "XDG_CACHE_HOME=$runner_home/.cache" + echo "XDG_CONFIG_HOME=$runner_home/.config" + echo "XDG_DATA_HOME=$runner_home/.local/share" + echo "TMPDIR=$PWD/.tmp" + echo "TMP=$PWD/.tmp" + } >> "$GITHUB_ENV" + + - name: Ensure Nix + shell: bash + run: bash Scripts/ci/ensure-nix.sh + + - name: Namespace Cache + shell: bash + run: | + set -euo pipefail + bash Scripts/ci/nscloud-cache.sh bazel + + - name: Build Staged macOS Artifact + shell: bash + env: + BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }} + run: | + set -euo pipefail + bazel_args=() + if [[ -n "${BURROW_BAZEL_NSCCACHE_BAZELRC:-}" && -f "${BURROW_BAZEL_NSCCACHE_BAZELRC:-}" ]]; then + bazel_args+=("--bazelrc=${BURROW_BAZEL_NSCCACHE_BAZELRC}") + fi + NIX_BIN="$(bash Scripts/ci/resolve-nix-bin.sh)" + ci_path="$("$NIX_BIN" develop .#ci --command bash -lc 'printf "%s" "$PATH"')" + ci_protoc="$("$NIX_BIN" develop .#ci --command bash -lc 'command -v protoc')" + "$NIX_BIN" develop .#ci --command bazel "${bazel_args[@]}" build \ + --verbose_failures \ + --show_timestamps \ + --experimental_ui_max_stdouterr_bytes=16777216 \ + --action_env=PATH="$ci_path" \ + --action_env=PROTOC="$ci_protoc" \ + --action_env=BUILD_WORKSPACE_DIRECTORY="$PWD" \ + --action_env=BUILD_NUMBER="$BUILD_NUMBER" \ + --action_env=BURROW_RELEASE_OUT="$PWD/dist/builds/$BUILD_NUMBER" \ + --action_env=BURROW_APPLE_SIGNING_MODE="$BURROW_APPLE_SIGNING_MODE" \ + --action_env=BURROW_APPLE_REQUIRE_SIGNING=true \ + --action_env=BURROW_APPLE_BUNDLE_ID="$BURROW_APPLE_BUNDLE_ID" \ + --action_env=BURROW_APPLE_NETWORK_EXTENSION_BUNDLE_ID="$BURROW_APPLE_NETWORK_EXTENSION_BUNDLE_ID" \ + --action_env=BURROW_SPARKLE_FEED_URL="$BURROW_SPARKLE_FEED_URL" \ + --action_env=BURROW_SPARKLE_PUBLIC_ED_KEY="$BURROW_SPARKLE_PUBLIC_ED_KEY" \ + --action_env=HOME="$HOME" \ + --action_env=XDG_CACHE_HOME="$XDG_CACHE_HOME" \ + //bazel/apple:release_macos_stamp + + - name: Upload Staged macOS Artifact + uses: https://code.forgejo.org/actions/upload-artifact@v3 + with: + name: burrow-apple-macos-${{ needs.prepare.outputs.build_number }} + path: | + dist/builds/${{ needs.prepare.outputs.build_number }}/apple/Burrow-macOS-${{ needs.prepare.outputs.build_number }}.unsigned.zip + dist/builds/${{ needs.prepare.outputs.build_number }}/apple/Burrow-macOS-${{ needs.prepare.outputs.build_number }}.unsigned.zip.sha256 + if-no-files-found: error + + sign-apple: + name: Sign Apple Artifacts + needs: + - prepare + - build-ios + - build-macos + runs-on: namespace-profile-linux-medium-apple-v2 + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Ensure Nix + shell: bash + run: bash Scripts/ci/ensure-nix.sh + + - name: Configure Age + shell: bash + env: + AGE_FORGE_SSH_KEY: ${{ secrets.AGE_FORGE_SSH_KEY }} + run: Scripts/resolve-age-identity.sh >> "$GITHUB_ENV" + + - name: Decrypt Release Secrets + uses: ./.forgejo/actions/decrypt-release-secrets + + - name: Validate App Store Credentials + shell: bash + run: Scripts/ci/check-release-config.sh app-store + + - name: Authenticate Google WIF + shell: bash + run: nix develop .#ci -c Scripts/ci/google-wif-auth.sh + + - name: Download Staged Apple Artifacts + uses: https://code.forgejo.org/actions/download-artifact@v3 + with: + path: dist/downloaded + + - name: Prepare Staged Apple Directory + shell: bash + env: + BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }} + run: | + set -euo pipefail + mkdir -p "dist/builds/${BUILD_NUMBER}/apple" + find dist/downloaded -type f -name 'Burrow-*.unsigned.*' -exec cp -v {} "dist/builds/${BUILD_NUMBER}/apple/" \; + find "dist/builds/${BUILD_NUMBER}/apple" -type f -print | sort + + - name: Sync Apple Provisioning Profiles + shell: bash + run: nix develop .#ci -c Scripts/ci/sync-apple-provisioning-profiles.sh all + + - name: Sign Apple Artifacts With KMS + shell: bash + env: + BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }} + SPARKLE_CHANNEL: ${{ needs.prepare.outputs.sparkle_channel }} + run: nix develop .#ci -c Scripts/apple/sign-release-artifacts-kms.sh all + + - name: Upload Signed Apple Artifacts To Release Storage + shell: bash + env: + BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }} + run: nix develop .#ci -c Scripts/ci/upload-release-storage.sh + + - name: Upload Signed Apple Artifacts + uses: https://code.forgejo.org/actions/upload-artifact@v3 + with: + name: burrow-apple-signed-${{ needs.prepare.outputs.build_number }} + path: | + dist/builds/${{ needs.prepare.outputs.build_number }}/apple/Burrow-iOS-${{ needs.prepare.outputs.build_number }}.ipa + dist/builds/${{ needs.prepare.outputs.build_number }}/apple/Burrow-iOS-${{ needs.prepare.outputs.build_number }}.ipa.sha256 + dist/builds/${{ needs.prepare.outputs.build_number }}/apple/Burrow-macOS-${{ needs.prepare.outputs.build_number }}.zip + dist/builds/${{ needs.prepare.outputs.build_number }}/apple/Burrow-macOS-${{ needs.prepare.outputs.build_number }}.zip.sha256 + dist/builds/${{ needs.prepare.outputs.build_number }}/sparkle/** + if-no-files-found: error + + upload-testflight: + name: Upload TestFlight + needs: + - prepare + - sign-apple + if: ${{ github.event.inputs.upload_app_store == 'true' }} + runs-on: namespace-profile-macos-large-testflight + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Ensure Nix + shell: bash + run: bash Scripts/ci/ensure-nix.sh + + - name: Configure Age + shell: bash + env: + AGE_FORGE_SSH_KEY: ${{ secrets.AGE_FORGE_SSH_KEY }} + run: Scripts/resolve-age-identity.sh >> "$GITHUB_ENV" + + - name: Decrypt Release Secrets + uses: ./.forgejo/actions/decrypt-release-secrets + + - name: Download Signed Apple Artifacts + uses: https://code.forgejo.org/actions/download-artifact@v3 + with: + name: burrow-apple-signed-${{ needs.prepare.outputs.build_number }} + path: publish + + - name: Upload iOS IPA To App Store Connect + shell: bash + env: + BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }} + run: | + set -euo pipefail + Scripts/ci/check-release-config.sh app-store + key_dir="${RUNNER_TEMP:-/tmp}/burrow-asc" + altool_key_dir="${HOME}/.appstoreconnect/private_keys" + mkdir -p "$key_dir" "$altool_key_dir" + key_path="$key_dir/AuthKey_${ASC_API_KEY_ID}.p8" + if [[ -n "${ASC_API_KEY_PATH:-}" && -f "${ASC_API_KEY_PATH:-}" ]]; then + cp "$ASC_API_KEY_PATH" "$key_path" + else + printf '%s' "$ASC_API_KEY_BASE64" | base64 --decode > "$key_path" + fi + cp "$key_path" "$altool_key_dir/AuthKey_${ASC_API_KEY_ID}.p8" + chmod 600 "$key_path" "$altool_key_dir/AuthKey_${ASC_API_KEY_ID}.p8" + ipa="publish/apple/Burrow-iOS-${BUILD_NUMBER}.ipa" + if [[ ! -s "$ipa" ]]; then + echo "::error ::No signed iOS IPA found at $ipa" >&2 + find publish -type f -print | sort + exit 1 + fi + upload_log="${RUNNER_TEMP:-/tmp}/burrow-altool-ios-${BUILD_NUMBER}.log" + set +e + xcrun altool --upload-app \ + --type ios \ + --file "$ipa" \ + --apiKey "$ASC_API_KEY_ID" \ + --apiIssuer "$ASC_API_ISSUER_ID" 2>&1 | tee "$upload_log" + altool_status=${PIPESTATUS[0]} + set -e + if (( altool_status != 0 )) || grep -Eq 'UPLOAD FAILED|Validation failed|ERROR:' "$upload_log"; then + echo "::error ::altool reported upload validation failure for $ipa" >&2 + exit 1 + fi + + - name: Distribute iOS Build To TestFlight + shell: bash + env: + BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }} + TESTFLIGHT_DISTRIBUTE_EXTERNAL: ${{ github.event.inputs.testflight_distribute_external || 'false' }} + TESTFLIGHT_GROUPS: ${{ github.event.inputs.testflight_groups || '' }} + IOS_USES_NON_EXEMPT_ENCRYPTION: ${{ github.event.inputs.ios_uses_non_exempt_encryption || 'false' }} + run: Scripts/ci/distribute-testflight.sh + + publish-sparkle: + name: Publish Sparkle + needs: + - prepare + - sign-apple + if: ${{ github.event.inputs.upload_sparkle == 'true' }} + runs-on: namespace-profile-linux-medium-apple-v2 + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Ensure Nix + shell: bash + run: bash Scripts/ci/ensure-nix.sh + + - name: Authenticate Google WIF + shell: bash + run: nix develop .#ci -c Scripts/ci/google-wif-auth.sh + + - name: Download Signed Apple Artifacts + uses: https://code.forgejo.org/actions/download-artifact@v3 + with: + name: burrow-apple-signed-${{ needs.prepare.outputs.build_number }} + path: publish + + - name: Publish Sparkle Channel + shell: bash + env: + CHANNEL: ${{ needs.prepare.outputs.sparkle_channel }} + SPARKLE_POINT_MAIN: ${{ github.event.inputs.sparkle_point_main || 'true' }} + run: | + set -euo pipefail + if [[ ! -f "publish/sparkle/${CHANNEL}/appcast.xml" ]]; then + echo "::error ::No Sparkle appcast staged for channel ${CHANNEL}" >&2 + find publish -type f -print | sort + exit 1 + fi + nix develop .#ci -c gcloud storage rsync --recursive "publish/sparkle/${CHANNEL}" "gs://${BURROW_RELEASE_GCS_BUCKET}/sparkle/${CHANNEL}" + if [[ "$SPARKLE_POINT_MAIN" == "true" ]]; then + printf '%s\n' "$CHANNEL" > main-channel.txt + nix develop .#ci -c gcloud storage cp main-channel.txt "gs://${BURROW_RELEASE_GCS_BUCKET}/sparkle/main-channel.txt" + nix develop .#ci -c gcloud storage cp "publish/sparkle/${CHANNEL}/appcast.xml" "gs://${BURROW_RELEASE_GCS_BUCKET}/sparkle/appcast.xml" + nix develop .#ci -c gcloud storage rsync --recursive "publish/sparkle/${CHANNEL}" "gs://${BURROW_RELEASE_GCS_BUCKET}/sparkle/default" + fi diff --git a/.forgejo/workflows/apple-ios-distribution-kms-csr.yml b/.forgejo/workflows/apple-ios-distribution-kms-csr.yml new file mode 100644 index 0000000..d9cb614 --- /dev/null +++ b/.forgejo/workflows/apple-ios-distribution-kms-csr.yml @@ -0,0 +1,99 @@ +name: "Apple: iOS Distribution KMS CSR" +run-name: "Apple: iOS Distribution KMS CSR (${{ github.event.inputs.kms_key || 'apple-ios-distribution' }})" + +on: + workflow_dispatch: + inputs: + kms_key: + description: Google KMS key name in the Burrow identity key ring + required: false + default: apple-ios-distribution + kms_version: + description: Google KMS key version + required: false + default: "1" + common_name: + description: CSR common name + required: false + default: Burrow iOS Distribution + email_address: + description: CSR email address + required: false + default: release@burrow.net + +permissions: + contents: read + +concurrency: + group: apple-ios-distribution-kms-csr-${{ github.ref }} + cancel-in-progress: false + +env: + BURROW_GOOGLE_PROJECT_ID: ${{ vars.GOOGLE_PROJECT_ID || 'project-88c23ce9-918a-470a-b33' }} + GOOGLE_CLOUD_PROJECT: ${{ vars.GOOGLE_PROJECT_ID || 'project-88c23ce9-918a-470a-b33' }} + BURROW_GOOGLE_PROJECT_NUMBER: ${{ vars.GOOGLE_PROJECT_NUMBER || '416198671487' }} + BURROW_GOOGLE_WIF_POOL_ID: ${{ vars.BURROW_GOOGLE_WIF_POOL_ID || 'burrow-authentik' }} + BURROW_GOOGLE_WIF_PROVIDER_ID: ${{ vars.BURROW_GOOGLE_WIF_PROVIDER_ID || 'forgejo-runners' }} + BURROW_GOOGLE_WIF_SERVICE_ACCOUNT: ${{ vars.BURROW_GOOGLE_WIF_SERVICE_ACCOUNT || 'burrow-forgejo-runner@project-88c23ce9-918a-470a-b33.iam.gserviceaccount.com' }} + BURROW_AUTHENTIK_WIF_ISSUER: ${{ vars.BURROW_AUTHENTIK_WIF_ISSUER || 'https://auth.burrow.net/application/o/google-cloud/' }} + BURROW_AUTHENTIK_WIF_AUDIENCE: ${{ vars.BURROW_AUTHENTIK_WIF_AUDIENCE || 'google-wif.burrow.net' }} + BURROW_AUTHENTIK_WIF_CLIENT_ID: ${{ vars.BURROW_AUTHENTIK_WIF_CLIENT_ID || 'google-wif.burrow.net' }} + BURROW_AUTHENTIK_WIF_CLIENT_SECRET: ${{ secrets.BURROW_AUTHENTIK_WIF_CLIENT_SECRET }} + BURROW_KMS_LOCATION: global + BURROW_KMS_KEYRING: burrow-identity + +jobs: + csr: + name: Generate CSR + runs-on: [self-hosted, linux, x86_64, burrow-forge] + timeout-minutes: 20 + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Ensure Nix + shell: bash + run: bash Scripts/ci/ensure-nix.sh + + - name: Authenticate Google WIF + shell: bash + run: nix develop .#ci -c Scripts/ci/google-wif-auth.sh + + - name: Generate KMS-backed CSR + shell: bash + run: | + set -euo pipefail + mkdir -p dist/apple-ios-distribution + nix develop .#ci -c Scripts/apple/google-kms-csr.py \ + --kms-key "${{ github.event.inputs.kms_key || 'apple-ios-distribution' }}" \ + --kms-version "${{ github.event.inputs.kms_version || '1' }}" \ + --common-name "${{ github.event.inputs.common_name || 'Burrow iOS Distribution' }}" \ + --email-address "${{ github.event.inputs.email_address || 'release@burrow.net' }}" \ + --output dist/apple-ios-distribution/ios-distribution.certSigningRequest \ + --public-key-output dist/apple-ios-distribution/google-kms-public-key.pem + if command -v openssl >/dev/null 2>&1; then + openssl req -in dist/apple-ios-distribution/ios-distribution.certSigningRequest -noout -verify + fi + cat > dist/apple-ios-distribution/README.txt <<'EOF' + This CSR is backed by a non-exportable Google Cloud KMS key in the Burrow + identity key ring. + + Create an iOS Distribution certificate explicitly through App Store Connect: + + Scripts/apple/create-asc-certificate.mjs \ + --certificate-type IOS_DISTRIBUTION \ + --csr-file ios-distribution.certSigningRequest \ + --out-dir Apple/Certificates + + Keep the returned .cer file with release artifacts. The private key remains in + Google Cloud KMS and is never exported as a p12. + EOF + + - name: Upload CSR Artifact + uses: https://code.forgejo.org/actions/upload-artifact@v3 + with: + name: burrow-ios-distribution-kms-csr + path: dist/apple-ios-distribution diff --git a/.forgejo/workflows/backup-garage-storage.yml b/.forgejo/workflows/backup-garage-storage.yml new file mode 100644 index 0000000..77d08aa --- /dev/null +++ b/.forgejo/workflows/backup-garage-storage.yml @@ -0,0 +1,67 @@ +name: "Backup: Garage Storage" +run-name: "Backup Garage Storage (${{ github.event.inputs.set || 'all' }})" + +on: + schedule: + - cron: "17 9 * * *" + workflow_dispatch: + inputs: + set: + description: "Comma-separated backup set: all, releases, packages, nix-cache" + required: false + default: all + delete_unmatched: + description: Delete destination objects that are missing from Garage + required: false + default: "false" + +permissions: + contents: read + +concurrency: + group: backup-garage-storage-${{ github.event.inputs.set || 'all' }} + cancel-in-progress: false + +jobs: + backup: + name: Mirror Garage To GCS + runs-on: namespace-profile-linux-medium + timeout-minutes: 90 + env: + BURROW_GARAGE_ENDPOINT: ${{ vars.BURROW_GARAGE_ENDPOINT || 'https://objects.burrow.net' }} + BURROW_GARAGE_REGION: ${{ vars.BURROW_GARAGE_REGION || 'garage' }} + BURROW_GARAGE_BACKUP_SET: ${{ github.event.inputs.set || 'all' }} + BURROW_GARAGE_BACKUP_DELETE: ${{ github.event.inputs.delete_unmatched || 'false' }} + BURROW_RELEASE_GARAGE_BUCKET: ${{ vars.BURROW_RELEASE_GARAGE_BUCKET || 'burrow-releases' }} + BURROW_PACKAGE_GARAGE_BUCKET: ${{ vars.BURROW_PACKAGE_GARAGE_BUCKET || 'burrow-packages' }} + BURROW_NIX_CACHE_GARAGE_BUCKET: ${{ vars.BURROW_NIX_CACHE_GARAGE_BUCKET || 'attic' }} + BURROW_RELEASE_GCS_BUCKET: ${{ vars.BURROW_RELEASE_GCS_BUCKET || 'burrow-net-releases' }} + BURROW_PACKAGE_GCS_BUCKET: ${{ vars.BURROW_PACKAGE_GCS_BUCKET || 'burrow-net-packages' }} + BURROW_NIX_CACHE_GCS_BUCKET: ${{ vars.BURROW_NIX_CACHE_GCS_BUCKET || 'burrow-net-nix-cache' }} + AWS_ACCESS_KEY_ID: ${{ secrets.BURROW_GARAGE_BACKUP_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.BURROW_GARAGE_BACKUP_SECRET_ACCESS_KEY }} + BURROW_GOOGLE_PROJECT_ID: ${{ vars.GOOGLE_PROJECT_ID || 'project-88c23ce9-918a-470a-b33' }} + GOOGLE_CLOUD_PROJECT: ${{ vars.GOOGLE_PROJECT_ID || 'project-88c23ce9-918a-470a-b33' }} + BURROW_GOOGLE_PROJECT_NUMBER: ${{ vars.GOOGLE_PROJECT_NUMBER || '416198671487' }} + BURROW_GOOGLE_WIF_POOL_ID: ${{ vars.BURROW_GOOGLE_WIF_POOL_ID || 'burrow-authentik' }} + BURROW_GOOGLE_WIF_PROVIDER_ID: ${{ vars.BURROW_GOOGLE_WIF_PROVIDER_ID || 'forgejo-runners' }} + BURROW_GOOGLE_WIF_SERVICE_ACCOUNT: ${{ vars.BURROW_GOOGLE_WIF_SERVICE_ACCOUNT || 'burrow-forgejo-runner@project-88c23ce9-918a-470a-b33.iam.gserviceaccount.com' }} + BURROW_AUTHENTIK_WIF_ISSUER: ${{ vars.BURROW_AUTHENTIK_WIF_ISSUER || 'https://auth.burrow.net/application/o/google-cloud/' }} + BURROW_AUTHENTIK_WIF_AUDIENCE: ${{ vars.BURROW_AUTHENTIK_WIF_AUDIENCE || 'google-wif.burrow.net' }} + BURROW_AUTHENTIK_WIF_CLIENT_ID: ${{ vars.BURROW_AUTHENTIK_WIF_CLIENT_ID || 'google-wif.burrow.net' }} + BURROW_AUTHENTIK_WIF_CLIENT_SECRET: ${{ secrets.BURROW_AUTHENTIK_WIF_CLIENT_SECRET }} + BURROW_NIX_CACHE_URL: ${{ vars.BURROW_NIX_CACHE_URL || 'https://nix.burrow.net/burrow' }} + BURROW_NIX_CACHE_PUBLIC_KEY: ${{ vars.BURROW_NIX_CACHE_PUBLIC_KEY }} + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Ensure Nix + shell: bash + run: bash Scripts/ci/ensure-nix.sh + + - name: Mirror Garage Buckets To GCS + shell: bash + run: nix develop .#ci -c Scripts/ci/backup-garage-to-gcs.sh diff --git a/.forgejo/workflows/build-android.yml b/.forgejo/workflows/build-android.yml new file mode 100644 index 0000000..0cc61cd --- /dev/null +++ b/.forgejo/workflows/build-android.yml @@ -0,0 +1,74 @@ +name: "Build: Android" +run-name: "Build: Android (${{ github.ref_name }})" + +on: + push: + branches: + - main + paths: + - ".forgejo/workflows/build-android.yml" + - "Android/**" + - "BUILD.bazel" + - "MODULE.bazel" + - "MODULE.bazel.lock" + - "bazel/android/**" + - "Cargo.lock" + - "Cargo.toml" + - "crates/burrow-core/**" + - "crates/burrow-mobile-ffi/**" + - "rust-toolchain.toml" + - "Scripts/ci/nscloud-cache.sh" + pull_request: + paths: + - ".forgejo/workflows/build-android.yml" + - "Android/**" + - "BUILD.bazel" + - "MODULE.bazel" + - "MODULE.bazel.lock" + - "bazel/android/**" + - "Cargo.lock" + - "Cargo.toml" + - "crates/burrow-core/**" + - "crates/burrow-mobile-ffi/**" + - "rust-toolchain.toml" + - "Scripts/ci/nscloud-cache.sh" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: burrow-build-android-${{ github.ref }} + cancel-in-progress: true + +env: + BURROW_NIX_CACHE_URL: ${{ vars.BURROW_NIX_CACHE_URL || 'https://nix.burrow.net/burrow' }} + BURROW_NIX_CACHE_PUBLIC_KEY: ${{ vars.BURROW_NIX_CACHE_PUBLIC_KEY }} + +jobs: + stub: + name: Android Rust Core Stub + runs-on: namespace-profile-linux-medium + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Configure Cache + shell: bash + run: | + set -euo pipefail + bash Scripts/ci/ensure-nix.sh + nix develop .#ci -c Scripts/ci/nscloud-cache.sh bazel + + - name: Build Android Stub Check + shell: bash + run: | + set -euo pipefail + if [[ -n "${BURROW_BAZEL_NSCCACHE_BAZELRC:-}" ]]; then + bazel --bazelrc="$BURROW_BAZEL_NSCCACHE_BAZELRC" build //bazel/android:check_stub_stamp + else + bazel build //bazel/android:check_stub_stamp + fi diff --git a/.forgejo/workflows/build-release.yml b/.forgejo/workflows/build-release.yml new file mode 100644 index 0000000..85c2e76 --- /dev/null +++ b/.forgejo/workflows/build-release.yml @@ -0,0 +1,480 @@ +name: "Build: Release" +run-name: "Build: Release (${{ github.ref_name }})" + +on: + workflow_dispatch: + inputs: + build_number_override: + description: Optional explicit build number + required: false + default: "" + upload_app_store: + description: Trigger downstream App Store Connect upload workflow + required: false + default: "true" + upload_sparkle: + description: Trigger downstream Sparkle publish workflow + required: false + default: "true" + upload_microsoft_store: + description: Trigger downstream Microsoft Store beta upload workflow + required: false + default: "false" + sparkle_point_main: + description: Update Sparkle main channel pointers + required: false + default: "true" + testflight_distribute_external: + description: Distribute to external TestFlight groups + required: false + default: "false" + testflight_groups: + description: Optional comma-separated TestFlight groups for external distribution + required: false + default: "" + ios_uses_non_exempt_encryption: + description: Set true only when the iOS build uses non-exempt encryption + required: false + default: "false" + push: + tags: + - "release/*" + +permissions: + actions: write + contents: write + +concurrency: + group: burrow-build-release-${{ github.ref }} + cancel-in-progress: true + +env: + BURROW_RELEASE_GCS_BUCKET: ${{ vars.BURROW_RELEASE_GCS_BUCKET || 'burrow-net-releases' }} + BURROW_RELEASE_GCS_BACKUP: ${{ vars.BURROW_RELEASE_GCS_BACKUP || 'true' }} + BURROW_RELEASE_GARAGE_BUCKET: ${{ vars.BURROW_RELEASE_GARAGE_BUCKET || 'burrow-releases' }} + BURROW_RELEASE_REQUIRE_GARAGE: ${{ vars.BURROW_RELEASE_REQUIRE_GARAGE || 'true' }} + BURROW_GARAGE_ENDPOINT: ${{ vars.BURROW_GARAGE_ENDPOINT || 'https://objects.burrow.net' }} + BURROW_GARAGE_REGION: ${{ vars.BURROW_GARAGE_REGION || 'garage' }} + AWS_ACCESS_KEY_ID: ${{ secrets.BURROW_GARAGE_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.BURROW_GARAGE_SECRET_ACCESS_KEY }} + BURROW_NIX_CACHE_URL: ${{ vars.BURROW_NIX_CACHE_URL || 'https://nix.burrow.net/burrow' }} + BURROW_NIX_CACHE_PUBLIC_KEY: ${{ vars.BURROW_NIX_CACHE_PUBLIC_KEY }} + BURROW_GOOGLE_PROJECT_ID: ${{ vars.GOOGLE_PROJECT_ID || 'project-88c23ce9-918a-470a-b33' }} + GOOGLE_CLOUD_PROJECT: ${{ vars.GOOGLE_PROJECT_ID || 'project-88c23ce9-918a-470a-b33' }} + BURROW_GOOGLE_PROJECT_NUMBER: ${{ vars.GOOGLE_PROJECT_NUMBER || '416198671487' }} + BURROW_GOOGLE_WIF_POOL_ID: ${{ vars.BURROW_GOOGLE_WIF_POOL_ID || 'burrow-authentik' }} + BURROW_GOOGLE_WIF_PROVIDER_ID: ${{ vars.BURROW_GOOGLE_WIF_PROVIDER_ID || 'forgejo-runners' }} + BURROW_GOOGLE_WIF_SERVICE_ACCOUNT: ${{ vars.BURROW_GOOGLE_WIF_SERVICE_ACCOUNT || 'burrow-forgejo-runner@project-88c23ce9-918a-470a-b33.iam.gserviceaccount.com' }} + BURROW_AUTHENTIK_WIF_ISSUER: ${{ vars.BURROW_AUTHENTIK_WIF_ISSUER || 'https://auth.burrow.net/application/o/google-cloud/' }} + BURROW_AUTHENTIK_WIF_AUDIENCE: ${{ vars.BURROW_AUTHENTIK_WIF_AUDIENCE || 'google-wif.burrow.net' }} + BURROW_AUTHENTIK_WIF_CLIENT_ID: ${{ vars.BURROW_AUTHENTIK_WIF_CLIENT_ID || 'google-wif.burrow.net' }} + BURROW_AUTHENTIK_WIF_CLIENT_SECRET: ${{ secrets.BURROW_AUTHENTIK_WIF_CLIENT_SECRET }} + BURROW_APPLE_BUNDLE_ID: ${{ vars.BURROW_APPLE_BUNDLE_ID || 'net.burrow.app' }} + BURROW_APPLE_NETWORK_EXTENSION_BUNDLE_ID: ${{ vars.BURROW_APPLE_NETWORK_EXTENSION_BUNDLE_ID || 'net.burrow.app.network' }} + BURROW_IOS_DISTRIBUTION_CERTIFICATE_ID: ${{ vars.BURROW_IOS_DISTRIBUTION_CERTIFICATE_ID || '3G42677598' }} + BURROW_DEVELOPER_ID_CERTIFICATE_ID: ${{ vars.BURROW_DEVELOPER_ID_CERTIFICATE_ID || '9JKN6HXBHC' }} + BURROW_APPLE_CREATE_MISSING_BUNDLE_IDS: ${{ vars.BURROW_APPLE_CREATE_MISSING_BUNDLE_IDS || 'false' }} + BURROW_APPLE_ENABLE_CAPABILITIES: ${{ vars.BURROW_APPLE_ENABLE_CAPABILITIES || 'false' }} + BURROW_APPLE_SIGNING_MODE: ${{ vars.BURROW_APPLE_SIGNING_MODE || 'google-kms-staged' }} + BURROW_NOTARIZE_MACOS: ${{ vars.BURROW_NOTARIZE_MACOS || 'true' }} + BURROW_SPARKLE_SIGN_WITH_KMS: ${{ vars.BURROW_SPARKLE_SIGN_WITH_KMS || 'true' }} + BURROW_SPARKLE_KMS_KEY: ${{ vars.BURROW_SPARKLE_KMS_KEY || 'sparkle-ed25519' }} + BURROW_SPARKLE_KMS_VERSION: ${{ vars.BURROW_SPARKLE_KMS_VERSION || '1' }} + BURROW_SPARKLE_FEED_URL: ${{ vars.BURROW_SPARKLE_FEED_URL || 'https://releases.burrow.net/sparkle/appcast.xml' }} + BURROW_SPARKLE_PUBLIC_ED_KEY: ${{ vars.BURROW_SPARKLE_PUBLIC_ED_KEY || 'uugZuJeqvvKd91NZ6F1Fv2cQenUbIG/ZW3L9MuaEz30=' }} + BURROW_VERSION_REQUIRE_REMOTE: "1" + +jobs: + prepare: + name: Prepare + runs-on: namespace-profile-linux-medium + outputs: + do_release: ${{ steps.plan.outputs.do_release }} + build_number: ${{ steps.plan.outputs.build_number }} + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Fetch Build Tags + shell: bash + run: git fetch --force --prune origin "+refs/tags/builds/*:refs/tags/builds/*" + + - name: Compute Release Plan + id: plan + shell: bash + env: + BURROW_BUILD_NUMBER_OVERRIDE: ${{ github.event.inputs.build_number_override || '' }} + run: | + set -euo pipefail + status="$(Scripts/version.sh status)" + if [[ "$status" == "clean" ]]; then + echo "do_release=false" >> "$GITHUB_OUTPUT" + echo "build_number=" >> "$GITHUB_OUTPUT" + echo "No unreleased changes." + exit 0 + fi + build_number="$(Scripts/version.sh pre-increment)" + echo "do_release=true" >> "$GITHUB_OUTPUT" + echo "build_number=${build_number}" >> "$GITHUB_OUTPUT" + + build-linux: + name: Build (Linux) + needs: prepare + if: ${{ needs.prepare.outputs.do_release == 'true' }} + runs-on: namespace-profile-linux-medium + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Build Linux Release + shell: bash + env: + BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }} + run: | + set -euo pipefail + bash Scripts/ci/ensure-nix.sh + nix develop .#ci -c Scripts/ci/nscloud-cache.sh nix + nix develop .#ci -c Scripts/ci/package-release-artifacts.sh linux + + - name: Upload Linux Artifacts + uses: https://code.forgejo.org/actions/upload-artifact@v3 + with: + name: burrow-linux-${{ needs.prepare.outputs.build_number }} + path: dist/builds/${{ needs.prepare.outputs.build_number }}/linux/* + if-no-files-found: error + + - name: Upload Linux Artifacts To Release Storage + shell: bash + env: + BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }} + run: | + set -euo pipefail + bash Scripts/ci/ensure-nix.sh + nix develop .#ci -c Scripts/ci/upload-release-storage.sh + + build-windows: + name: Build (Windows Stub) + needs: prepare + if: ${{ needs.prepare.outputs.do_release == 'true' }} + runs-on: namespace-profile-windows-large + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Build Rust Stub + shell: pwsh + env: + BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }} + run: | + if (-not (Get-Command cargo -ErrorAction SilentlyContinue)) { + Invoke-WebRequest -Uri "https://win.rustup.rs" -OutFile "rustup-init.exe" + .\rustup-init.exe -y --profile minimal --default-toolchain stable + $env:Path = "$env:USERPROFILE\.cargo\bin;$env:Path" + } + cargo build --locked --release -p burrow-windows-stub + New-Item -ItemType Directory -Force -Path "dist/builds/$env:BUILD_NUMBER/windows/burrow-$env:BUILD_NUMBER-x86_64-pc-windows-msvc" | Out-Null + Copy-Item "target/release/burrow.exe" "dist/builds/$env:BUILD_NUMBER/windows/burrow-$env:BUILD_NUMBER-x86_64-pc-windows-msvc/burrow.exe" + Copy-Item "README.md" "dist/builds/$env:BUILD_NUMBER/windows/burrow-$env:BUILD_NUMBER-x86_64-pc-windows-msvc/README.md" + Compress-Archive -Path "dist/builds/$env:BUILD_NUMBER/windows/burrow-$env:BUILD_NUMBER-x86_64-pc-windows-msvc" -DestinationPath "dist/builds/$env:BUILD_NUMBER/windows/burrow-$env:BUILD_NUMBER-x86_64-pc-windows-msvc.zip" -Force + Get-FileHash "dist/builds/$env:BUILD_NUMBER/windows/burrow-$env:BUILD_NUMBER-x86_64-pc-windows-msvc.zip" -Algorithm SHA256 | ForEach-Object { "$($_.Hash.ToLower()) burrow-$env:BUILD_NUMBER-x86_64-pc-windows-msvc.zip" } | Set-Content "dist/builds/$env:BUILD_NUMBER/windows/burrow-$env:BUILD_NUMBER-x86_64-pc-windows-msvc.zip.sha256" + + - name: Upload Windows Artifacts + uses: https://code.forgejo.org/actions/upload-artifact@v3 + with: + name: burrow-windows-${{ needs.prepare.outputs.build_number }} + path: dist/builds/${{ needs.prepare.outputs.build_number }}/windows/* + if-no-files-found: error + + build-apple: + name: Build (Apple ${{ matrix.platform_name }}) + needs: prepare + if: ${{ needs.prepare.outputs.do_release == 'true' }} + runs-on: namespace-profile-macos-large + strategy: + fail-fast: false + max-parallel: 2 + matrix: + include: + - platform: ios + platform_name: iOS + bazel_target: //bazel/apple:release_ios_stamp + - platform: macos + platform_name: macOS + bazel_target: //bazel/apple:release_macos_stamp + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + submodules: recursive + + - name: Select Apple SDK + shell: bash + run: | + set -euo pipefail + if ! command -v xcrun >/dev/null 2>&1; then + echo "::error ::xcrun is required for Apple release builds" >&2 + exit 1 + fi + xcrun --find swiftc + xcrun --sdk macosx --show-sdk-path + xcrun --sdk iphoneos --show-sdk-path + xcrun --sdk iphonesimulator --show-sdk-path + + - name: Prepare Rust Apple Targets + shell: bash + env: + PLATFORM: ${{ matrix.platform }} + run: | + set -euo pipefail + if ! command -v rustup >/dev/null 2>&1; then + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable + export PATH="$HOME/.cargo/bin:$PATH" + fi + case "$PLATFORM" in + ios) + rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios + ;; + macos) + rustup target add aarch64-apple-darwin x86_64-apple-darwin + ;; + *) + echo "::error ::unsupported Apple platform ${PLATFORM}" >&2 + exit 1 + ;; + esac + + - name: Bootstrap Runner Environment + shell: bash + run: | + set -euo pipefail + runner_home="${RUNNER_HOME:-}" + if [[ -z "$runner_home" ]]; then + runner_home="$(python3 -c 'import os,pwd; print(pwd.getpwuid(os.getuid()).pw_dir)' 2>/dev/null || true)" + if [[ -z "$runner_home" ]]; then + runner_home="$PWD/.home" + fi + fi + mkdir -p "$runner_home" "$PWD/.tmp" + { + echo "HOME=$runner_home" + echo "XDG_CACHE_HOME=$runner_home/.cache" + echo "XDG_CONFIG_HOME=$runner_home/.config" + echo "XDG_DATA_HOME=$runner_home/.local/share" + echo "TMPDIR=$PWD/.tmp" + echo "TMP=$PWD/.tmp" + } >> "$GITHUB_ENV" + + - name: Ensure Nix + shell: bash + run: bash Scripts/ci/ensure-nix.sh + + - name: Namespace Cache + shell: bash + run: | + set -euo pipefail + NIX_BIN="$(bash Scripts/ci/resolve-nix-bin.sh)" + "$NIX_BIN" develop .#ci --command bash Scripts/ci/nscloud-cache.sh bazel + + - name: Configure Age + id: age_apple + continue-on-error: true + shell: bash + env: + AGE_FORGE_SSH_KEY: ${{ secrets.AGE_FORGE_SSH_KEY }} + run: Scripts/resolve-age-identity.sh >> "$GITHUB_ENV" + + - name: Decrypt Release Secrets + if: ${{ steps.age_apple.outcome == 'success' }} + uses: ./.forgejo/actions/decrypt-release-secrets + + - name: Sync Apple Provisioning Profiles + shell: bash + env: + PLATFORM: ${{ matrix.platform }} + run: | + set -euo pipefail + NIX_BIN="$(bash Scripts/ci/resolve-nix-bin.sh)" + "$NIX_BIN" develop .#ci --command Scripts/ci/sync-apple-provisioning-profiles.sh "$PLATFORM" + + - name: Install Apple Signing Assets + shell: bash + run: Scripts/ci/install-apple-signing-assets.sh + + - name: Build Apple Release + shell: bash + env: + BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }} + PLATFORM: ${{ matrix.platform }} + UPLOAD_APP_STORE: ${{ github.event.inputs.upload_app_store || 'true' }} + UPLOAD_SPARKLE: ${{ github.event.inputs.upload_sparkle || 'true' }} + SPARKLE_CHANNEL: build-${{ needs.prepare.outputs.build_number }} + run: | + set -euo pipefail + require_signing=false + if [[ "$UPLOAD_APP_STORE" == "true" && "$PLATFORM" == "ios" ]]; then + require_signing=true + fi + if [[ "$UPLOAD_SPARKLE" == "true" && "$PLATFORM" == "macos" ]]; then + require_signing=true + fi + + bazel_args=() + if [[ -n "${BURROW_BAZEL_NSCCACHE_BAZELRC:-}" && -f "${BURROW_BAZEL_NSCCACHE_BAZELRC:-}" ]]; then + bazel_args+=("--bazelrc=${BURROW_BAZEL_NSCCACHE_BAZELRC}") + fi + + NIX_BIN="$(bash Scripts/ci/resolve-nix-bin.sh)" + ci_path="$("$NIX_BIN" develop .#ci --command bash -lc 'printf "%s" "$PATH"')" + ci_protoc="$("$NIX_BIN" develop .#ci --command bash -lc 'command -v protoc')" + "$NIX_BIN" develop .#ci --command bazel "${bazel_args[@]}" build \ + --verbose_failures \ + --show_timestamps \ + --experimental_ui_max_stdouterr_bytes=16777216 \ + --action_env=PATH="$ci_path" \ + --action_env=PROTOC="$ci_protoc" \ + --action_env=BUILD_WORKSPACE_DIRECTORY="$PWD" \ + --action_env=BUILD_NUMBER="$BUILD_NUMBER" \ + --action_env=BURROW_RELEASE_OUT="$PWD/dist/builds/$BUILD_NUMBER" \ + --action_env=BURROW_APPLE_SIGNING_READY="${BURROW_APPLE_SIGNING_READY:-0}" \ + --action_env=BURROW_APPLE_SIGNING_MODE="${BURROW_APPLE_SIGNING_MODE:-keychain}" \ + --action_env=BURROW_APPLE_REQUIRE_SIGNING="$require_signing" \ + --action_env=BURROW_APPLE_BUNDLE_ID="${BURROW_APPLE_BUNDLE_ID:-}" \ + --action_env=BURROW_APPLE_NETWORK_EXTENSION_BUNDLE_ID="${BURROW_APPLE_NETWORK_EXTENSION_BUNDLE_ID:-}" \ + --action_env=BURROW_APPLE_KEYCHAIN_PATH="${BURROW_APPLE_KEYCHAIN_PATH:-}" \ + --action_env=BURROW_NOTARIZE_MACOS="${BURROW_NOTARIZE_MACOS:-false}" \ + --action_env=BURROW_SPARKLE_SIGN_WITH_KMS="${BURROW_SPARKLE_SIGN_WITH_KMS:-false}" \ + --action_env=BURROW_SPARKLE_KMS_KEY="${BURROW_SPARKLE_KMS_KEY:-sparkle-ed25519}" \ + --action_env=BURROW_SPARKLE_KMS_VERSION="${BURROW_SPARKLE_KMS_VERSION:-1}" \ + --action_env=BURROW_SPARKLE_FEED_URL="${BURROW_SPARKLE_FEED_URL:-https://releases.burrow.net/sparkle/appcast.xml}" \ + --action_env=BURROW_SPARKLE_PUBLIC_ED_KEY="${BURROW_SPARKLE_PUBLIC_ED_KEY:-}" \ + --action_env=GOOGLE_CLOUD_PROJECT="${GOOGLE_CLOUD_PROJECT:-}" \ + --action_env=ASC_API_KEY_ID="${ASC_API_KEY_ID:-}" \ + --action_env=ASC_API_ISSUER_ID="${ASC_API_ISSUER_ID:-}" \ + --action_env=ASC_API_KEY_PATH="${ASC_API_KEY_PATH:-}" \ + --action_env=SPARKLE_CHANNEL="$SPARKLE_CHANNEL" \ + --action_env=HOME="$HOME" \ + --action_env=XDG_CACHE_HOME="$XDG_CACHE_HOME" \ + "${{ matrix.bazel_target }}" + + - name: Upload Apple Artifacts + uses: https://code.forgejo.org/actions/upload-artifact@v3 + with: + name: burrow-apple-${{ matrix.platform }}-${{ needs.prepare.outputs.build_number }} + path: | + dist/builds/${{ needs.prepare.outputs.build_number }}/apple/* + dist/builds/${{ needs.prepare.outputs.build_number }}/sparkle/** + if-no-files-found: error + + - name: Upload Apple Artifacts To Release Storage + shell: bash + env: + BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }} + run: | + set -euo pipefail + bash Scripts/ci/ensure-nix.sh + nix develop .#ci -c Scripts/ci/upload-release-storage.sh + + publish: + name: Publish (Forgejo) + needs: + - prepare + - build-linux + - build-windows + - build-apple + if: ${{ always() && needs.prepare.outputs.do_release == 'true' }} + runs-on: namespace-profile-linux-medium + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Download Artifacts + uses: https://code.forgejo.org/actions/download-artifact@v3 + with: + path: dist/downloaded + + - name: Prepare Release Assets + shell: bash + env: + BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }} + run: | + set -euo pipefail + mkdir -p dist + mkdir -p "dist/builds/${BUILD_NUMBER}/windows" + find dist/downloaded -path '*/burrow-windows-*/*' -type f -exec cp {} "dist/builds/${BUILD_NUMBER}/windows/" \; + find dist/downloaded -type f \( -name '*.tar.gz' -o -name '*.zip' -o -name '*.sha256' -o -name '*.ipa' -o -name '*.pkg' -o -name '*.dmg' -o -name 'README*.txt' \) -exec cp {} dist/ \; + rm -rf dist/downloaded + find dist -maxdepth 1 -type f -print | sort + + - name: Upload Windows Artifacts To Release Storage + shell: bash + env: + BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }} + run: | + set -euo pipefail + if ! find "dist/builds/${BUILD_NUMBER}/windows" -type f -print -quit | grep -q .; then + echo "::warning ::No Windows artifacts staged for release storage upload." + exit 0 + fi + bash Scripts/ci/ensure-nix.sh + nix develop .#ci -c Scripts/ci/upload-release-storage.sh + + - name: Tag Build + shell: bash + env: + BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }} + run: | + set -euo pipefail + tag="builds/${BUILD_NUMBER}" + head_commit="$(git rev-parse HEAD)" + remote_commit="$(git ls-remote --tags --refs origin "refs/tags/${tag}" | awk 'NR==1 { print $1 }')" + if [[ -n "$remote_commit" && "$remote_commit" != "$head_commit" ]]; then + echo "::error ::Remote tag ${tag} already points at ${remote_commit}, not ${head_commit}" >&2 + exit 1 + fi + git tag -f "$tag" "$head_commit" + git push --quiet --no-verify origin "refs/tags/${tag}:refs/tags/${tag}" + + - name: Publish Forgejo Release + shell: bash + env: + RELEASE_TAG: builds/${{ needs.prepare.outputs.build_number }} + API_URL: ${{ github.api_url }} + REPOSITORY: ${{ github.repository }} + TOKEN: ${{ github.token }} + run: Scripts/ci/publish-forgejo-release.sh + + - name: Dispatch Store Uploads + shell: bash + env: + GITHUB_TOKEN: ${{ github.token }} + BUILD_NUMBER: ${{ needs.prepare.outputs.build_number }} + UPLOAD_APP_STORE: ${{ github.event.inputs.upload_app_store || 'true' }} + UPLOAD_SPARKLE: ${{ github.event.inputs.upload_sparkle || 'true' }} + UPLOAD_MICROSOFT_STORE: ${{ github.event.inputs.upload_microsoft_store || 'false' }} + SPARKLE_POINT_MAIN: ${{ github.event.inputs.sparkle_point_main || 'true' }} + TESTFLIGHT_DISTRIBUTE_EXTERNAL: ${{ github.event.inputs.testflight_distribute_external || 'false' }} + TESTFLIGHT_GROUPS: ${{ github.event.inputs.testflight_groups || '' }} + IOS_USES_NON_EXEMPT_ENCRYPTION: ${{ github.event.inputs.ios_uses_non_exempt_encryption || 'false' }} + run: | + set -euo pipefail + inputs="$(python3 -c 'import json, os; print(json.dumps({"build_number":os.environ["BUILD_NUMBER"],"upload_app_store":os.environ["UPLOAD_APP_STORE"],"upload_sparkle":os.environ["UPLOAD_SPARKLE"],"upload_microsoft_store":os.environ["UPLOAD_MICROSOFT_STORE"],"sparkle_point_main":os.environ["SPARKLE_POINT_MAIN"],"testflight_distribute_external":os.environ["TESTFLIGHT_DISTRIBUTE_EXTERNAL"],"testflight_groups":os.environ["TESTFLIGHT_GROUPS"],"ios_uses_non_exempt_encryption":os.environ["IOS_USES_NON_EXEMPT_ENCRYPTION"]}))')" + curl -fsS \ + -X POST \ + -H "Authorization: token ${GITHUB_TOKEN}" \ + -H "Content-Type: application/json" \ + -d "{\"ref\":\"main\",\"inputs\":${inputs}}" \ + "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/workflows/publish-store-uploads.yml/dispatches" diff --git a/.forgejo/workflows/distribute-testflight.yml b/.forgejo/workflows/distribute-testflight.yml new file mode 100644 index 0000000..8962c9a --- /dev/null +++ b/.forgejo/workflows/distribute-testflight.yml @@ -0,0 +1,71 @@ +name: "Apple: Distribute TestFlight" +run-name: "Apple: Distribute TestFlight (Build ${{ inputs.build_number }})" + +on: + workflow_dispatch: + inputs: + build_number: + description: Already-uploaded App Store Connect build number + required: true + testflight_distribute_external: + description: Distribute to external TestFlight groups + required: false + default: "false" + testflight_groups: + description: Optional comma-separated TestFlight groups + required: false + default: "" + ios_uses_non_exempt_encryption: + description: Set true only when the iOS build uses non-exempt encryption + required: false + default: "false" + +permissions: + contents: read + +concurrency: + group: burrow-distribute-testflight-${{ inputs.build_number }} + cancel-in-progress: true + +env: + BURROW_NIX_CACHE_URL: ${{ vars.BURROW_NIX_CACHE_URL || 'https://nix.burrow.net/burrow' }} + BURROW_NIX_CACHE_PUBLIC_KEY: ${{ vars.BURROW_NIX_CACHE_PUBLIC_KEY }} + BURROW_APPLE_BUNDLE_ID: ${{ vars.BURROW_APPLE_BUNDLE_ID || 'net.burrow.app' }} + TESTFLIGHT_WAIT_PROCESSING_TIMEOUT_SECONDS: ${{ vars.TESTFLIGHT_WAIT_PROCESSING_TIMEOUT_SECONDS || '7200' }} + +jobs: + distribute-ios-testflight: + name: Distribute (TestFlight iOS Testers) + runs-on: namespace-profile-linux-testflight + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Ensure Nix + shell: bash + run: bash Scripts/ci/ensure-nix.sh + + - name: Configure Age + shell: bash + env: + AGE_FORGE_SSH_KEY: ${{ secrets.AGE_FORGE_SSH_KEY }} + run: Scripts/resolve-age-identity.sh >> "$GITHUB_ENV" + + - name: Decrypt Release Secrets + uses: ./.forgejo/actions/decrypt-release-secrets + + - name: Validate App Store Credentials + shell: bash + run: Scripts/ci/check-release-config.sh app-store + + - name: Distribute iOS Build To TestFlight + shell: bash + env: + BUILD_NUMBER: ${{ inputs.build_number }} + TESTFLIGHT_DISTRIBUTE_EXTERNAL: ${{ inputs.testflight_distribute_external || 'false' }} + TESTFLIGHT_GROUPS: ${{ inputs.testflight_groups || '' }} + IOS_USES_NON_EXEMPT_ENCRYPTION: ${{ inputs.ios_uses_non_exempt_encryption || 'false' }} + run: Scripts/ci/distribute-testflight.sh diff --git a/.forgejo/workflows/infra-opentofu.yml b/.forgejo/workflows/infra-opentofu.yml new file mode 100644 index 0000000..dad4f01 --- /dev/null +++ b/.forgejo/workflows/infra-opentofu.yml @@ -0,0 +1,237 @@ +name: "Infra: OpenTofu" +run-name: "Infra: OpenTofu (${{ github.event.inputs.stack || 'grafana' }} ${{ github.event.inputs.mode || 'validate' }})" + +on: + push: + branches: + - main + paths: + - ".forgejo/workflows/infra-opentofu.yml" + - "Scripts/grafana-tofu.sh" + - "Scripts/identity-tofu.sh" + - "Scripts/openbao-tofu.sh" + - "Scripts/releases-tofu.sh" + - "infra/grafana/**" + - "infra/identity/**" + - "infra/openbao/**" + - "infra/releases/**" + - "services/grafana/**" + workflow_dispatch: + inputs: + stack: + description: OpenTofu stack to run + required: true + default: grafana + type: choice + options: + - grafana + - identity + - openbao + - releases + mode: + description: OpenTofu mode + required: true + default: plan + type: choice + options: + - fmt + - validate + - plan + - apply + - import + apply_confirmation: + description: Type apply-burrow--tofu to run apply + required: false + default: "" + import_address: + description: OpenTofu resource address for import mode + required: false + default: "" + import_id: + description: Provider import id for import mode + required: false + default: "" + +permissions: + contents: read + +concurrency: + group: infra-opentofu-${{ github.ref }}-${{ github.event.inputs.stack || 'grafana' }} + cancel-in-progress: false + +jobs: + opentofu: + name: OpenTofu (${{ github.event.inputs.stack || 'grafana' }}) + runs-on: [self-hosted, linux, x86_64, burrow-forge] + timeout-minutes: 30 + env: + MODE: ${{ github.event.inputs.mode || 'validate' }} + STACK: ${{ github.event.inputs.stack || 'grafana' }} + APPLY_CONFIRMATION: ${{ github.event.inputs.apply_confirmation || '' }} + IMPORT_ADDRESS: ${{ github.event.inputs.import_address || '' }} + IMPORT_ID: ${{ github.event.inputs.import_id || '' }} + TF_INPUT: "false" + TF_IN_AUTOMATION: "true" + TF_VAR_grafana_url: ${{ vars.GRAFANA_URL || 'https://graphs.burrow.net' }} + TF_VAR_google_project_id: ${{ vars.GOOGLE_PROJECT_ID || 'project-88c23ce9-918a-470a-b33' }} + TF_VAR_google_project_number: ${{ vars.GOOGLE_PROJECT_NUMBER || '416198671487' }} + TF_VAR_google_runner_service_account_email: ${{ vars.BURROW_GOOGLE_WIF_SERVICE_ACCOUNT || 'burrow-forgejo-runner@project-88c23ce9-918a-470a-b33.iam.gserviceaccount.com' }} + TF_VAR_google_wif_runner_client_id: ${{ vars.BURROW_AUTHENTIK_WIF_CLIENT_ID || 'google-wif.burrow.net' }} + TF_VAR_google_release_bucket_name: ${{ vars.BURROW_RELEASE_GCS_BUCKET || 'burrow-net-releases' }} + TF_VAR_google_package_bucket_name: ${{ vars.BURROW_PACKAGE_GCS_BUCKET || 'burrow-net-packages' }} + TF_VAR_google_nix_cache_bucket_name: ${{ vars.BURROW_NIX_CACHE_GCS_BUCKET || 'burrow-net-nix-cache' }} + TF_VAR_google_nix_cache_public_read: ${{ vars.BURROW_NIX_CACHE_GCS_PUBLIC_READ || 'false' }} + TF_VAR_google_storage_location: ${{ vars.BURROW_GCS_LOCATION || 'US' }} + BURROW_GOOGLE_PROJECT_ID: ${{ vars.GOOGLE_PROJECT_ID || 'project-88c23ce9-918a-470a-b33' }} + GOOGLE_CLOUD_PROJECT: ${{ vars.GOOGLE_PROJECT_ID || 'project-88c23ce9-918a-470a-b33' }} + BURROW_GOOGLE_PROJECT_NUMBER: ${{ vars.GOOGLE_PROJECT_NUMBER || '416198671487' }} + BURROW_GOOGLE_WIF_POOL_ID: ${{ vars.BURROW_GOOGLE_WIF_POOL_ID || 'burrow-authentik' }} + BURROW_GOOGLE_WIF_PROVIDER_ID: ${{ vars.BURROW_GOOGLE_WIF_PROVIDER_ID || 'forgejo-runners' }} + BURROW_GOOGLE_WIF_SERVICE_ACCOUNT: ${{ vars.BURROW_GOOGLE_WIF_SERVICE_ACCOUNT || 'burrow-forgejo-runner@project-88c23ce9-918a-470a-b33.iam.gserviceaccount.com' }} + BURROW_AUTHENTIK_WIF_ISSUER: ${{ vars.BURROW_AUTHENTIK_WIF_ISSUER || 'https://auth.burrow.net/application/o/google-cloud/' }} + BURROW_AUTHENTIK_WIF_AUDIENCE: ${{ vars.BURROW_AUTHENTIK_WIF_AUDIENCE || 'google-wif.burrow.net' }} + BURROW_AUTHENTIK_WIF_CLIENT_ID: ${{ vars.BURROW_AUTHENTIK_WIF_CLIENT_ID || 'google-wif.burrow.net' }} + BURROW_AUTHENTIK_WIF_CLIENT_SECRET: ${{ secrets.BURROW_AUTHENTIK_WIF_CLIENT_SECRET }} + BURROW_NIX_CACHE_URL: ${{ vars.BURROW_NIX_CACHE_URL || 'https://nix.burrow.net/burrow' }} + BURROW_NIX_CACHE_PUBLIC_KEY: ${{ vars.BURROW_NIX_CACHE_PUBLIC_KEY }} + OPENTOFU_STATE_BUCKET: ${{ vars.OPENTOFU_STATE_BUCKET || '' }} + OPENTOFU_STATE_REGION: ${{ vars.OPENTOFU_STATE_REGION || vars.AWS_REGION || 'us-west-2' }} + OPENTOFU_STATE_DYNAMODB_TABLE: ${{ vars.OPENTOFU_STATE_DYNAMODB_TABLE || '' }} + steps: + - name: Checkout + shell: bash + run: | + set -euo pipefail + repo_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" + if [ ! -d .git ]; then + git init . + fi + if git remote get-url origin >/dev/null 2>&1; then + git remote set-url origin "${repo_url}" + else + git remote add origin "${repo_url}" + fi + git fetch --force --tags origin "${GITHUB_SHA}" + git checkout --force --detach FETCH_HEAD + git clean -ffdqx + + - name: Validate Request + shell: bash + run: | + set -euo pipefail + + case "$STACK" in + grafana|identity|openbao|releases) ;; + *) + echo "::error ::Unsupported OpenTofu stack: $STACK" >&2 + exit 2 + ;; + esac + + case "$MODE" in + fmt|validate|plan|apply|import) ;; + *) + echo "::error ::Unsupported OpenTofu mode: $MODE" >&2 + exit 2 + ;; + esac + + if [[ "${GITHUB_EVENT_NAME}" != "workflow_dispatch" && "$MODE" != "validate" ]]; then + echo "::error ::Non-manual runs may only validate." >&2 + exit 2 + fi + + if [[ "$MODE" == "apply" && "$APPLY_CONFIRMATION" != "apply-burrow-${STACK}-tofu" ]]; then + echo "::error ::apply_confirmation must be exactly apply-burrow-${STACK}-tofu." >&2 + exit 1 + fi + + if [[ "$MODE" == "import" && ( -z "$IMPORT_ADDRESS" || -z "$IMPORT_ID" ) ]]; then + echo "::error ::import mode requires import_address and import_id." >&2 + exit 2 + fi + + - name: Configure Age + if: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.mode == 'plan' || github.event.inputs.mode == 'apply' || github.event.inputs.mode == 'import') }} + shell: bash + env: + AGE_FORGE_SSH_KEY: ${{ secrets.AGE_FORGE_SSH_KEY }} + run: Scripts/resolve-age-identity.sh >> "$GITHUB_ENV" + + - name: Configure Grafana Provider Auth + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.stack == 'grafana' && (github.event.inputs.mode == 'plan' || github.event.inputs.mode == 'apply' || github.event.inputs.mode == 'import') }} + shell: bash + run: | + set -euo pipefail + + : "${AGE_IDENTITY_PATH:?AGE_IDENTITY_PATH is required}" + agenix="$(nix build --no-link .#agenix --print-out-paths | tail -n1)/bin/agenix" + password="$("$agenix" --identity "$AGE_IDENTITY_PATH" --decrypt secrets/infra/grafana-admin-password.age | tr -d '\r')" + + echo "::add-mask::${password}" + { + echo "TF_VAR_grafana_auth<> "$GITHUB_ENV" + + - name: Configure OpenTofu Backend + shell: bash + run: | + set -euo pipefail + + stack_dir="infra/${STACK}" + rm -f "${stack_dir}/backend.hcl" + if [[ -n "$OPENTOFU_STATE_BUCKET" ]]; then + { + printf 'bucket = "%s"\n' "$OPENTOFU_STATE_BUCKET" + printf 'key = "%s"\n' "${STACK}/${STACK}.tfstate" + printf 'region = "%s"\n' "$OPENTOFU_STATE_REGION" + printf 'encrypt = true\n' + if [[ -n "$OPENTOFU_STATE_DYNAMODB_TABLE" ]]; then + printf 'dynamodb_table = "%s"\n' "$OPENTOFU_STATE_DYNAMODB_TABLE" + fi + } > "${stack_dir}/backend.hcl" + elif [[ "$MODE" == "apply" || "$MODE" == "import" ]]; then + echo "::error ::OPENTOFU_STATE_BUCKET is required for apply/import." >&2 + exit 1 + fi + + - name: Authenticate Google WIF + if: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.stack == 'identity' || github.event.inputs.stack == 'releases') && (github.event.inputs.mode == 'plan' || github.event.inputs.mode == 'apply' || github.event.inputs.mode == 'import') }} + shell: bash + run: | + set -euo pipefail + nix develop .#ci -c Scripts/ci/google-wif-auth.sh + + - name: Run OpenTofu + shell: bash + run: | + set -euo pipefail + + stack_script="Scripts/${STACK}-tofu.sh" + case "$MODE" in + fmt) + nix develop .#ci -c tofu -chdir="infra/${STACK}" fmt -check + ;; + validate) + "$stack_script" init -backend=false + "$stack_script" validate + ;; + plan) + if [[ -f "infra/${STACK}/backend.hcl" ]]; then + "$stack_script" init -backend-config=backend.hcl + else + "$stack_script" init -backend=false + fi + "$stack_script" plan + ;; + apply) + "$stack_script" init -backend-config=backend.hcl + "$stack_script" apply -auto-approve + ;; + import) + "$stack_script" init -backend-config=backend.hcl + "$stack_script" import "$IMPORT_ADDRESS" "$IMPORT_ID" + ;; + esac diff --git a/.forgejo/workflows/publish-nix-cache.yml b/.forgejo/workflows/publish-nix-cache.yml new file mode 100644 index 0000000..5ff5d27 --- /dev/null +++ b/.forgejo/workflows/publish-nix-cache.yml @@ -0,0 +1,63 @@ +name: "Cache: Publish Nix" +run-name: "Publish Nix Cache (${{ github.ref_name }})" + +on: + push: + branches: + - main + paths: + - ".forgejo/workflows/publish-nix-cache.yml" + - "Cargo.lock" + - "Cargo.toml" + - "flake.lock" + - "flake.nix" + - "crates/**" + - "services/forgejo-nsc/**" + - "nixos/**" + - "Scripts/ci/ensure-nix.sh" + - "Scripts/ci/publish-nix-cache.sh" + workflow_dispatch: + inputs: + attrs: + description: Space-separated flake attrs to build and push + required: false + default: ".#burrow .#forgejo-nsc-dispatcher .#forgejo-nsc-autoscaler" + required: + description: Fail when the cache push token is missing + required: false + default: "false" + +permissions: + contents: read + +concurrency: + group: publish-nix-cache-${{ github.ref }} + cancel-in-progress: true + +jobs: + publish: + name: Publish Nix Cache + runs-on: namespace-profile-linux-medium + timeout-minutes: 45 + env: + BURROW_NIX_CACHE_SERVER_NAME: ${{ vars.BURROW_NIX_CACHE_SERVER_NAME || 'burrow' }} + BURROW_NIX_CACHE_SERVER_URL: ${{ vars.BURROW_NIX_CACHE_SERVER_URL || 'https://nix.burrow.net' }} + BURROW_NIX_CACHE_NAME: ${{ vars.BURROW_NIX_CACHE_NAME || 'burrow' }} + BURROW_NIX_CACHE_URL: ${{ vars.BURROW_NIX_CACHE_URL || 'https://nix.burrow.net/burrow' }} + BURROW_NIX_CACHE_PUBLIC_KEY: ${{ vars.BURROW_NIX_CACHE_PUBLIC_KEY }} + BURROW_NIX_CACHE_PUSH_TOKEN: ${{ secrets.BURROW_NIX_CACHE_PUSH_TOKEN }} + BURROW_NIX_CACHE_ATTRS: ${{ github.event.inputs.attrs || '.#burrow .#forgejo-nsc-dispatcher .#forgejo-nsc-autoscaler' }} + BURROW_NIX_CACHE_REQUIRED: ${{ github.event.inputs.required || 'false' }} + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Ensure Nix + shell: bash + run: bash Scripts/ci/ensure-nix.sh + + - name: Publish Cache Paths + shell: bash + run: nix develop .#ci -c Scripts/ci/publish-nix-cache.sh diff --git a/.forgejo/workflows/publish-package-repositories.yml b/.forgejo/workflows/publish-package-repositories.yml new file mode 100644 index 0000000..315e43b --- /dev/null +++ b/.forgejo/workflows/publish-package-repositories.yml @@ -0,0 +1,148 @@ +name: "Publish: Package Repositories" +run-name: "Publish Package Repositories (${{ github.event.inputs.channel || 'stable' }})" + +on: + workflow_dispatch: + inputs: + build_number: + description: Build number or release label for package artifact paths + required: false + default: "" + channel: + description: Native package repository channel + required: true + default: stable + type: choice + options: + - stable + - beta + - nightly + publish_gcs: + description: Publish repository tree to configured package storage targets + required: false + default: "true" + +permissions: + contents: read + +concurrency: + group: publish-package-repositories-${{ github.ref }}-${{ github.event.inputs.channel || 'stable' }} + cancel-in-progress: false + +jobs: + publish: + name: Build Native Repositories + runs-on: [self-hosted, linux, x86_64, burrow-forge] + timeout-minutes: 45 + env: + BUILD_NUMBER: ${{ github.event.inputs.build_number || github.sha }} + BURROW_PACKAGE_CHANNEL: ${{ github.event.inputs.channel || 'stable' }} + BURROW_KMS_LOCATION: ${{ vars.BURROW_KMS_LOCATION || 'global' }} + BURROW_KMS_KEYRING: ${{ vars.BURROW_KMS_KEYRING || 'burrow-identity' }} + BURROW_KMS_VERSION: ${{ vars.BURROW_KMS_VERSION || '1' }} + BURROW_GOOGLE_PROJECT_ID: ${{ vars.GOOGLE_PROJECT_ID || 'project-88c23ce9-918a-470a-b33' }} + GOOGLE_CLOUD_PROJECT: ${{ vars.GOOGLE_PROJECT_ID || 'project-88c23ce9-918a-470a-b33' }} + BURROW_GOOGLE_PROJECT_NUMBER: ${{ vars.GOOGLE_PROJECT_NUMBER || '416198671487' }} + BURROW_GOOGLE_WIF_POOL_ID: ${{ vars.BURROW_GOOGLE_WIF_POOL_ID || 'burrow-authentik' }} + BURROW_GOOGLE_WIF_PROVIDER_ID: ${{ vars.BURROW_GOOGLE_WIF_PROVIDER_ID || 'forgejo-runners' }} + BURROW_GOOGLE_WIF_SERVICE_ACCOUNT: ${{ vars.BURROW_GOOGLE_WIF_SERVICE_ACCOUNT || 'burrow-forgejo-runner@project-88c23ce9-918a-470a-b33.iam.gserviceaccount.com' }} + BURROW_AUTHENTIK_WIF_ISSUER: ${{ vars.BURROW_AUTHENTIK_WIF_ISSUER || 'https://auth.burrow.net/application/o/google-cloud/' }} + BURROW_AUTHENTIK_WIF_AUDIENCE: ${{ vars.BURROW_AUTHENTIK_WIF_AUDIENCE || 'google-wif.burrow.net' }} + BURROW_AUTHENTIK_WIF_CLIENT_ID: ${{ vars.BURROW_AUTHENTIK_WIF_CLIENT_ID || 'google-wif.burrow.net' }} + BURROW_AUTHENTIK_WIF_CLIENT_SECRET: ${{ secrets.BURROW_AUTHENTIK_WIF_CLIENT_SECRET }} + BURROW_PACKAGE_GCS_BUCKET: ${{ vars.BURROW_PACKAGE_GCS_BUCKET || 'burrow-net-packages' }} + BURROW_PACKAGE_GCS_PREFIX: ${{ vars.BURROW_PACKAGE_GCS_PREFIX || '' }} + BURROW_PACKAGE_GCS_BACKUP: ${{ vars.BURROW_PACKAGE_GCS_BACKUP || 'true' }} + BURROW_PACKAGE_GARAGE_BUCKET: ${{ vars.BURROW_PACKAGE_GARAGE_BUCKET || 'burrow-packages' }} + BURROW_PACKAGE_GARAGE_PREFIX: ${{ vars.BURROW_PACKAGE_GARAGE_PREFIX || vars.BURROW_PACKAGE_GCS_PREFIX || '' }} + BURROW_PACKAGE_REQUIRE_GARAGE: ${{ vars.BURROW_PACKAGE_REQUIRE_GARAGE || 'true' }} + BURROW_GARAGE_ENDPOINT: ${{ vars.BURROW_GARAGE_ENDPOINT || 'https://objects.burrow.net' }} + BURROW_GARAGE_REGION: ${{ vars.BURROW_GARAGE_REGION || 'garage' }} + AWS_ACCESS_KEY_ID: ${{ secrets.BURROW_GARAGE_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.BURROW_GARAGE_SECRET_ACCESS_KEY }} + BURROW_NIX_CACHE_URL: ${{ vars.BURROW_NIX_CACHE_URL || 'https://nix.burrow.net/burrow' }} + BURROW_NIX_CACHE_PUBLIC_KEY: ${{ vars.BURROW_NIX_CACHE_PUBLIC_KEY }} + steps: + - name: Checkout + shell: bash + run: | + set -euo pipefail + repo_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" + if [ ! -d .git ]; then + git init . + fi + if git remote get-url origin >/dev/null 2>&1; then + git remote set-url origin "${repo_url}" + else + git remote add origin "${repo_url}" + fi + git fetch --force --tags origin "${GITHUB_SHA}" + git checkout --force --detach FETCH_HEAD + git clean -ffdqx + + - name: Ensure Nix + shell: bash + run: bash Scripts/ci/ensure-nix.sh + + - name: Build Linux Packages + shell: bash + run: | + set -euo pipefail + export BURROW_RELEASE_OUT="$PWD/dist/builds/$BUILD_NUMBER" + nix develop .#ci -c Scripts/ci/package-release-artifacts.sh linux + + - name: Authenticate Google WIF + shell: bash + run: | + set -euo pipefail + nix develop .#ci -c Scripts/ci/google-wif-auth.sh + + - name: Export KMS Public Keys + shell: bash + run: | + set -euo pipefail + mkdir -p "$PWD/.kms" + + export BURROW_APT_REPO_KMS_KEY="${BURROW_APT_REPO_KMS_KEY:-package-apt-repository}" + export BURROW_RPM_REPO_KMS_KEY="${BURROW_RPM_REPO_KMS_KEY:-package-rpm-repository}" + export BURROW_PACMAN_REPO_KMS_KEY="${BURROW_PACMAN_REPO_KMS_KEY:-package-pacman-repository}" + + for item in \ + "APT:${BURROW_APT_REPO_KMS_KEY}:apt" \ + "RPM:${BURROW_RPM_REPO_KMS_KEY}:rpm" \ + "PACMAN:${BURROW_PACMAN_REPO_KMS_KEY}:pacman" + do + IFS=: read -r env_prefix key_name file_prefix <<< "$item" + pem="$PWD/.kms/${file_prefix}.pem" + nix develop .#ci -c gcloud kms keys versions get-public-key "$BURROW_KMS_VERSION" \ + --location "$BURROW_KMS_LOCATION" \ + --keyring "$BURROW_KMS_KEYRING" \ + --key "$key_name" \ + --project "$GOOGLE_CLOUD_PROJECT" \ + --output-file "$pem" + echo "BURROW_${env_prefix}_REPO_KMS_PUBLIC_KEY_PEM=$pem" >> "$GITHUB_ENV" + echo "BURROW_${env_prefix}_REPO_KMS_KEY=$key_name" >> "$GITHUB_ENV" + done + + - name: Build Repository Metadata + shell: bash + run: | + set -euo pipefail + export BURROW_PACKAGE_INPUT_DIR="$PWD/dist/builds/$BUILD_NUMBER/linux" + export BURROW_PACKAGE_REPOSITORY_DIR="$PWD/dist/builds/$BUILD_NUMBER/repositories" + nix develop .#ci -c Scripts/package/build-repositories.sh all + + - name: Upload Repository Artifact + uses: https://code.forgejo.org/actions/upload-artifact@v3 + with: + name: burrow-package-repositories-${{ github.event.inputs.channel || 'stable' }}-${{ github.event.inputs.build_number || github.sha }} + path: dist/builds/${{ github.event.inputs.build_number || github.sha }}/repositories/** + if-no-files-found: error + + - name: Publish Package Repository To Storage + if: ${{ github.event.inputs.publish_gcs == 'true' }} + shell: bash + run: | + set -euo pipefail + export BURROW_PACKAGE_REPOSITORY_DIR="$PWD/dist/builds/$BUILD_NUMBER/repositories" + nix develop .#ci -c Scripts/ci/upload-package-storage.sh diff --git a/.forgejo/workflows/publish-store-uploads.yml b/.forgejo/workflows/publish-store-uploads.yml new file mode 100644 index 0000000..904abce --- /dev/null +++ b/.forgejo/workflows/publish-store-uploads.yml @@ -0,0 +1,385 @@ +name: "Publish: Release Uploads" +run-name: "Publish: Release Uploads (Build ${{ inputs.build_number }})" + +on: + workflow_dispatch: + inputs: + build_number: + description: Build number to publish + required: true + upload_app_store: + description: Upload iOS/macOS/visionOS artifacts to App Store Connect + required: false + default: "true" + distribute_testflight: + description: Distribute an already-uploaded iOS build to TestFlight + required: false + default: "false" + upload_sparkle: + description: Publish Sparkle artifacts + required: false + default: "true" + upload_microsoft_store: + description: Upload Windows package to Microsoft Partner Center beta lane + required: false + default: "false" + sparkle_channel: + description: Sparkle channel, defaults to build- + required: false + default: "" + sparkle_point_main: + description: Point Sparkle main appcast/default channel to selected channel + required: false + default: "true" + testflight_distribute_external: + description: Distribute to external TestFlight groups + required: false + default: "false" + testflight_groups: + description: Optional comma-separated TestFlight groups for external distribution + required: false + default: "" + ios_uses_non_exempt_encryption: + description: Set true only when the iOS build uses non-exempt encryption + required: false + default: "false" + +permissions: + contents: read + +concurrency: + group: burrow-publish-store-uploads-${{ inputs.build_number }} + cancel-in-progress: true + +env: + BURROW_RELEASE_GCS_BUCKET: ${{ vars.BURROW_RELEASE_GCS_BUCKET || 'burrow-net-releases' }} + BURROW_GOOGLE_PROJECT_ID: ${{ vars.GOOGLE_PROJECT_ID || 'project-88c23ce9-918a-470a-b33' }} + GOOGLE_CLOUD_PROJECT: ${{ vars.GOOGLE_PROJECT_ID || 'project-88c23ce9-918a-470a-b33' }} + BURROW_GOOGLE_PROJECT_NUMBER: ${{ vars.GOOGLE_PROJECT_NUMBER || '416198671487' }} + BURROW_GOOGLE_WIF_POOL_ID: ${{ vars.BURROW_GOOGLE_WIF_POOL_ID || 'burrow-authentik' }} + BURROW_GOOGLE_WIF_PROVIDER_ID: ${{ vars.BURROW_GOOGLE_WIF_PROVIDER_ID || 'forgejo-runners' }} + BURROW_GOOGLE_WIF_SERVICE_ACCOUNT: ${{ vars.BURROW_GOOGLE_WIF_SERVICE_ACCOUNT || 'burrow-forgejo-runner@project-88c23ce9-918a-470a-b33.iam.gserviceaccount.com' }} + BURROW_AUTHENTIK_WIF_ISSUER: ${{ vars.BURROW_AUTHENTIK_WIF_ISSUER || 'https://auth.burrow.net/application/o/google-cloud/' }} + BURROW_AUTHENTIK_WIF_AUDIENCE: ${{ vars.BURROW_AUTHENTIK_WIF_AUDIENCE || 'google-wif.burrow.net' }} + BURROW_AUTHENTIK_WIF_CLIENT_ID: ${{ vars.BURROW_AUTHENTIK_WIF_CLIENT_ID || 'google-wif.burrow.net' }} + BURROW_AUTHENTIK_WIF_CLIENT_SECRET: ${{ secrets.BURROW_AUTHENTIK_WIF_CLIENT_SECRET }} + BURROW_NIX_CACHE_URL: ${{ vars.BURROW_NIX_CACHE_URL || 'https://nix.burrow.net/burrow' }} + BURROW_NIX_CACHE_PUBLIC_KEY: ${{ vars.BURROW_NIX_CACHE_PUBLIC_KEY }} + BURROW_APPLE_BUNDLE_ID: ${{ vars.BURROW_APPLE_BUNDLE_ID || 'net.burrow.app' }} + BURROW_APPLE_NETWORK_EXTENSION_BUNDLE_ID: ${{ vars.BURROW_APPLE_NETWORK_EXTENSION_BUNDLE_ID || 'net.burrow.app.network' }} + BURROW_IOS_DISTRIBUTION_CERTIFICATE_ID: ${{ vars.BURROW_IOS_DISTRIBUTION_CERTIFICATE_ID || '3G42677598' }} + BURROW_DEVELOPER_ID_CERTIFICATE_ID: ${{ vars.BURROW_DEVELOPER_ID_CERTIFICATE_ID || '9JKN6HXBHC' }} + BURROW_APPLE_SIGNING_MODE: ${{ vars.BURROW_APPLE_SIGNING_MODE || 'google-kms-staged' }} + BURROW_NOTARIZE_MACOS: ${{ vars.BURROW_NOTARIZE_MACOS || 'true' }} + BURROW_SPARKLE_SIGN_WITH_KMS: ${{ vars.BURROW_SPARKLE_SIGN_WITH_KMS || 'true' }} + BURROW_SPARKLE_KMS_KEY: ${{ vars.BURROW_SPARKLE_KMS_KEY || 'sparkle-ed25519' }} + BURROW_SPARKLE_KMS_VERSION: ${{ vars.BURROW_SPARKLE_KMS_VERSION || '1' }} + BURROW_KMS_LOCATION: ${{ vars.BURROW_KMS_LOCATION || 'global' }} + BURROW_KMS_KEYRING: ${{ vars.BURROW_KMS_KEYRING || 'burrow-identity' }} + TESTFLIGHT_WAIT_PROCESSING_TIMEOUT_SECONDS: ${{ vars.TESTFLIGHT_WAIT_PROCESSING_TIMEOUT_SECONDS || '7200' }} + +jobs: + sign-apple-kms: + name: Sign (Apple KMS) + if: ${{ inputs.upload_app_store == 'true' || inputs.upload_sparkle == 'true' }} + runs-on: namespace-profile-linux-medium + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Ensure Nix + shell: bash + run: bash Scripts/ci/ensure-nix.sh + + - name: Configure Age + shell: bash + env: + AGE_FORGE_SSH_KEY: ${{ secrets.AGE_FORGE_SSH_KEY }} + run: Scripts/resolve-age-identity.sh >> "$GITHUB_ENV" + + - name: Decrypt Release Secrets + uses: ./.forgejo/actions/decrypt-release-secrets + + - name: Validate App Store Credentials + shell: bash + run: Scripts/ci/check-release-config.sh app-store + + - name: Download Staged Apple Artifacts + shell: bash + env: + BUILD_NUMBER: ${{ inputs.build_number }} + run: | + set -euo pipefail + nix develop .#ci -c Scripts/ci/google-wif-auth.sh + mkdir -p "dist/builds/${BUILD_NUMBER}/apple" + nix develop .#ci -c gcloud storage rsync --recursive "gs://${BURROW_RELEASE_GCS_BUCKET}/builds/${BUILD_NUMBER}/apple" "dist/builds/${BUILD_NUMBER}/apple" + find "dist/builds/${BUILD_NUMBER}/apple" -type f -print | sort + + - name: Sync Apple Provisioning Profiles + shell: bash + run: nix develop .#ci -c Scripts/ci/sync-apple-provisioning-profiles.sh all + + - name: Sign Apple Artifacts With KMS + shell: bash + env: + BUILD_NUMBER: ${{ inputs.build_number }} + SPARKLE_CHANNEL_INPUT: ${{ inputs.sparkle_channel }} + run: | + set -euo pipefail + channel="${SPARKLE_CHANNEL_INPUT:-}" + if [[ -z "$channel" ]]; then + channel="build-${BUILD_NUMBER}" + fi + SPARKLE_CHANNEL="$channel" nix develop .#ci -c Scripts/apple/sign-release-artifacts-kms.sh all + + - name: Upload Signed Apple Artifacts + shell: bash + env: + BUILD_NUMBER: ${{ inputs.build_number }} + run: nix develop .#ci -c Scripts/ci/upload-release-storage.sh + + upload-app-store: + name: Upload (App Store Connect) + needs: sign-apple-kms + if: ${{ inputs.upload_app_store == 'true' }} + runs-on: namespace-profile-macos-large + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Ensure Nix + shell: bash + run: bash Scripts/ci/ensure-nix.sh + + - name: Configure Age + shell: bash + env: + AGE_FORGE_SSH_KEY: ${{ secrets.AGE_FORGE_SSH_KEY }} + run: Scripts/resolve-age-identity.sh >> "$GITHUB_ENV" + + - name: Decrypt Release Secrets + uses: ./.forgejo/actions/decrypt-release-secrets + + - name: Validate App Store Credentials + shell: bash + run: Scripts/ci/check-release-config.sh app-store + + - name: Download Apple Artifacts From GCS + shell: bash + env: + BUILD_NUMBER: ${{ inputs.build_number }} + run: | + set -euo pipefail + nix develop .#ci -c Scripts/ci/google-wif-auth.sh + mkdir -p publish/apple + nix develop .#ci -c gcloud storage rsync --recursive "gs://${BURROW_RELEASE_GCS_BUCKET}/builds/${BUILD_NUMBER}/apple" publish/apple + find publish/apple -type f -print | sort + + - name: Upload Apple Packages + shell: bash + run: | + set -euo pipefail + Scripts/ci/check-release-config.sh app-store + key_dir="${RUNNER_TEMP:-/tmp}/burrow-asc" + altool_key_dir="${HOME}/.appstoreconnect/private_keys" + mkdir -p "$key_dir" "$altool_key_dir" + key_path="$key_dir/AuthKey_${ASC_API_KEY_ID}.p8" + if [[ -n "${ASC_API_KEY_PATH:-}" && -f "${ASC_API_KEY_PATH:-}" ]]; then + cp "$ASC_API_KEY_PATH" "$key_path" + else + printf '%s' "$ASC_API_KEY_BASE64" | base64 --decode > "$key_path" + fi + cp "$key_path" "$altool_key_dir/AuthKey_${ASC_API_KEY_ID}.p8" + chmod 600 "$key_path" "$altool_key_dir/AuthKey_${ASC_API_KEY_ID}.p8" + shopt -s nullglob + artifacts=() + for artifact in publish/apple/*.ipa publish/apple/*.pkg; do + [[ "$artifact" == *.unsigned.ipa ]] && continue + artifacts+=("$artifact") + done + if (( ${#artifacts[@]} == 0 )); then + echo "::error ::No Apple upload artifacts found for build ${{ inputs.build_number }}." + exit 1 + fi + for artifact in "${artifacts[@]}"; do + upload_type="ios" + if [[ "$artifact" == *.pkg ]]; then + upload_type="macos" + fi + upload_log="${RUNNER_TEMP:-/tmp}/burrow-altool-${upload_type}-$(basename "$artifact").log" + set +e + xcrun altool --upload-app \ + --type "$upload_type" \ + --file "$artifact" \ + --apiKey "$ASC_API_KEY_ID" \ + --apiIssuer "$ASC_API_ISSUER_ID" 2>&1 | tee "$upload_log" + altool_status=${PIPESTATUS[0]} + set -e + if (( altool_status != 0 )) || grep -Eq 'UPLOAD FAILED|Validation failed|ERROR:' "$upload_log"; then + echo "::error ::altool reported upload validation failure for $artifact" >&2 + exit 1 + fi + done + + release-ios-testflight: + name: Release (TestFlight iOS Testers) + needs: upload-app-store + if: ${{ inputs.upload_app_store == 'true' }} + runs-on: namespace-profile-linux-testflight + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Ensure Nix + shell: bash + run: bash Scripts/ci/ensure-nix.sh + + - name: Configure Age + shell: bash + env: + AGE_FORGE_SSH_KEY: ${{ secrets.AGE_FORGE_SSH_KEY }} + run: Scripts/resolve-age-identity.sh >> "$GITHUB_ENV" + + - name: Decrypt Release Secrets + uses: ./.forgejo/actions/decrypt-release-secrets + + - name: Validate App Store Credentials + shell: bash + run: Scripts/ci/check-release-config.sh app-store + + - name: Distribute iOS Build To TestFlight + shell: bash + env: + BUILD_NUMBER: ${{ inputs.build_number }} + TESTFLIGHT_DISTRIBUTE_EXTERNAL: ${{ inputs.testflight_distribute_external || 'false' }} + TESTFLIGHT_GROUPS: ${{ inputs.testflight_groups || '' }} + IOS_USES_NON_EXEMPT_ENCRYPTION: ${{ inputs.ios_uses_non_exempt_encryption || 'false' }} + run: Scripts/ci/distribute-testflight.sh + + distribute-ios-testflight: + name: Distribute (TestFlight iOS Testers) + if: ${{ inputs.upload_app_store != 'true' && inputs.distribute_testflight == 'true' }} + runs-on: namespace-profile-linux-testflight + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Ensure Nix + shell: bash + run: bash Scripts/ci/ensure-nix.sh + + - name: Configure Age + shell: bash + env: + AGE_FORGE_SSH_KEY: ${{ secrets.AGE_FORGE_SSH_KEY }} + run: Scripts/resolve-age-identity.sh >> "$GITHUB_ENV" + + - name: Decrypt Release Secrets + uses: ./.forgejo/actions/decrypt-release-secrets + + - name: Validate App Store Credentials + shell: bash + run: Scripts/ci/check-release-config.sh app-store + + - name: Distribute iOS Build To TestFlight + shell: bash + env: + BUILD_NUMBER: ${{ inputs.build_number }} + TESTFLIGHT_DISTRIBUTE_EXTERNAL: ${{ inputs.testflight_distribute_external || 'false' }} + TESTFLIGHT_GROUPS: ${{ inputs.testflight_groups || '' }} + IOS_USES_NON_EXEMPT_ENCRYPTION: ${{ inputs.ios_uses_non_exempt_encryption || 'false' }} + run: Scripts/ci/distribute-testflight.sh + + upload-sparkle: + name: Upload (Sparkle) + needs: sign-apple-kms + if: ${{ inputs.upload_sparkle == 'true' }} + runs-on: namespace-profile-linux-medium + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Resolve Sparkle Channel + id: channel + shell: bash + env: + BUILD_NUMBER: ${{ inputs.build_number }} + run: | + set -euo pipefail + channel="${{ inputs.sparkle_channel }}" + if [[ -z "$channel" ]]; then + channel="build-${BUILD_NUMBER}" + fi + echo "channel=$channel" >> "$GITHUB_OUTPUT" + + - name: Ensure Nix + shell: bash + run: bash Scripts/ci/ensure-nix.sh + + - name: Publish Sparkle Channel + shell: bash + env: + BUILD_NUMBER: ${{ inputs.build_number }} + CHANNEL: ${{ steps.channel.outputs.channel }} + SPARKLE_POINT_MAIN: ${{ inputs.sparkle_point_main }} + run: | + set -euo pipefail + nix develop .#ci -c Scripts/ci/google-wif-auth.sh + mkdir -p "publish/sparkle/${CHANNEL}" + nix develop .#ci -c gcloud storage rsync --recursive "gs://${BURROW_RELEASE_GCS_BUCKET}/builds/${BUILD_NUMBER}/sparkle/${CHANNEL}" "publish/sparkle/${CHANNEL}" || true + if [[ ! -f "publish/sparkle/${CHANNEL}/appcast.xml" ]]; then + echo "::warning ::No Sparkle appcast staged for build ${BUILD_NUMBER}; skipping Sparkle publish." + find "publish/sparkle/${CHANNEL}" -maxdepth 2 -type f -print || true + exit 0 + fi + nix develop .#ci -c gcloud storage rsync --recursive "publish/sparkle/${CHANNEL}" "gs://${BURROW_RELEASE_GCS_BUCKET}/sparkle/${CHANNEL}" + if [[ "$SPARKLE_POINT_MAIN" == "true" ]]; then + printf '%s\n' "$CHANNEL" > main-channel.txt + nix develop .#ci -c gcloud storage cp main-channel.txt "gs://${BURROW_RELEASE_GCS_BUCKET}/sparkle/main-channel.txt" + nix develop .#ci -c gcloud storage cp "publish/sparkle/${CHANNEL}/appcast.xml" "gs://${BURROW_RELEASE_GCS_BUCKET}/sparkle/appcast.xml" + nix develop .#ci -c gcloud storage rsync --recursive "publish/sparkle/${CHANNEL}" "gs://${BURROW_RELEASE_GCS_BUCKET}/sparkle/default" + fi + + upload-microsoft-store: + name: Upload (Microsoft Store Beta) + if: ${{ inputs.upload_microsoft_store == 'true' }} + runs-on: namespace-profile-windows-large + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Validate Microsoft Store Credentials + shell: pwsh + env: + MICROSOFT_TENANT_ID: ${{ secrets.MICROSOFT_TENANT_ID }} + MICROSOFT_CLIENT_ID: ${{ secrets.MICROSOFT_CLIENT_ID }} + MICROSOFT_CLIENT_SECRET: ${{ secrets.MICROSOFT_CLIENT_SECRET }} + run: | + foreach ($name in "MICROSOFT_TENANT_ID","MICROSOFT_CLIENT_ID","MICROSOFT_CLIENT_SECRET") { + if ([string]::IsNullOrWhiteSpace([Environment]::GetEnvironmentVariable($name))) { + throw "missing required environment variable: $name" + } + } + + - name: Stop Until Store Package Exists + shell: pwsh + run: | + Write-Host "::warning ::Burrow only builds a Windows Rust stub today; Microsoft Store package upload is wired for credentials but waits on MSIX packaging." diff --git a/.forgejo/workflows/release-if-needed.yml b/.forgejo/workflows/release-if-needed.yml new file mode 100644 index 0000000..cc39214 --- /dev/null +++ b/.forgejo/workflows/release-if-needed.yml @@ -0,0 +1,92 @@ +name: "Release: If Needed" +run-name: "Release: If Needed (${{ github.ref_name }})" + +on: + push: + branches: + - main + schedule: + - cron: "*/30 * * * *" + workflow_dispatch: + inputs: + upload_app_store: + description: Trigger downstream App Store Connect upload workflow + required: false + default: "true" + upload_sparkle: + description: Trigger downstream Sparkle publish workflow + required: false + default: "true" + upload_microsoft_store: + description: Trigger downstream Microsoft Store beta upload workflow + required: false + default: "false" + sparkle_point_main: + description: Update Sparkle main channel pointers + required: false + default: "true" + testflight_distribute_external: + description: Distribute to external TestFlight groups + required: false + default: "false" + testflight_groups: + description: Optional comma-separated TestFlight groups for external distribution + required: false + default: "" + ios_uses_non_exempt_encryption: + description: Set true only when the iOS build uses non-exempt encryption + required: false + default: "false" + +permissions: + contents: read + actions: write + +concurrency: + group: burrow-release-if-needed-main + cancel-in-progress: true + +env: + GITHUB_TOKEN: ${{ github.token }} + BURROW_VERSION_REQUIRE_REMOTE: "1" + +jobs: + check: + name: Check (Release Needed) + runs-on: namespace-profile-linux-medium + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + token: ${{ github.token }} + fetch-depth: 0 + + - name: Fetch Build Tags + shell: bash + run: git fetch --force --prune origin "+refs/tags/builds/*:refs/tags/builds/*" + + - name: Dispatch Release Build + shell: bash + env: + UPLOAD_APP_STORE: ${{ github.event.inputs.upload_app_store || 'true' }} + UPLOAD_SPARKLE: ${{ github.event.inputs.upload_sparkle || 'true' }} + UPLOAD_MICROSOFT_STORE: ${{ github.event.inputs.upload_microsoft_store || 'false' }} + SPARKLE_POINT_MAIN: ${{ github.event.inputs.sparkle_point_main || 'true' }} + TESTFLIGHT_DISTRIBUTE_EXTERNAL: ${{ github.event.inputs.testflight_distribute_external || 'false' }} + TESTFLIGHT_GROUPS: ${{ github.event.inputs.testflight_groups || '' }} + IOS_USES_NON_EXEMPT_ENCRYPTION: ${{ github.event.inputs.ios_uses_non_exempt_encryption || 'false' }} + run: | + set -euo pipefail + status="$(Scripts/version.sh status)" + if [[ "$status" == "clean" ]]; then + echo "No unreleased changes." + exit 0 + fi + inputs="$(python3 -c 'import json, os; print(json.dumps({"upload_app_store":os.environ["UPLOAD_APP_STORE"],"upload_sparkle":os.environ["UPLOAD_SPARKLE"],"upload_microsoft_store":os.environ["UPLOAD_MICROSOFT_STORE"],"sparkle_point_main":os.environ["SPARKLE_POINT_MAIN"],"testflight_distribute_external":os.environ["TESTFLIGHT_DISTRIBUTE_EXTERNAL"],"testflight_groups":os.environ["TESTFLIGHT_GROUPS"],"ios_uses_non_exempt_encryption":os.environ["IOS_USES_NON_EXEMPT_ENCRYPTION"]}))')" + curl -fsS \ + -X POST \ + -H "Authorization: token ${GITHUB_TOKEN}" \ + -H "Content-Type: application/json" \ + -d "{\"ref\":\"main\",\"inputs\":${inputs}}" \ + "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/actions/workflows/build-release.yml/dispatches" + echo "Dispatched build-release.yml (status=${status})." diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index 3d1e92a..cf05fd3 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -10,6 +10,10 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: false +env: + BURROW_NIX_CACHE_URL: ${{ vars.BURROW_NIX_CACHE_URL || 'https://nix.burrow.net/burrow' }} + BURROW_NIX_CACHE_PUBLIC_KEY: ${{ vars.BURROW_NIX_CACHE_PUBLIC_KEY }} + jobs: release: name: Release Build @@ -39,8 +43,21 @@ jobs: chmod +x Scripts/ci/build-release-artifacts.sh nix develop .#ci -c Scripts/ci/build-release-artifacts.sh + - name: Flatten release assets + shell: bash + env: + RELEASE_REF: ${{ github.ref_name }} + run: | + set -euo pipefail + ref="${RELEASE_REF:-manual-${GITHUB_SHA::7}}" + mkdir -p dist/release-assets + find "dist/builds/${ref}" -type f \( -name '*.tar.gz' -o -name '*.zip' -o -name '*.sha256' -o -name 'README.txt' \) -exec cp {} dist/release-assets/ \; + rm -rf dist/builds + cp dist/release-assets/* dist/ + find dist -maxdepth 1 -type f -print | sort + - name: Upload release artifacts - uses: https://code.forgejo.org/actions/upload-artifact@v4 + uses: https://code.forgejo.org/actions/upload-artifact@v3 with: name: burrow-release-${{ github.ref_name }} path: dist/* diff --git a/.gitignore b/.gitignore index 7efe903..8237d1a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,10 @@ # Xcode xcuserdata Apple/build/ +.derived-data/ +AuthKey_*.p8 +burrow-certs-pass.txt +*.p12 # Swift Apple/Package/.swiftpm/ @@ -9,11 +13,19 @@ Apple/Package/.swiftpm/ target/ .env +# Bazel +bazel-* + .DS_STORE .idea/ tmp/ +.cache/ intake/ +dist/ +publish/ +release/ +ci-artifacts/ *.db *.sqlite3 diff --git a/Android/README.md b/Android/README.md new file mode 100644 index 0000000..755b722 --- /dev/null +++ b/Android/README.md @@ -0,0 +1,14 @@ +# Burrow Android + +The Android app starts as a Kotlin shell linked to `crates/burrow-mobile-ffi`, +which exposes the cross-platform `burrow-core` crate through JNI. + +The current stub proves the package shape and Rust core boundary. Full VPN +support must use Android `VpnService` and keep platform consent, Play Store +policy, and disclosure requirements in the release lane. + +The Bazel entrypoint is: + +```sh +bazel build //bazel/android:check_stub_stamp +``` diff --git a/Android/app/build.gradle.kts b/Android/app/build.gradle.kts new file mode 100644 index 0000000..cb1a8ac --- /dev/null +++ b/Android/app/build.gradle.kts @@ -0,0 +1,21 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + namespace = "net.burrow.android" + compileSdk = 36 + + defaultConfig { + applicationId = "net.burrow.android" + minSdk = 26 + targetSdk = 36 + versionCode = 1 + versionName = "0.1.0" + } +} + +kotlin { + jvmToolchain(17) +} diff --git a/Android/app/src/main/AndroidManifest.xml b/Android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..2bb3a13 --- /dev/null +++ b/Android/app/src/main/AndroidManifest.xml @@ -0,0 +1,18 @@ + + + + + + + + + + diff --git a/Android/app/src/main/java/net/burrow/android/BurrowCore.kt b/Android/app/src/main/java/net/burrow/android/BurrowCore.kt new file mode 100644 index 0000000..cf286ba --- /dev/null +++ b/Android/app/src/main/java/net/burrow/android/BurrowCore.kt @@ -0,0 +1,9 @@ +package net.burrow.android + +object BurrowCore { + init { + System.loadLibrary("burrow_mobile_ffi") + } + + external fun version(): String +} diff --git a/Android/app/src/main/java/net/burrow/android/MainActivity.kt b/Android/app/src/main/java/net/burrow/android/MainActivity.kt new file mode 100644 index 0000000..810a403 --- /dev/null +++ b/Android/app/src/main/java/net/burrow/android/MainActivity.kt @@ -0,0 +1,32 @@ +package net.burrow.android + +import android.app.Activity +import android.os.Bundle +import android.widget.LinearLayout +import android.widget.TextView + +class MainActivity : Activity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + val versionText = runCatching { BurrowCore.version() } + .getOrElse { "burrow-core unavailable" } + + val root = LinearLayout(this).apply { + orientation = LinearLayout.VERTICAL + setPadding(40, 40, 40, 40) + } + + root.addView(TextView(this).apply { + text = getString(R.string.app_name) + textSize = 24f + }) + + root.addView(TextView(this).apply { + text = versionText + textSize = 14f + }) + + setContentView(root) + } +} diff --git a/Android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/Android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..5d973f2 Binary files /dev/null and b/Android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/Android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/Android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..5d973f2 Binary files /dev/null and b/Android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/Android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/Android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..68cf88b Binary files /dev/null and b/Android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/Android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/Android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..68cf88b Binary files /dev/null and b/Android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/Android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/Android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..2f341d8 Binary files /dev/null and b/Android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/Android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/Android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..2f341d8 Binary files /dev/null and b/Android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/Android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/Android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..ed3c1ba Binary files /dev/null and b/Android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/Android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/Android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..ed3c1ba Binary files /dev/null and b/Android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..3e052d2 Binary files /dev/null and b/Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..3e052d2 Binary files /dev/null and b/Android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/Android/app/src/main/res/values/strings.xml b/Android/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..2f79d4b --- /dev/null +++ b/Android/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + Burrow + diff --git a/Android/app/src/main/res/values/styles.xml b/Android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..3bc0947 --- /dev/null +++ b/Android/app/src/main/res/values/styles.xml @@ -0,0 +1,8 @@ + + + diff --git a/Android/build.gradle.kts b/Android/build.gradle.kts new file mode 100644 index 0000000..60678e4 --- /dev/null +++ b/Android/build.gradle.kts @@ -0,0 +1,4 @@ +plugins { + id("com.android.application") version "8.10.1" apply false + id("org.jetbrains.kotlin.android") version "2.1.21" apply false +} diff --git a/Android/settings.gradle.kts b/Android/settings.gradle.kts new file mode 100644 index 0000000..a4925f9 --- /dev/null +++ b/Android/settings.gradle.kts @@ -0,0 +1,18 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "BurrowAndroid" +include(":app") diff --git a/Apple/App/App.xcconfig b/Apple/App/App.xcconfig index 4e42ddc..05fbc27 100644 --- a/Apple/App/App.xcconfig +++ b/Apple/App/App.xcconfig @@ -10,6 +10,8 @@ INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphone*] = YES INFOPLIST_KEY_UIStatusBarStyle[sdk=iphone*] = UIStatusBarStyleDefault INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad[sdk=iphone*] = UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone[sdk=iphone*] = UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight +ASSETCATALOG_COMPILER_ALTERNATE_APPICON_NAMES[sdk=iphone*] = BurrowPanel02 BurrowPanel03 BurrowPanel04 BurrowPanel05 BurrowPanel06 +ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS[sdk=iphone*] = YES TARGETED_DEVICE_FAMILY[sdk=iphone*] = 1,2 EXCLUDED_SOURCE_FILE_NAMES = MainMenu.xib @@ -18,6 +20,10 @@ INFOPLIST_KEY_LSUIElement[sdk=macosx*] = YES INFOPLIST_KEY_NSMainNibFile[sdk=macosx*] = MainMenu INFOPLIST_KEY_NSPrincipalClass[sdk=macosx*] = NSApplication INFOPLIST_KEY_LSApplicationCategoryType[sdk=macosx*] = public.app-category.utilities +BURROW_SPARKLE_FEED_URL = https:/$()/releases.burrow.net/sparkle/appcast.xml +BURROW_SPARKLE_PUBLIC_ED_KEY = uugZuJeqvvKd91NZ6F1Fv2cQenUbIG/ZW3L9MuaEz30= +INFOPLIST_KEY_SUFeedURL[sdk=macosx*] = $(BURROW_SPARKLE_FEED_URL) +INFOPLIST_KEY_SUPublicEDKey[sdk=macosx*] = $(BURROW_SPARKLE_PUBLIC_ED_KEY) CODE_SIGN_ENTITLEMENTS = App/App-iOS.entitlements CODE_SIGN_ENTITLEMENTS[sdk=macosx*] = App/App-macOS.entitlements diff --git a/Apple/App/AppDelegate.swift b/Apple/App/AppDelegate.swift index c3cb4cb..8eccc07 100644 --- a/Apple/App/AppDelegate.swift +++ b/Apple/App/AppDelegate.swift @@ -1,12 +1,18 @@ #if os(macOS) import AppKit import BurrowUI +import Sparkle import SwiftUI @main @MainActor class AppDelegate: NSObject, NSApplicationDelegate { private var windowController: NSWindowController? + private let updaterController = SPUStandardUpdaterController( + startingUpdater: true, + updaterDelegate: nil, + userDriverDelegate: nil + ) private let quitItem: NSMenuItem = { let quitItem = NSMenuItem( @@ -30,6 +36,16 @@ class AppDelegate: NSObject, NSApplicationDelegate { return item }() + private lazy var checkForUpdatesItem: NSMenuItem = { + let item = NSMenuItem( + title: "Check for Updates...", + action: #selector(checkForUpdates(_:)), + keyEquivalent: "" + ) + item.target = self + return item + }() + private let toggleItem: NSMenuItem = { let toggleView = NSHostingView(rootView: MenuItemToggleView()) toggleView.frame.size = CGSize(width: 300, height: 32) @@ -45,6 +61,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { menu.items = [ toggleItem, openItem, + checkForUpdatesItem, .separator(), quitItem ] @@ -86,5 +103,10 @@ class AppDelegate: NSObject, NSApplicationDelegate { windowController = controller NSApplication.shared.activate(ignoringOtherApps: true) } + + @objc + private func checkForUpdates(_ sender: Any?) { + updaterController.checkForUpdates(sender) + } } #endif diff --git a/Apple/App/BurrowApp.swift b/Apple/App/BurrowApp.swift index 838ef54..45529dc 100644 --- a/Apple/App/BurrowApp.swift +++ b/Apple/App/BurrowApp.swift @@ -1,14 +1,46 @@ #if !os(macOS) import BurrowUI import SwiftUI +#if os(iOS) +import UIKit +#endif @MainActor @main struct BurrowApp: App { var body: some Scene { WindowGroup { + #if os(iOS) + BurrowView(appIconManager: UIKitAppIconManager()) + #else BurrowView() + #endif + } + } +} + +#if os(iOS) +@MainActor +private struct UIKitAppIconManager: AppIconManaging { + var supportsAlternateIcons: Bool { + UIApplication.shared.supportsAlternateIcons + } + + var alternateIconName: String? { + UIApplication.shared.alternateIconName + } + + func setAlternateIconName(_ iconName: String?) async throws { + try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in + UIApplication.shared.setAlternateIconName(iconName) { error in + if let error { + continuation.resume(throwing: error) + } else { + continuation.resume(returning: ()) + } + } } } } #endif +#endif diff --git a/Apple/Burrow.xcodeproj/project.pbxproj b/Apple/Burrow.xcodeproj/project.pbxproj index 83d32e0..71de427 100644 --- a/Apple/Burrow.xcodeproj/project.pbxproj +++ b/Apple/Burrow.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ D03383B02C8E67E300F7C44E /* NIOTransportServices in Frameworks */ = {isa = PBXBuildFile; productRef = D044EE952C8DAB2800778185 /* NIOTransportServices */; }; D05B9F7629E39EEC008CB1F9 /* BurrowApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = D05B9F7529E39EEC008CB1F9 /* BurrowApp.swift */; }; D09150422B9D2AF700BE3CB0 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = D09150412B9D2AF700BE3CB0 /* MainMenu.xib */; platformFilters = (macos, ); }; + D0A11C102F90000100112233 /* DequeModule in Frameworks */ = {isa = PBXBuildFile; productRef = D0A11C0F2F90000100112233 /* DequeModule */; }; D0B1D1102C436152004B7823 /* AsyncAlgorithms in Frameworks */ = {isa = PBXBuildFile; productRef = D0B1D10F2C436152004B7823 /* AsyncAlgorithms */; }; D0BCC6092A09A03E00AD070D /* libburrow.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D0BCC6032A09535900AD070D /* libburrow.a */; }; D0BF09522C8E66F6000D8DEC /* BurrowConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0D4E5622C8D9BF4007F820A /* BurrowConfiguration.framework */; }; @@ -36,6 +37,7 @@ D0D4E57C2C8D9C6F007F820A /* Tunnel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0D4E4AA2C8D921A007F820A /* Tunnel.swift */; }; D0D4E57D2C8D9C6F007F820A /* TunnelButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0D4E4AB2C8D921A007F820A /* TunnelButton.swift */; }; D0D4E57E2C8D9C6F007F820A /* TunnelStatusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0D4E4AC2C8D921A007F820A /* TunnelStatusView.swift */; }; + D0D4E5812C8D9C94007F820A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D0D4E4A12C8D921A007F820A /* Assets.xcassets */; }; D0D4E5892C8D9C94007F820A /* BurrowUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0D4E5582C8D9BF2007F820A /* BurrowUI.framework */; }; D0D4E58A2C8D9C9E007F820A /* BurrowUI.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D0D4E5582C8D9BF2007F820A /* BurrowUI.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; D0D4E58B2C8D9CA4007F820A /* BurrowConfiguration.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D0D4E5622C8D9BF4007F820A /* BurrowConfiguration.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -47,6 +49,7 @@ D0FA10022D10200100112233 /* burrow.grpc.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0FA10042D10200100112233 /* burrow.grpc.swift */; }; D0F7597E2C8DB30500126CF3 /* CGRPCZlib in Frameworks */ = {isa = PBXBuildFile; productRef = D0F7597D2C8DB30500126CF3 /* CGRPCZlib */; }; D0F7598D2C8DB3DA00126CF3 /* Client.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0D4E4992C8D921A007F820A /* Client.swift */; }; + D0C0DE102FA0000100112233 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; platformFilters = (macos, ); productRef = D0C0DE122FA0000100112233 /* Sparkle */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -218,6 +221,7 @@ D0BF09552C8E66FD000D8DEC /* BurrowConfiguration.framework in Frameworks */, D0F4FAD32C8DC79C0068730A /* BurrowCore.framework in Frameworks */, D0D4E5892C8D9C94007F820A /* BurrowUI.framework in Frameworks */, + D0C0DE102FA0000100112233 /* Sparkle in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -238,6 +242,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D0A11C102F90000100112233 /* DequeModule in Frameworks */, D0D4E5702C8D9C62007F820A /* BurrowCore.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -460,6 +465,9 @@ D020F65C29E4A697002790F6 /* PBXTargetDependency */, ); name = App; + packageProductDependencies = ( + D0C0DE122FA0000100112233 /* Sparkle */, + ); productName = Burrow; productReference = D05B9F7229E39EEC008CB1F9 /* Burrow.app */; productType = "com.apple.product-type.application"; @@ -504,6 +512,7 @@ ); name = UI; packageProductDependencies = ( + D0A11C0F2F90000100112233 /* DequeModule */, ); productName = Core; productReference = D0D4E5582C8D9BF2007F820A /* BurrowUI.framework */; @@ -567,6 +576,8 @@ D0D4E4852C8D8F29007F820A /* XCRemoteSwiftPackageReference "swift-protobuf" */, D044EE8F2C8DAB2000778185 /* XCRemoteSwiftPackageReference "swift-nio" */, D044EE942C8DAB2800778185 /* XCRemoteSwiftPackageReference "swift-nio-transport-services" */, + D0A11C0D2F90000100112233 /* XCRemoteSwiftPackageReference "swift-collections" */, + D0C0DE112FA0000100112233 /* XCRemoteSwiftPackageReference "Sparkle" */, ); productRefGroup = D05B9F7329E39EEC008CB1F9 /* Products */; projectDirPath = ""; @@ -595,6 +606,7 @@ buildActionMask = 2147483647; files = ( D09150422B9D2AF700BE3CB0 /* MainMenu.xib in Resources */, + D0D4E5812C8D9C94007F820A /* Assets.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -949,6 +961,14 @@ minimumVersion = 1.21.0; }; }; + D0A11C0D2F90000100112233 /* XCRemoteSwiftPackageReference "swift-collections" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/apple/swift-collections.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 1.1.3; + }; + }; D0B1D10E2C436152004B7823 /* XCRemoteSwiftPackageReference "swift-async-algorithms" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/apple/swift-async-algorithms.git"; @@ -957,6 +977,14 @@ minimumVersion = 1.0.1; }; }; + D0C0DE112FA0000100112233 /* XCRemoteSwiftPackageReference "Sparkle" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/sparkle-project/Sparkle.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 2.9.2; + }; + }; D0D4E4822C8D8EF6007F820A /* XCRemoteSwiftPackageReference "grpc-swift" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/grpc/grpc-swift.git"; @@ -1001,11 +1029,21 @@ package = D0D4E4852C8D8F29007F820A /* XCRemoteSwiftPackageReference "swift-protobuf" */; productName = SwiftProtobuf; }; + D0A11C0F2F90000100112233 /* DequeModule */ = { + isa = XCSwiftPackageProductDependency; + package = D0A11C0D2F90000100112233 /* XCRemoteSwiftPackageReference "swift-collections" */; + productName = DequeModule; + }; D0B1D10F2C436152004B7823 /* AsyncAlgorithms */ = { isa = XCSwiftPackageProductDependency; package = D0B1D10E2C436152004B7823 /* XCRemoteSwiftPackageReference "swift-async-algorithms" */; productName = AsyncAlgorithms; }; + D0C0DE122FA0000100112233 /* Sparkle */ = { + isa = XCSwiftPackageProductDependency; + package = D0C0DE112FA0000100112233 /* XCRemoteSwiftPackageReference "Sparkle" */; + productName = Sparkle; + }; D0F7597D2C8DB30500126CF3 /* CGRPCZlib */ = { isa = XCSwiftPackageProductDependency; package = D0D4E4822C8D8EF6007F820A /* XCRemoteSwiftPackageReference "grpc-swift" */; diff --git a/Apple/Burrow.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Apple/Burrow.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 739b77c..a633fc0 100644 --- a/Apple/Burrow.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Apple/Burrow.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "fa512b990383b7e309c5854a5279817052294a8191a6d3c55c49cfb38e88c0c3", + "originHash" : "5d81b59cbecacd7aae6aa598b32e3513c636250dadab9280a55b905bb0e0ee60", "pins" : [ { "identity" : "grpc-swift", @@ -10,6 +10,15 @@ "version" : "1.23.0" } }, + { + "identity" : "sparkle", + "kind" : "remoteSourceControl", + "location" : "https://github.com/sparkle-project/Sparkle.git", + "state" : { + "revision" : "6276ba2b404829d139c45ff98427cf90e2efc59b", + "version" : "2.9.2" + } + }, { "identity" : "swift-async-algorithms", "kind" : "remoteSourceControl", diff --git a/Apple/Certificates/README.md b/Apple/Certificates/README.md new file mode 100644 index 0000000..a579568 --- /dev/null +++ b/Apple/Certificates/README.md @@ -0,0 +1,41 @@ +# Apple Certificates + +Public Apple certificate material that can be inspected by release tooling lives +here. Private keys do not belong in this directory. + +## Developer ID Application + +- Apple certificate id: `9JKN6HXBHC` +- Certificate file: `Apple/Certificates/developer-id-application-9JKN6HXBHC.cer` +- Subject: `Developer ID Application: Conrad Kramer (87PW93R2ZR)` +- Issuer: `Developer ID Certification Authority`, `G2` +- Team id: `87PW93R2ZR` +- Validity: `2026-06-07T12:13:47Z` through `2031-06-08T12:13:46Z` +- SHA-256 fingerprint: `7B:2D:58:A5:BB:1E:34:5E:FB:FF:7F:E0:A1:CA:4F:B1:5B:6E:08:AF:CE:FD:BE:D0:2B:0A:E9:9C:82:E3:4F:74` +- Google KMS key: + `projects/project-88c23ce9-918a-470a-b33/locations/global/keyRings/burrow-identity/cryptoKeys/apple-developer-id-application/cryptoKeyVersions/1` +- KMS public-key SHA-256: + `9cfaf4755158f445f20a215ef52e7a7ba00da1a310e2e934ba7db5dbb29d2869` + +The certificate was created from a CSR signed by the non-exportable Google KMS +key above. There is no `.p12` for this identity. Release signing must use a +signer that delegates the relevant Apple code-signing operations to Google KMS. + +## iOS Distribution + +- Apple certificate id: `3G42677598` +- Certificate file: `Apple/Certificates/ios-distribution-3G42677598.cer` +- Subject: `iPhone Distribution: Conrad Kramer (87PW93R2ZR)` +- Issuer: `Apple Worldwide Developer Relations Certification Authority`, `G3` +- Team id: `87PW93R2ZR` +- Validity: `2026-06-07T12:21:32Z` through `2027-06-07T12:21:31Z` +- SHA-256 fingerprint: `5A:2F:BA:6E:FB:CA:2D:58:01:1F:A0:C8:0F:CF:6B:58:BE:AA:73:7F:4E:F8:06:1C:8A:14:1B:22:8A:2A:29:2B` +- Google KMS key: + `projects/project-88c23ce9-918a-470a-b33/locations/global/keyRings/burrow-identity/cryptoKeys/apple-ios-distribution/cryptoKeyVersions/1` +- KMS public-key SHA-256: + `f8613ce059de90b29acf01cbd4a7deb37567653bd154bdf6c447098b5c4fae91` + +The certificate was created from a CSR signed by the non-exportable Google KMS +key above through App Store Connect certificate creation. There is no `.p12` +for this identity. iOS signing requires a signing path that can delegate Apple +code-signing operations to Google KMS. diff --git a/Apple/Certificates/developer-id-application-9JKN6HXBHC.cer b/Apple/Certificates/developer-id-application-9JKN6HXBHC.cer new file mode 100644 index 0000000..3e4d20d Binary files /dev/null and b/Apple/Certificates/developer-id-application-9JKN6HXBHC.cer differ diff --git a/Apple/Certificates/ios-distribution-3G42677598.cer b/Apple/Certificates/ios-distribution-3G42677598.cer new file mode 100644 index 0000000..f145b1e Binary files /dev/null and b/Apple/Certificates/ios-distribution-3G42677598.cer differ diff --git a/Apple/Configuration/Info.plist b/Apple/Configuration/Info.plist index 7632dad..519d374 100644 --- a/Apple/Configuration/Info.plist +++ b/Apple/Configuration/Info.plist @@ -4,5 +4,9 @@ CFBundleName $(INFOPLIST_KEY_CFBundleDisplayName) + SUFeedURL + $(BURROW_SPARKLE_FEED_URL) + SUPublicEDKey + $(BURROW_SPARKLE_PUBLIC_ED_KEY) diff --git a/Apple/NetworkExtension/libburrow/build-rust.sh b/Apple/NetworkExtension/libburrow/build-rust.sh index 5db2a2b..81cb901 100755 --- a/Apple/NetworkExtension/libburrow/build-rust.sh +++ b/Apple/NetworkExtension/libburrow/build-rust.sh @@ -45,6 +45,27 @@ for ARCH in "${BURROW_ARCHS[@]}"; do esac done +if [[ -x "$(command -v rustup)" ]]; then + INSTALLED_TARGETS="$(rustup target list --installed)" + MISSING_TARGETS=() + for TARGET in "${RUST_TARGETS[@]}"; do + if ! grep -qx "$TARGET" <<< "$INSTALLED_TARGETS"; then + MISSING_TARGETS+=("$TARGET") + fi + done + if (( ${#MISSING_TARGETS[@]} > 0 )); then + rustup target add "${MISSING_TARGETS[@]}" + fi +else + SYSROOT="$(rustc --print sysroot)" + for TARGET in "${RUST_TARGETS[@]}"; do + if [[ ! -d "${SYSROOT}/lib/rustlib/${TARGET}" ]]; then + echo "error: Rust target ${TARGET} is not installed and rustup is unavailable" >&2 + exit 1 + fi + done +fi + # Pass all RUST_TARGETS in a single invocation CARGO_ARGS=() for TARGET in "${RUST_TARGETS[@]}"; do @@ -63,12 +84,20 @@ else fi if [[ -x "$(command -v rustup)" ]]; then - CARGO_PATH="$(dirname $(rustup which cargo)):/usr/bin" + CARGO_PATH="$(dirname "$(rustup which cargo)"):/usr/bin" else - CARGO_PATH="$(dirname $(readlink -f $(which cargo))):/usr/bin" + CARGO_PATH="$(dirname "$(command -v cargo)"):/usr/bin" fi -PROTOC=$(readlink -f $(which protoc)) +if [[ -n "${PROTOC:-}" ]]; then + if [[ ! -x "$PROTOC" ]]; then + echo "error: PROTOC is set but is not executable: $PROTOC" >&2 + exit 127 + fi +elif ! PROTOC="$(command -v protoc 2>/dev/null)"; then + echo 'error: Unable to find protoc; pass PROTOC or include it in PATH for the Xcode Rust build phase' >&2 + exit 127 +fi CARGO_PATH="$(dirname $PROTOC):$CARGO_PATH" # Run cargo without the various environment variables set by Xcode. diff --git a/Apple/UI/Assets.xcassets/AccentColor.colorset/Contents.json b/Apple/UI/Assets.xcassets/AccentColor.colorset/Contents.json index eb87897..127b747 100644 --- a/Apple/UI/Assets.xcassets/AccentColor.colorset/Contents.json +++ b/Apple/UI/Assets.xcassets/AccentColor.colorset/Contents.json @@ -1,6 +1,15 @@ { "colors" : [ { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x31", + "green" : "0x7A", + "red" : "0xB7" + } + }, "idiom" : "universal" } ], diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/100.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/100.png deleted file mode 100644 index f86c139..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/100.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/1024.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/1024.png deleted file mode 100644 index 872c9ce..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/1024.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/114.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/114.png deleted file mode 100644 index 3bb278d..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/114.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/120.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/120.png deleted file mode 100644 index 185615e..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/120.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/128.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/128.png deleted file mode 100644 index 51bd97c..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/128.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/144.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/144.png deleted file mode 100644 index b05e371..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/144.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/152.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/152.png deleted file mode 100644 index c95ea8a..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/152.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/16.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/16.png deleted file mode 100644 index 3cb15a5..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/16.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/167.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/167.png deleted file mode 100644 index a3ad6a2..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/167.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/172.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/172.png deleted file mode 100644 index 9f3bdb4..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/172.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/180.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/180.png deleted file mode 100644 index 53c1237..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/180.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/196.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/196.png deleted file mode 100644 index ea95961..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/196.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/20.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/20.png deleted file mode 100644 index aec8236..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/20.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/216.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/216.png deleted file mode 100644 index 9f0e3ce..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/216.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/256.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/256.png deleted file mode 100644 index a82ce93..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/256.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/29.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/29.png deleted file mode 100644 index 8dc25c1..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/29.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/32.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/32.png deleted file mode 100644 index 655a424..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/32.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/40.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/40.png deleted file mode 100644 index 1f7f5e9..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/40.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/48.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/48.png deleted file mode 100644 index 4a67ebf..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/48.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/50.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/50.png deleted file mode 100644 index 88985d8..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/50.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/512.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/512.png deleted file mode 100644 index e5cbf6a..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/512.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/55.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/55.png deleted file mode 100644 index dc079ea..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/55.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/57.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/57.png deleted file mode 100644 index de4fddc..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/57.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/58.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/58.png deleted file mode 100644 index 961adad..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/58.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/60.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/60.png deleted file mode 100644 index 2a9e939..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/60.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/64.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/64.png deleted file mode 100644 index c67e407..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/64.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/72.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/72.png deleted file mode 100644 index d09aebe..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/72.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/76.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/76.png deleted file mode 100644 index 3e649b6..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/76.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/80.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/80.png deleted file mode 100644 index 6dad29f..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/80.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/87.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/87.png deleted file mode 100644 index a8ccb38..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/87.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/88.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/88.png deleted file mode 100644 index b1a478a..0000000 Binary files a/Apple/UI/Assets.xcassets/AppIcon.appiconset/88.png and /dev/null differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/Contents.json b/Apple/UI/Assets.xcassets/AppIcon.appiconset/Contents.json index f78687a..092f7cd 100644 --- a/Apple/UI/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/Apple/UI/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,344 +1,218 @@ { - "images" : [ + "images": [ { - "filename" : "40.png", - "idiom" : "iphone", - "scale" : "2x", - "size" : "20x20" + "filename": "ios-panel-01-40.png", + "idiom": "iphone", + "scale": "2x", + "size": "20x20" }, { - "filename" : "60.png", - "idiom" : "iphone", - "scale" : "3x", - "size" : "20x20" + "filename": "ios-panel-01-60.png", + "idiom": "iphone", + "scale": "3x", + "size": "20x20" }, { - "filename" : "29.png", - "idiom" : "iphone", - "scale" : "1x", - "size" : "29x29" + "filename": "ios-panel-01-29.png", + "idiom": "iphone", + "scale": "1x", + "size": "29x29" }, { - "filename" : "58.png", - "idiom" : "iphone", - "scale" : "2x", - "size" : "29x29" + "filename": "ios-panel-01-58.png", + "idiom": "iphone", + "scale": "2x", + "size": "29x29" }, { - "filename" : "87.png", - "idiom" : "iphone", - "scale" : "3x", - "size" : "29x29" + "filename": "ios-panel-01-87.png", + "idiom": "iphone", + "scale": "3x", + "size": "29x29" }, { - "filename" : "80.png", - "idiom" : "iphone", - "scale" : "2x", - "size" : "40x40" + "filename": "ios-panel-01-80.png", + "idiom": "iphone", + "scale": "2x", + "size": "40x40" }, { - "filename" : "120.png", - "idiom" : "iphone", - "scale" : "3x", - "size" : "40x40" + "filename": "ios-panel-01-120.png", + "idiom": "iphone", + "scale": "3x", + "size": "40x40" }, { - "filename" : "57.png", - "idiom" : "iphone", - "scale" : "1x", - "size" : "57x57" + "filename": "ios-panel-01-57.png", + "idiom": "iphone", + "scale": "1x", + "size": "57x57" }, { - "filename" : "114.png", - "idiom" : "iphone", - "scale" : "2x", - "size" : "57x57" + "filename": "ios-panel-01-114.png", + "idiom": "iphone", + "scale": "2x", + "size": "57x57" }, { - "filename" : "120.png", - "idiom" : "iphone", - "scale" : "2x", - "size" : "60x60" + "filename": "ios-panel-01-120.png", + "idiom": "iphone", + "scale": "2x", + "size": "60x60" }, { - "filename" : "180.png", - "idiom" : "iphone", - "scale" : "3x", - "size" : "60x60" + "filename": "ios-panel-01-180.png", + "idiom": "iphone", + "scale": "3x", + "size": "60x60" }, { - "filename" : "20.png", - "idiom" : "ipad", - "scale" : "1x", - "size" : "20x20" + "filename": "ios-panel-01-20.png", + "idiom": "ipad", + "scale": "1x", + "size": "20x20" }, { - "filename" : "40.png", - "idiom" : "ipad", - "scale" : "2x", - "size" : "20x20" + "filename": "ios-panel-01-40.png", + "idiom": "ipad", + "scale": "2x", + "size": "20x20" }, { - "filename" : "29.png", - "idiom" : "ipad", - "scale" : "1x", - "size" : "29x29" + "filename": "ios-panel-01-29.png", + "idiom": "ipad", + "scale": "1x", + "size": "29x29" }, { - "filename" : "58.png", - "idiom" : "ipad", - "scale" : "2x", - "size" : "29x29" + "filename": "ios-panel-01-58.png", + "idiom": "ipad", + "scale": "2x", + "size": "29x29" }, { - "filename" : "40.png", - "idiom" : "ipad", - "scale" : "1x", - "size" : "40x40" + "filename": "ios-panel-01-40.png", + "idiom": "ipad", + "scale": "1x", + "size": "40x40" }, { - "filename" : "80.png", - "idiom" : "ipad", - "scale" : "2x", - "size" : "40x40" + "filename": "ios-panel-01-80.png", + "idiom": "ipad", + "scale": "2x", + "size": "40x40" }, { - "filename" : "50.png", - "idiom" : "ipad", - "scale" : "1x", - "size" : "50x50" + "filename": "ios-panel-01-50.png", + "idiom": "ipad", + "scale": "1x", + "size": "50x50" }, { - "filename" : "100.png", - "idiom" : "ipad", - "scale" : "2x", - "size" : "50x50" + "filename": "ios-panel-01-100.png", + "idiom": "ipad", + "scale": "2x", + "size": "50x50" }, { - "filename" : "72.png", - "idiom" : "ipad", - "scale" : "1x", - "size" : "72x72" + "filename": "ios-panel-01-72.png", + "idiom": "ipad", + "scale": "1x", + "size": "72x72" }, { - "filename" : "144.png", - "idiom" : "ipad", - "scale" : "2x", - "size" : "72x72" + "filename": "ios-panel-01-144.png", + "idiom": "ipad", + "scale": "2x", + "size": "72x72" }, { - "filename" : "76.png", - "idiom" : "ipad", - "scale" : "1x", - "size" : "76x76" + "filename": "ios-panel-01-76.png", + "idiom": "ipad", + "scale": "1x", + "size": "76x76" }, { - "filename" : "152.png", - "idiom" : "ipad", - "scale" : "2x", - "size" : "76x76" + "filename": "ios-panel-01-152.png", + "idiom": "ipad", + "scale": "2x", + "size": "76x76" }, { - "filename" : "167.png", - "idiom" : "ipad", - "scale" : "2x", - "size" : "83.5x83.5" + "filename": "ios-panel-01-167.png", + "idiom": "ipad", + "scale": "2x", + "size": "83.5x83.5" }, { - "filename" : "1024.png", - "idiom" : "ios-marketing", - "scale" : "1x", - "size" : "1024x1024" + "filename": "ios-panel-01-1024.png", + "idiom": "ios-marketing", + "scale": "1x", + "size": "1024x1024" }, { - "filename" : "16.png", - "idiom" : "mac", - "scale" : "1x", - "size" : "16x16" + "filename": "mac-panel-05-16.png", + "idiom": "mac", + "scale": "1x", + "size": "16x16" }, { - "filename" : "32.png", - "idiom" : "mac", - "scale" : "2x", - "size" : "16x16" + "filename": "mac-panel-05-32.png", + "idiom": "mac", + "scale": "2x", + "size": "16x16" }, { - "filename" : "32.png", - "idiom" : "mac", - "scale" : "1x", - "size" : "32x32" + "filename": "mac-panel-05-32.png", + "idiom": "mac", + "scale": "1x", + "size": "32x32" }, { - "filename" : "64.png", - "idiom" : "mac", - "scale" : "2x", - "size" : "32x32" + "filename": "mac-panel-05-64.png", + "idiom": "mac", + "scale": "2x", + "size": "32x32" }, { - "filename" : "128.png", - "idiom" : "mac", - "scale" : "1x", - "size" : "128x128" + "filename": "mac-panel-05-128.png", + "idiom": "mac", + "scale": "1x", + "size": "128x128" }, { - "filename" : "256.png", - "idiom" : "mac", - "scale" : "2x", - "size" : "128x128" + "filename": "mac-panel-05-256.png", + "idiom": "mac", + "scale": "2x", + "size": "128x128" }, { - "filename" : "256.png", - "idiom" : "mac", - "scale" : "1x", - "size" : "256x256" + "filename": "mac-panel-05-256.png", + "idiom": "mac", + "scale": "1x", + "size": "256x256" }, { - "filename" : "512.png", - "idiom" : "mac", - "scale" : "2x", - "size" : "256x256" + "filename": "mac-panel-05-512.png", + "idiom": "mac", + "scale": "2x", + "size": "256x256" }, { - "filename" : "512.png", - "idiom" : "mac", - "scale" : "1x", - "size" : "512x512" + "filename": "mac-panel-05-512.png", + "idiom": "mac", + "scale": "1x", + "size": "512x512" }, { - "filename" : "1024.png", - "idiom" : "mac", - "scale" : "2x", - "size" : "512x512" - }, - { - "filename" : "48.png", - "idiom" : "watch", - "role" : "notificationCenter", - "scale" : "2x", - "size" : "24x24", - "subtype" : "38mm" - }, - { - "filename" : "55.png", - "idiom" : "watch", - "role" : "notificationCenter", - "scale" : "2x", - "size" : "27.5x27.5", - "subtype" : "42mm" - }, - { - "filename" : "58.png", - "idiom" : "watch", - "role" : "companionSettings", - "scale" : "2x", - "size" : "29x29" - }, - { - "filename" : "87.png", - "idiom" : "watch", - "role" : "companionSettings", - "scale" : "3x", - "size" : "29x29" - }, - { - "idiom" : "watch", - "role" : "notificationCenter", - "scale" : "2x", - "size" : "33x33", - "subtype" : "45mm" - }, - { - "filename" : "80.png", - "idiom" : "watch", - "role" : "appLauncher", - "scale" : "2x", - "size" : "40x40", - "subtype" : "38mm" - }, - { - "filename" : "88.png", - "idiom" : "watch", - "role" : "appLauncher", - "scale" : "2x", - "size" : "44x44", - "subtype" : "40mm" - }, - { - "idiom" : "watch", - "role" : "appLauncher", - "scale" : "2x", - "size" : "46x46", - "subtype" : "41mm" - }, - { - "filename" : "100.png", - "idiom" : "watch", - "role" : "appLauncher", - "scale" : "2x", - "size" : "50x50", - "subtype" : "44mm" - }, - { - "idiom" : "watch", - "role" : "appLauncher", - "scale" : "2x", - "size" : "51x51", - "subtype" : "45mm" - }, - { - "idiom" : "watch", - "role" : "appLauncher", - "scale" : "2x", - "size" : "54x54", - "subtype" : "49mm" - }, - { - "filename" : "172.png", - "idiom" : "watch", - "role" : "quickLook", - "scale" : "2x", - "size" : "86x86", - "subtype" : "38mm" - }, - { - "filename" : "196.png", - "idiom" : "watch", - "role" : "quickLook", - "scale" : "2x", - "size" : "98x98", - "subtype" : "42mm" - }, - { - "filename" : "216.png", - "idiom" : "watch", - "role" : "quickLook", - "scale" : "2x", - "size" : "108x108", - "subtype" : "44mm" - }, - { - "idiom" : "watch", - "role" : "quickLook", - "scale" : "2x", - "size" : "117x117", - "subtype" : "45mm" - }, - { - "idiom" : "watch", - "role" : "quickLook", - "scale" : "2x", - "size" : "129x129", - "subtype" : "49mm" - }, - { - "filename" : "1024.png", - "idiom" : "watch-marketing", - "scale" : "1x", - "size" : "1024x1024" + "filename": "mac-panel-05-1024.png", + "idiom": "mac", + "scale": "2x", + "size": "512x512" } ], - "info" : { - "author" : "xcode", - "version" : 1 + "info": { + "author": "xcode", + "version": 1 } } diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-100.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-100.png new file mode 100644 index 0000000..dbe8e53 Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-100.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-1024.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-1024.png new file mode 100644 index 0000000..e335771 Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-1024.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-114.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-114.png new file mode 100644 index 0000000..af8f95a Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-114.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-120.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-120.png new file mode 100644 index 0000000..eea76eb Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-120.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-144.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-144.png new file mode 100644 index 0000000..ed3c1ba Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-144.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-152.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-152.png new file mode 100644 index 0000000..2c7a7cd Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-152.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-167.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-167.png new file mode 100644 index 0000000..7ce3660 Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-167.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-180.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-180.png new file mode 100644 index 0000000..488ac42 Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-180.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-20.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-20.png new file mode 100644 index 0000000..bd3cc95 Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-20.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-29.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-29.png new file mode 100644 index 0000000..227cb6c Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-29.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-40.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-40.png new file mode 100644 index 0000000..c0ef687 Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-40.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-50.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-50.png new file mode 100644 index 0000000..377281b Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-50.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-57.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-57.png new file mode 100644 index 0000000..b9b88e1 Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-57.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-58.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-58.png new file mode 100644 index 0000000..0847ee9 Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-58.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-60.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-60.png new file mode 100644 index 0000000..cd8358b Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-60.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-72.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-72.png new file mode 100644 index 0000000..5d973f2 Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-72.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-76.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-76.png new file mode 100644 index 0000000..1cde009 Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-76.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-80.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-80.png new file mode 100644 index 0000000..ecf97e9 Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-80.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-87.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-87.png new file mode 100644 index 0000000..e1f3193 Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/ios-panel-01-87.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-1024.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-1024.png new file mode 100644 index 0000000..065e8b6 Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-1024.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-128.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-128.png new file mode 100644 index 0000000..f4bd4bc Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-128.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-16.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-16.png new file mode 100644 index 0000000..30e2ad9 Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-16.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-256.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-256.png new file mode 100644 index 0000000..d919e9c Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-256.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-32.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-32.png new file mode 100644 index 0000000..3c1fd9f Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-32.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-512.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-512.png new file mode 100644 index 0000000..441a139 Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-512.png differ diff --git a/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-64.png b/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-64.png new file mode 100644 index 0000000..e6a72db Binary files /dev/null and b/Apple/UI/Assets.xcassets/AppIcon.appiconset/mac-panel-05-64.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel01Preview.imageset/Contents.json b/Apple/UI/Assets.xcassets/BurrowPanel01Preview.imageset/Contents.json new file mode 100644 index 0000000..d6ee58c --- /dev/null +++ b/Apple/UI/Assets.xcassets/BurrowPanel01Preview.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images": [ + { + "filename": "preview.png", + "idiom": "universal", + "scale": "1x" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/Apple/UI/Assets.xcassets/BurrowPanel01Preview.imageset/preview.png b/Apple/UI/Assets.xcassets/BurrowPanel01Preview.imageset/preview.png new file mode 100644 index 0000000..561abcb Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel01Preview.imageset/preview.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-100.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-100.png new file mode 100644 index 0000000..48c06a4 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-100.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-1024.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-1024.png new file mode 100644 index 0000000..278575e Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-1024.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-114.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-114.png new file mode 100644 index 0000000..411802b Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-114.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-120.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-120.png new file mode 100644 index 0000000..95473ee Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-120.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-144.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-144.png new file mode 100644 index 0000000..2b2afb9 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-144.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-152.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-152.png new file mode 100644 index 0000000..0668af2 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-152.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-167.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-167.png new file mode 100644 index 0000000..5486437 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-167.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-180.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-180.png new file mode 100644 index 0000000..18111cf Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-180.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-20.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-20.png new file mode 100644 index 0000000..b0df643 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-20.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-29.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-29.png new file mode 100644 index 0000000..49d677b Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-29.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-40.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-40.png new file mode 100644 index 0000000..1fb9e0f Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-40.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-50.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-50.png new file mode 100644 index 0000000..c73d033 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-50.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-57.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-57.png new file mode 100644 index 0000000..c55bc86 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-57.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-58.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-58.png new file mode 100644 index 0000000..470ab9c Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-58.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-60.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-60.png new file mode 100644 index 0000000..914fe25 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-60.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-72.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-72.png new file mode 100644 index 0000000..463a7cc Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-72.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-76.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-76.png new file mode 100644 index 0000000..7080ec3 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-76.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-80.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-80.png new file mode 100644 index 0000000..90be22c Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-80.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-87.png b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-87.png new file mode 100644 index 0000000..f494783 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/BurrowPanel02-87.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/Contents.json b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/Contents.json new file mode 100644 index 0000000..a6ab553 --- /dev/null +++ b/Apple/UI/Assets.xcassets/BurrowPanel02.appiconset/Contents.json @@ -0,0 +1,158 @@ +{ + "images": [ + { + "filename": "BurrowPanel02-40.png", + "idiom": "iphone", + "scale": "2x", + "size": "20x20" + }, + { + "filename": "BurrowPanel02-60.png", + "idiom": "iphone", + "scale": "3x", + "size": "20x20" + }, + { + "filename": "BurrowPanel02-29.png", + "idiom": "iphone", + "scale": "1x", + "size": "29x29" + }, + { + "filename": "BurrowPanel02-58.png", + "idiom": "iphone", + "scale": "2x", + "size": "29x29" + }, + { + "filename": "BurrowPanel02-87.png", + "idiom": "iphone", + "scale": "3x", + "size": "29x29" + }, + { + "filename": "BurrowPanel02-80.png", + "idiom": "iphone", + "scale": "2x", + "size": "40x40" + }, + { + "filename": "BurrowPanel02-120.png", + "idiom": "iphone", + "scale": "3x", + "size": "40x40" + }, + { + "filename": "BurrowPanel02-57.png", + "idiom": "iphone", + "scale": "1x", + "size": "57x57" + }, + { + "filename": "BurrowPanel02-114.png", + "idiom": "iphone", + "scale": "2x", + "size": "57x57" + }, + { + "filename": "BurrowPanel02-120.png", + "idiom": "iphone", + "scale": "2x", + "size": "60x60" + }, + { + "filename": "BurrowPanel02-180.png", + "idiom": "iphone", + "scale": "3x", + "size": "60x60" + }, + { + "filename": "BurrowPanel02-20.png", + "idiom": "ipad", + "scale": "1x", + "size": "20x20" + }, + { + "filename": "BurrowPanel02-40.png", + "idiom": "ipad", + "scale": "2x", + "size": "20x20" + }, + { + "filename": "BurrowPanel02-29.png", + "idiom": "ipad", + "scale": "1x", + "size": "29x29" + }, + { + "filename": "BurrowPanel02-58.png", + "idiom": "ipad", + "scale": "2x", + "size": "29x29" + }, + { + "filename": "BurrowPanel02-40.png", + "idiom": "ipad", + "scale": "1x", + "size": "40x40" + }, + { + "filename": "BurrowPanel02-80.png", + "idiom": "ipad", + "scale": "2x", + "size": "40x40" + }, + { + "filename": "BurrowPanel02-50.png", + "idiom": "ipad", + "scale": "1x", + "size": "50x50" + }, + { + "filename": "BurrowPanel02-100.png", + "idiom": "ipad", + "scale": "2x", + "size": "50x50" + }, + { + "filename": "BurrowPanel02-72.png", + "idiom": "ipad", + "scale": "1x", + "size": "72x72" + }, + { + "filename": "BurrowPanel02-144.png", + "idiom": "ipad", + "scale": "2x", + "size": "72x72" + }, + { + "filename": "BurrowPanel02-76.png", + "idiom": "ipad", + "scale": "1x", + "size": "76x76" + }, + { + "filename": "BurrowPanel02-152.png", + "idiom": "ipad", + "scale": "2x", + "size": "76x76" + }, + { + "filename": "BurrowPanel02-167.png", + "idiom": "ipad", + "scale": "2x", + "size": "83.5x83.5" + }, + { + "filename": "BurrowPanel02-1024.png", + "idiom": "ios-marketing", + "scale": "1x", + "size": "1024x1024" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02Preview.imageset/Contents.json b/Apple/UI/Assets.xcassets/BurrowPanel02Preview.imageset/Contents.json new file mode 100644 index 0000000..d6ee58c --- /dev/null +++ b/Apple/UI/Assets.xcassets/BurrowPanel02Preview.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images": [ + { + "filename": "preview.png", + "idiom": "universal", + "scale": "1x" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/Apple/UI/Assets.xcassets/BurrowPanel02Preview.imageset/preview.png b/Apple/UI/Assets.xcassets/BurrowPanel02Preview.imageset/preview.png new file mode 100644 index 0000000..f6d9feb Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel02Preview.imageset/preview.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-100.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-100.png new file mode 100644 index 0000000..8d72c1b Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-100.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-1024.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-1024.png new file mode 100644 index 0000000..6f40b0a Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-1024.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-114.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-114.png new file mode 100644 index 0000000..9d44be4 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-114.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-120.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-120.png new file mode 100644 index 0000000..434c1a8 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-120.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-144.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-144.png new file mode 100644 index 0000000..d837b45 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-144.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-152.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-152.png new file mode 100644 index 0000000..c507534 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-152.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-167.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-167.png new file mode 100644 index 0000000..e79fc1e Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-167.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-180.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-180.png new file mode 100644 index 0000000..7022128 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-180.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-20.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-20.png new file mode 100644 index 0000000..28468f0 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-20.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-29.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-29.png new file mode 100644 index 0000000..b4dc026 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-29.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-40.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-40.png new file mode 100644 index 0000000..2ed0ee4 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-40.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-50.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-50.png new file mode 100644 index 0000000..7015cf1 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-50.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-57.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-57.png new file mode 100644 index 0000000..6cfb78d Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-57.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-58.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-58.png new file mode 100644 index 0000000..1efe951 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-58.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-60.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-60.png new file mode 100644 index 0000000..e007091 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-60.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-72.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-72.png new file mode 100644 index 0000000..f82f554 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-72.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-76.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-76.png new file mode 100644 index 0000000..5f92d14 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-76.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-80.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-80.png new file mode 100644 index 0000000..37337e7 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-80.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-87.png b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-87.png new file mode 100644 index 0000000..e37171c Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/BurrowPanel03-87.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/Contents.json b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/Contents.json new file mode 100644 index 0000000..923e927 --- /dev/null +++ b/Apple/UI/Assets.xcassets/BurrowPanel03.appiconset/Contents.json @@ -0,0 +1,158 @@ +{ + "images": [ + { + "filename": "BurrowPanel03-40.png", + "idiom": "iphone", + "scale": "2x", + "size": "20x20" + }, + { + "filename": "BurrowPanel03-60.png", + "idiom": "iphone", + "scale": "3x", + "size": "20x20" + }, + { + "filename": "BurrowPanel03-29.png", + "idiom": "iphone", + "scale": "1x", + "size": "29x29" + }, + { + "filename": "BurrowPanel03-58.png", + "idiom": "iphone", + "scale": "2x", + "size": "29x29" + }, + { + "filename": "BurrowPanel03-87.png", + "idiom": "iphone", + "scale": "3x", + "size": "29x29" + }, + { + "filename": "BurrowPanel03-80.png", + "idiom": "iphone", + "scale": "2x", + "size": "40x40" + }, + { + "filename": "BurrowPanel03-120.png", + "idiom": "iphone", + "scale": "3x", + "size": "40x40" + }, + { + "filename": "BurrowPanel03-57.png", + "idiom": "iphone", + "scale": "1x", + "size": "57x57" + }, + { + "filename": "BurrowPanel03-114.png", + "idiom": "iphone", + "scale": "2x", + "size": "57x57" + }, + { + "filename": "BurrowPanel03-120.png", + "idiom": "iphone", + "scale": "2x", + "size": "60x60" + }, + { + "filename": "BurrowPanel03-180.png", + "idiom": "iphone", + "scale": "3x", + "size": "60x60" + }, + { + "filename": "BurrowPanel03-20.png", + "idiom": "ipad", + "scale": "1x", + "size": "20x20" + }, + { + "filename": "BurrowPanel03-40.png", + "idiom": "ipad", + "scale": "2x", + "size": "20x20" + }, + { + "filename": "BurrowPanel03-29.png", + "idiom": "ipad", + "scale": "1x", + "size": "29x29" + }, + { + "filename": "BurrowPanel03-58.png", + "idiom": "ipad", + "scale": "2x", + "size": "29x29" + }, + { + "filename": "BurrowPanel03-40.png", + "idiom": "ipad", + "scale": "1x", + "size": "40x40" + }, + { + "filename": "BurrowPanel03-80.png", + "idiom": "ipad", + "scale": "2x", + "size": "40x40" + }, + { + "filename": "BurrowPanel03-50.png", + "idiom": "ipad", + "scale": "1x", + "size": "50x50" + }, + { + "filename": "BurrowPanel03-100.png", + "idiom": "ipad", + "scale": "2x", + "size": "50x50" + }, + { + "filename": "BurrowPanel03-72.png", + "idiom": "ipad", + "scale": "1x", + "size": "72x72" + }, + { + "filename": "BurrowPanel03-144.png", + "idiom": "ipad", + "scale": "2x", + "size": "72x72" + }, + { + "filename": "BurrowPanel03-76.png", + "idiom": "ipad", + "scale": "1x", + "size": "76x76" + }, + { + "filename": "BurrowPanel03-152.png", + "idiom": "ipad", + "scale": "2x", + "size": "76x76" + }, + { + "filename": "BurrowPanel03-167.png", + "idiom": "ipad", + "scale": "2x", + "size": "83.5x83.5" + }, + { + "filename": "BurrowPanel03-1024.png", + "idiom": "ios-marketing", + "scale": "1x", + "size": "1024x1024" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03Preview.imageset/Contents.json b/Apple/UI/Assets.xcassets/BurrowPanel03Preview.imageset/Contents.json new file mode 100644 index 0000000..d6ee58c --- /dev/null +++ b/Apple/UI/Assets.xcassets/BurrowPanel03Preview.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images": [ + { + "filename": "preview.png", + "idiom": "universal", + "scale": "1x" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/Apple/UI/Assets.xcassets/BurrowPanel03Preview.imageset/preview.png b/Apple/UI/Assets.xcassets/BurrowPanel03Preview.imageset/preview.png new file mode 100644 index 0000000..76d432e Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel03Preview.imageset/preview.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-100.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-100.png new file mode 100644 index 0000000..3c70fad Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-100.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-1024.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-1024.png new file mode 100644 index 0000000..4925f9f Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-1024.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-114.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-114.png new file mode 100644 index 0000000..6ea1195 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-114.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-120.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-120.png new file mode 100644 index 0000000..b07aa10 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-120.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-144.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-144.png new file mode 100644 index 0000000..783367c Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-144.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-152.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-152.png new file mode 100644 index 0000000..5a13fd3 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-152.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-167.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-167.png new file mode 100644 index 0000000..694d1f1 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-167.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-180.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-180.png new file mode 100644 index 0000000..af7e0fb Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-180.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-20.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-20.png new file mode 100644 index 0000000..6889afc Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-20.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-29.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-29.png new file mode 100644 index 0000000..81f027c Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-29.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-40.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-40.png new file mode 100644 index 0000000..6fc8b68 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-40.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-50.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-50.png new file mode 100644 index 0000000..cf8d516 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-50.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-57.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-57.png new file mode 100644 index 0000000..6bddc05 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-57.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-58.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-58.png new file mode 100644 index 0000000..c80a63f Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-58.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-60.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-60.png new file mode 100644 index 0000000..22bf565 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-60.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-72.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-72.png new file mode 100644 index 0000000..1ce020b Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-72.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-76.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-76.png new file mode 100644 index 0000000..d0f2173 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-76.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-80.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-80.png new file mode 100644 index 0000000..3d4be54 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-80.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-87.png b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-87.png new file mode 100644 index 0000000..0de4b64 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/BurrowPanel04-87.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/Contents.json b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/Contents.json new file mode 100644 index 0000000..ee5c59a --- /dev/null +++ b/Apple/UI/Assets.xcassets/BurrowPanel04.appiconset/Contents.json @@ -0,0 +1,158 @@ +{ + "images": [ + { + "filename": "BurrowPanel04-40.png", + "idiom": "iphone", + "scale": "2x", + "size": "20x20" + }, + { + "filename": "BurrowPanel04-60.png", + "idiom": "iphone", + "scale": "3x", + "size": "20x20" + }, + { + "filename": "BurrowPanel04-29.png", + "idiom": "iphone", + "scale": "1x", + "size": "29x29" + }, + { + "filename": "BurrowPanel04-58.png", + "idiom": "iphone", + "scale": "2x", + "size": "29x29" + }, + { + "filename": "BurrowPanel04-87.png", + "idiom": "iphone", + "scale": "3x", + "size": "29x29" + }, + { + "filename": "BurrowPanel04-80.png", + "idiom": "iphone", + "scale": "2x", + "size": "40x40" + }, + { + "filename": "BurrowPanel04-120.png", + "idiom": "iphone", + "scale": "3x", + "size": "40x40" + }, + { + "filename": "BurrowPanel04-57.png", + "idiom": "iphone", + "scale": "1x", + "size": "57x57" + }, + { + "filename": "BurrowPanel04-114.png", + "idiom": "iphone", + "scale": "2x", + "size": "57x57" + }, + { + "filename": "BurrowPanel04-120.png", + "idiom": "iphone", + "scale": "2x", + "size": "60x60" + }, + { + "filename": "BurrowPanel04-180.png", + "idiom": "iphone", + "scale": "3x", + "size": "60x60" + }, + { + "filename": "BurrowPanel04-20.png", + "idiom": "ipad", + "scale": "1x", + "size": "20x20" + }, + { + "filename": "BurrowPanel04-40.png", + "idiom": "ipad", + "scale": "2x", + "size": "20x20" + }, + { + "filename": "BurrowPanel04-29.png", + "idiom": "ipad", + "scale": "1x", + "size": "29x29" + }, + { + "filename": "BurrowPanel04-58.png", + "idiom": "ipad", + "scale": "2x", + "size": "29x29" + }, + { + "filename": "BurrowPanel04-40.png", + "idiom": "ipad", + "scale": "1x", + "size": "40x40" + }, + { + "filename": "BurrowPanel04-80.png", + "idiom": "ipad", + "scale": "2x", + "size": "40x40" + }, + { + "filename": "BurrowPanel04-50.png", + "idiom": "ipad", + "scale": "1x", + "size": "50x50" + }, + { + "filename": "BurrowPanel04-100.png", + "idiom": "ipad", + "scale": "2x", + "size": "50x50" + }, + { + "filename": "BurrowPanel04-72.png", + "idiom": "ipad", + "scale": "1x", + "size": "72x72" + }, + { + "filename": "BurrowPanel04-144.png", + "idiom": "ipad", + "scale": "2x", + "size": "72x72" + }, + { + "filename": "BurrowPanel04-76.png", + "idiom": "ipad", + "scale": "1x", + "size": "76x76" + }, + { + "filename": "BurrowPanel04-152.png", + "idiom": "ipad", + "scale": "2x", + "size": "76x76" + }, + { + "filename": "BurrowPanel04-167.png", + "idiom": "ipad", + "scale": "2x", + "size": "83.5x83.5" + }, + { + "filename": "BurrowPanel04-1024.png", + "idiom": "ios-marketing", + "scale": "1x", + "size": "1024x1024" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04Preview.imageset/Contents.json b/Apple/UI/Assets.xcassets/BurrowPanel04Preview.imageset/Contents.json new file mode 100644 index 0000000..d6ee58c --- /dev/null +++ b/Apple/UI/Assets.xcassets/BurrowPanel04Preview.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images": [ + { + "filename": "preview.png", + "idiom": "universal", + "scale": "1x" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/Apple/UI/Assets.xcassets/BurrowPanel04Preview.imageset/preview.png b/Apple/UI/Assets.xcassets/BurrowPanel04Preview.imageset/preview.png new file mode 100644 index 0000000..36b526c Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel04Preview.imageset/preview.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-100.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-100.png new file mode 100644 index 0000000..caed322 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-100.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-1024.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-1024.png new file mode 100644 index 0000000..065e8b6 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-1024.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-114.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-114.png new file mode 100644 index 0000000..a6a5dfa Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-114.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-120.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-120.png new file mode 100644 index 0000000..184604d Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-120.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-144.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-144.png new file mode 100644 index 0000000..89a64a9 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-144.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-152.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-152.png new file mode 100644 index 0000000..339670e Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-152.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-167.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-167.png new file mode 100644 index 0000000..ac23f7c Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-167.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-180.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-180.png new file mode 100644 index 0000000..d2c8089 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-180.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-20.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-20.png new file mode 100644 index 0000000..821044f Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-20.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-29.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-29.png new file mode 100644 index 0000000..b20c630 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-29.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-40.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-40.png new file mode 100644 index 0000000..9fa18b5 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-40.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-50.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-50.png new file mode 100644 index 0000000..619429d Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-50.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-57.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-57.png new file mode 100644 index 0000000..bde5672 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-57.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-58.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-58.png new file mode 100644 index 0000000..8d8311d Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-58.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-60.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-60.png new file mode 100644 index 0000000..5d37b74 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-60.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-72.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-72.png new file mode 100644 index 0000000..a3624bf Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-72.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-76.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-76.png new file mode 100644 index 0000000..35730d1 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-76.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-80.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-80.png new file mode 100644 index 0000000..43ad408 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-80.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-87.png b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-87.png new file mode 100644 index 0000000..1e7bbdf Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/BurrowPanel05-87.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/Contents.json b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/Contents.json new file mode 100644 index 0000000..a1e0e4b --- /dev/null +++ b/Apple/UI/Assets.xcassets/BurrowPanel05.appiconset/Contents.json @@ -0,0 +1,158 @@ +{ + "images": [ + { + "filename": "BurrowPanel05-40.png", + "idiom": "iphone", + "scale": "2x", + "size": "20x20" + }, + { + "filename": "BurrowPanel05-60.png", + "idiom": "iphone", + "scale": "3x", + "size": "20x20" + }, + { + "filename": "BurrowPanel05-29.png", + "idiom": "iphone", + "scale": "1x", + "size": "29x29" + }, + { + "filename": "BurrowPanel05-58.png", + "idiom": "iphone", + "scale": "2x", + "size": "29x29" + }, + { + "filename": "BurrowPanel05-87.png", + "idiom": "iphone", + "scale": "3x", + "size": "29x29" + }, + { + "filename": "BurrowPanel05-80.png", + "idiom": "iphone", + "scale": "2x", + "size": "40x40" + }, + { + "filename": "BurrowPanel05-120.png", + "idiom": "iphone", + "scale": "3x", + "size": "40x40" + }, + { + "filename": "BurrowPanel05-57.png", + "idiom": "iphone", + "scale": "1x", + "size": "57x57" + }, + { + "filename": "BurrowPanel05-114.png", + "idiom": "iphone", + "scale": "2x", + "size": "57x57" + }, + { + "filename": "BurrowPanel05-120.png", + "idiom": "iphone", + "scale": "2x", + "size": "60x60" + }, + { + "filename": "BurrowPanel05-180.png", + "idiom": "iphone", + "scale": "3x", + "size": "60x60" + }, + { + "filename": "BurrowPanel05-20.png", + "idiom": "ipad", + "scale": "1x", + "size": "20x20" + }, + { + "filename": "BurrowPanel05-40.png", + "idiom": "ipad", + "scale": "2x", + "size": "20x20" + }, + { + "filename": "BurrowPanel05-29.png", + "idiom": "ipad", + "scale": "1x", + "size": "29x29" + }, + { + "filename": "BurrowPanel05-58.png", + "idiom": "ipad", + "scale": "2x", + "size": "29x29" + }, + { + "filename": "BurrowPanel05-40.png", + "idiom": "ipad", + "scale": "1x", + "size": "40x40" + }, + { + "filename": "BurrowPanel05-80.png", + "idiom": "ipad", + "scale": "2x", + "size": "40x40" + }, + { + "filename": "BurrowPanel05-50.png", + "idiom": "ipad", + "scale": "1x", + "size": "50x50" + }, + { + "filename": "BurrowPanel05-100.png", + "idiom": "ipad", + "scale": "2x", + "size": "50x50" + }, + { + "filename": "BurrowPanel05-72.png", + "idiom": "ipad", + "scale": "1x", + "size": "72x72" + }, + { + "filename": "BurrowPanel05-144.png", + "idiom": "ipad", + "scale": "2x", + "size": "72x72" + }, + { + "filename": "BurrowPanel05-76.png", + "idiom": "ipad", + "scale": "1x", + "size": "76x76" + }, + { + "filename": "BurrowPanel05-152.png", + "idiom": "ipad", + "scale": "2x", + "size": "76x76" + }, + { + "filename": "BurrowPanel05-167.png", + "idiom": "ipad", + "scale": "2x", + "size": "83.5x83.5" + }, + { + "filename": "BurrowPanel05-1024.png", + "idiom": "ios-marketing", + "scale": "1x", + "size": "1024x1024" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05Preview.imageset/Contents.json b/Apple/UI/Assets.xcassets/BurrowPanel05Preview.imageset/Contents.json new file mode 100644 index 0000000..d6ee58c --- /dev/null +++ b/Apple/UI/Assets.xcassets/BurrowPanel05Preview.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images": [ + { + "filename": "preview.png", + "idiom": "universal", + "scale": "1x" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/Apple/UI/Assets.xcassets/BurrowPanel05Preview.imageset/preview.png b/Apple/UI/Assets.xcassets/BurrowPanel05Preview.imageset/preview.png new file mode 100644 index 0000000..d919e9c Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel05Preview.imageset/preview.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-100.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-100.png new file mode 100644 index 0000000..c723bc5 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-100.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-1024.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-1024.png new file mode 100644 index 0000000..54336b2 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-1024.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-114.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-114.png new file mode 100644 index 0000000..f0d4a55 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-114.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-120.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-120.png new file mode 100644 index 0000000..cf95959 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-120.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-144.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-144.png new file mode 100644 index 0000000..b1bb422 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-144.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-152.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-152.png new file mode 100644 index 0000000..a44333c Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-152.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-167.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-167.png new file mode 100644 index 0000000..adb7652 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-167.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-180.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-180.png new file mode 100644 index 0000000..0e64715 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-180.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-20.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-20.png new file mode 100644 index 0000000..d9d652b Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-20.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-29.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-29.png new file mode 100644 index 0000000..e200e3c Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-29.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-40.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-40.png new file mode 100644 index 0000000..3db6db7 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-40.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-50.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-50.png new file mode 100644 index 0000000..7f3b15e Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-50.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-57.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-57.png new file mode 100644 index 0000000..49fd3f6 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-57.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-58.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-58.png new file mode 100644 index 0000000..7f7c2ff Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-58.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-60.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-60.png new file mode 100644 index 0000000..da1f3ca Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-60.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-72.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-72.png new file mode 100644 index 0000000..1a9e3dc Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-72.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-76.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-76.png new file mode 100644 index 0000000..e4407db Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-76.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-80.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-80.png new file mode 100644 index 0000000..0c0b7f4 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-80.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-87.png b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-87.png new file mode 100644 index 0000000..3740748 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/BurrowPanel06-87.png differ diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/Contents.json b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/Contents.json new file mode 100644 index 0000000..91d9323 --- /dev/null +++ b/Apple/UI/Assets.xcassets/BurrowPanel06.appiconset/Contents.json @@ -0,0 +1,158 @@ +{ + "images": [ + { + "filename": "BurrowPanel06-40.png", + "idiom": "iphone", + "scale": "2x", + "size": "20x20" + }, + { + "filename": "BurrowPanel06-60.png", + "idiom": "iphone", + "scale": "3x", + "size": "20x20" + }, + { + "filename": "BurrowPanel06-29.png", + "idiom": "iphone", + "scale": "1x", + "size": "29x29" + }, + { + "filename": "BurrowPanel06-58.png", + "idiom": "iphone", + "scale": "2x", + "size": "29x29" + }, + { + "filename": "BurrowPanel06-87.png", + "idiom": "iphone", + "scale": "3x", + "size": "29x29" + }, + { + "filename": "BurrowPanel06-80.png", + "idiom": "iphone", + "scale": "2x", + "size": "40x40" + }, + { + "filename": "BurrowPanel06-120.png", + "idiom": "iphone", + "scale": "3x", + "size": "40x40" + }, + { + "filename": "BurrowPanel06-57.png", + "idiom": "iphone", + "scale": "1x", + "size": "57x57" + }, + { + "filename": "BurrowPanel06-114.png", + "idiom": "iphone", + "scale": "2x", + "size": "57x57" + }, + { + "filename": "BurrowPanel06-120.png", + "idiom": "iphone", + "scale": "2x", + "size": "60x60" + }, + { + "filename": "BurrowPanel06-180.png", + "idiom": "iphone", + "scale": "3x", + "size": "60x60" + }, + { + "filename": "BurrowPanel06-20.png", + "idiom": "ipad", + "scale": "1x", + "size": "20x20" + }, + { + "filename": "BurrowPanel06-40.png", + "idiom": "ipad", + "scale": "2x", + "size": "20x20" + }, + { + "filename": "BurrowPanel06-29.png", + "idiom": "ipad", + "scale": "1x", + "size": "29x29" + }, + { + "filename": "BurrowPanel06-58.png", + "idiom": "ipad", + "scale": "2x", + "size": "29x29" + }, + { + "filename": "BurrowPanel06-40.png", + "idiom": "ipad", + "scale": "1x", + "size": "40x40" + }, + { + "filename": "BurrowPanel06-80.png", + "idiom": "ipad", + "scale": "2x", + "size": "40x40" + }, + { + "filename": "BurrowPanel06-50.png", + "idiom": "ipad", + "scale": "1x", + "size": "50x50" + }, + { + "filename": "BurrowPanel06-100.png", + "idiom": "ipad", + "scale": "2x", + "size": "50x50" + }, + { + "filename": "BurrowPanel06-72.png", + "idiom": "ipad", + "scale": "1x", + "size": "72x72" + }, + { + "filename": "BurrowPanel06-144.png", + "idiom": "ipad", + "scale": "2x", + "size": "72x72" + }, + { + "filename": "BurrowPanel06-76.png", + "idiom": "ipad", + "scale": "1x", + "size": "76x76" + }, + { + "filename": "BurrowPanel06-152.png", + "idiom": "ipad", + "scale": "2x", + "size": "76x76" + }, + { + "filename": "BurrowPanel06-167.png", + "idiom": "ipad", + "scale": "2x", + "size": "83.5x83.5" + }, + { + "filename": "BurrowPanel06-1024.png", + "idiom": "ios-marketing", + "scale": "1x", + "size": "1024x1024" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06Preview.imageset/Contents.json b/Apple/UI/Assets.xcassets/BurrowPanel06Preview.imageset/Contents.json new file mode 100644 index 0000000..d6ee58c --- /dev/null +++ b/Apple/UI/Assets.xcassets/BurrowPanel06Preview.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images": [ + { + "filename": "preview.png", + "idiom": "universal", + "scale": "1x" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/Apple/UI/Assets.xcassets/BurrowPanel06Preview.imageset/preview.png b/Apple/UI/Assets.xcassets/BurrowPanel06Preview.imageset/preview.png new file mode 100644 index 0000000..7c63df0 Binary files /dev/null and b/Apple/UI/Assets.xcassets/BurrowPanel06Preview.imageset/preview.png differ diff --git a/Apple/UI/BurrowView.swift b/Apple/UI/BurrowView.swift index e15d3f7..8145928 100644 --- a/Apple/UI/BurrowView.swift +++ b/Apple/UI/BurrowView.swift @@ -4,17 +4,26 @@ import SwiftUI #if canImport(AuthenticationServices) import AuthenticationServices #endif -#if canImport(UIKit) -import UIKit -#elseif canImport(AppKit) -import AppKit -#endif + +@MainActor +public protocol AppIconManaging { + var supportsAlternateIcons: Bool { get } + var alternateIconName: String? { get } + func setAlternateIconName(_ iconName: String?) async throws +} public struct BurrowView: View { + private let appIconManager: (any AppIconManaging)? + @State private var networkViewModel: NetworkViewModel @State private var accountStore = NetworkAccountStore() @State private var activeSheet: ConfigurationSheet? @State private var didRunAutomation = false + #if os(iOS) + @State private var selectedAppIconName: String? + @State private var appIconError: String? + @State private var isSettingAppIcon = false + #endif public var body: some View { NavigationStack { @@ -56,6 +65,10 @@ public struct BurrowView: View { quickAddSection } + if showsAppIconSection { + appIconSection + } + VStack(alignment: .leading, spacing: 12) { sectionHeader( title: "Networks", @@ -121,10 +134,12 @@ public struct BurrowView: View { } .onAppear { runAutomationIfNeeded() + refreshAppIconSelection() } } - public init() { + public init(appIconManager: (any AppIconManaging)? = nil) { + self.appIconManager = appIconManager _networkViewModel = State( initialValue: NetworkViewModel( socketURLResult: Result { try Constants.socketURL } @@ -143,6 +158,12 @@ public struct BurrowView: View { activeSheet = .tailnet } + private func refreshAppIconSelection() { + #if os(iOS) + selectedAppIconName = appIconManager?.alternateIconName + #endif + } + @ViewBuilder private var quickAddSection: some View { VStack(alignment: .leading, spacing: 12) { @@ -157,6 +178,81 @@ public struct BurrowView: View { } } + @ViewBuilder + private var appIconSection: some View { + #if os(iOS) + VStack(alignment: .leading, spacing: 12) { + sectionHeader(title: "App Icon", detail: nil) + LazyVGrid( + columns: [GridItem(.adaptive(minimum: 86), spacing: 12)], + alignment: .leading, + spacing: 12 + ) { + ForEach(AppIconChoice.allCases) { choice in + let isSelected = selectedAppIconName == choice.alternateIconName + Button { + setAppIcon(choice) + } label: { + VStack(spacing: 8) { + Image(choice.previewAssetName) + .resizable() + .aspectRatio(1, contentMode: .fit) + .frame(width: 72, height: 72) + .clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous)) + .overlay { + RoundedRectangle(cornerRadius: 16, style: .continuous) + .stroke(isSelected ? Color.accentColor : Color.clear, lineWidth: 3) + } + .shadow(color: .black.opacity(0.18), radius: 5, y: 2) + Text(choice.title) + .font(.caption2.weight(.semibold)) + .foregroundStyle(isSelected ? Color.accentColor : Color.primary) + .lineLimit(1) + .minimumScaleFactor(0.75) + } + .frame(width: 86, height: 104) + .contentShape(Rectangle()) + } + .buttonStyle(.plain) + .disabled(isSettingAppIcon) + .accessibilityLabel(choice.accessibilityLabel) + } + } + if let appIconError { + Text(appIconError) + .font(.footnote) + .foregroundStyle(.secondary) + } + } + #else + EmptyView() + #endif + } + + #if os(iOS) + private func setAppIcon(_ choice: AppIconChoice) { + guard let appIconManager, appIconManager.supportsAlternateIcons else { + return + } + guard selectedAppIconName != choice.alternateIconName else { + return + } + + isSettingAppIcon = true + appIconError = nil + Task { @MainActor in + do { + try await appIconManager.setAlternateIconName(choice.alternateIconName) + selectedAppIconName = appIconManager.alternateIconName + } catch { + appIconError = error.localizedDescription + selectedAppIconName = appIconManager.alternateIconName + } + isSettingAppIcon = false + } + } + #endif + @ViewBuilder private func sectionHeader(title: String, detail: String?) -> some View { VStack(alignment: .leading, spacing: 4) { @@ -193,6 +289,80 @@ public struct BurrowView: View { true #endif } + + private var showsAppIconSection: Bool { + #if os(iOS) + appIconManager?.supportsAlternateIcons == true + #else + false + #endif + } +} + +private enum AppIconChoice: CaseIterable, Identifiable { + case guardian + case field + case burrow + case sentinel + case stride + case post + + var id: String { previewAssetName } + + var title: String { + switch self { + case .guardian: + "Guardian" + case .field: + "Field" + case .burrow: + "Burrow" + case .sentinel: + "Sentinel" + case .stride: + "Stride" + case .post: + "Post" + } + } + + var previewAssetName: String { + switch self { + case .guardian: + "BurrowPanel01Preview" + case .field: + "BurrowPanel02Preview" + case .burrow: + "BurrowPanel03Preview" + case .sentinel: + "BurrowPanel04Preview" + case .stride: + "BurrowPanel05Preview" + case .post: + "BurrowPanel06Preview" + } + } + + var alternateIconName: String? { + switch self { + case .guardian: + nil + case .field: + "BurrowPanel02" + case .burrow: + "BurrowPanel03" + case .sentinel: + "BurrowPanel04" + case .stride: + "BurrowPanel05" + case .post: + "BurrowPanel06" + } + } + + var accessibilityLabel: String { + "\(title) app icon" + } } private enum ConfigurationSheet: String, CaseIterable, Identifiable { diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000..d67b251 --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,69 @@ +filegroup( + name = "apple_project_files", + srcs = glob( + [ + "Apple/**", + "Scripts/ci/install-apple-signing-assets.sh", + "Scripts/ci/package-apple-artifacts.sh", + "Scripts/version.sh", + ], + exclude = [ + "Apple/build/**", + "Apple/**/xcuserdata/**", + ], + ), + visibility = ["//visibility:public"], +) + +filegroup( + name = "android_project_files", + srcs = glob( + [ + "Android/**", + ], + exclude = [ + "Android/.gradle/**", + "Android/**/build/**", + ], + ), + visibility = ["//visibility:public"], +) + +filegroup( + name = "mobile_rust_core_files", + srcs = glob( + [ + "crates/burrow-core/**", + "crates/burrow-mobile-ffi/**", + ], + ) + [ + "Cargo.lock", + "Cargo.toml", + "rust-toolchain.toml", + ], + visibility = ["//visibility:public"], +) + +alias( + name = "apple_release_ios", + actual = "//bazel/apple:release_ios_stamp", + visibility = ["//visibility:public"], +) + +alias( + name = "apple_release_macos", + actual = "//bazel/apple:release_macos_stamp", + visibility = ["//visibility:public"], +) + +alias( + name = "apple_release_all", + actual = "//bazel/apple:release_all_stamp", + visibility = ["//visibility:public"], +) + +alias( + name = "android_check_stub", + actual = "//bazel/android:check_stub_stamp", + visibility = ["//visibility:public"], +) diff --git a/Cargo.lock b/Cargo.lock index 2950701..020c072 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -767,6 +767,22 @@ dependencies = [ "x25519-dalek", ] +[[package]] +name = "burrow-core" +version = "0.1.0" + +[[package]] +name = "burrow-mobile-ffi" +version = "0.1.0" +dependencies = [ + "burrow-core", + "jni", +] + +[[package]] +name = "burrow-windows-stub" +version = "0.1.0" + [[package]] name = "by_address" version = "1.2.1" @@ -845,6 +861,12 @@ dependencies = [ "shlex", ] +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + [[package]] name = "cexpr" version = "0.6.0" @@ -1008,6 +1030,16 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes", + "memchr", +] + [[package]] name = "compression-codecs" version = "0.4.32" @@ -2944,6 +2976,50 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys 0.3.1", + "log", + "thiserror 1.0.69", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258" +dependencies = [ + "jni-sys 0.4.1", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn 2.0.106", +] + [[package]] name = "jobserver" version = "0.1.34" @@ -7471,6 +7547,15 @@ dependencies = [ "windows-link 0.2.1", ] +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -7516,6 +7601,21 @@ dependencies = [ "windows-link 0.2.1", ] +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -7573,6 +7673,12 @@ dependencies = [ "windows-link 0.1.3", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -7591,6 +7697,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -7609,6 +7721,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -7639,6 +7757,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -7657,6 +7781,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -7675,6 +7805,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -7693,6 +7829,12 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" diff --git a/Cargo.toml b/Cargo.toml index 362ba2b..13b3e08 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,11 @@ [workspace] -members = ["burrow", "tun"] +members = [ + "burrow", + "tun", + "crates/burrow-core", + "crates/burrow-mobile-ffi", + "crates/burrow-windows-stub", +] resolver = "2" exclude = ["burrow-gtk"] diff --git a/Dockerfile b/Dockerfile index 3497e22..2c4415e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -85,8 +85,8 @@ LABEL \ # https://github.com/opencontainers/image-spec/blob/master/annotations.md org.opencontainers.image.title="burrow" \ org.opencontainers.image.description="Burrow is an open source tool for burrowing through firewalls, built by teenagers at Hack Club." \ - org.opencontainers.image.url="https://github.com/hackclub/burrow" \ - org.opencontainers.image.source="https://github.com/hackclub/burrow" \ + org.opencontainers.image.url="https://git.burrow.net/hackclub/burrow" \ + org.opencontainers.image.source="https://git.burrow.net/hackclub/burrow" \ org.opencontainers.image.vendor="hackclub" \ org.opencontainers.image.licenses="GPL-3.0" diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..03e942e --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,7 @@ +module( + name = "burrow", + version = "0.1.0", +) + +bazel_dep(name = "platforms", version = "1.0.0") +bazel_dep(name = "rules_shell", version = "0.6.1") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock new file mode 100644 index 0000000..28f5c18 --- /dev/null +++ b/MODULE.bazel.lock @@ -0,0 +1,448 @@ +{ + "lockFileVersion": 26, + "registryFileHashes": { + "https://bcr.bazel.build/bazel_registry.json": "8a28e4aff06ee60aed2a8c281907fb8bcbf3b753c91fb5a5c57da3215d5b3497", + "https://bcr.bazel.build/modules/abseil-cpp/20210324.2/MODULE.bazel": "7cd0312e064fde87c8d1cd79ba06c876bd23630c83466e9500321be55c96ace2", + "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/MODULE.bazel": "70390338f7a5106231d20620712f7cccb659cd0e9d073d1991c038eb9fc57589", + "https://bcr.bazel.build/modules/abseil-cpp/20230125.1/MODULE.bazel": "89047429cb0207707b2dface14ba7f8df85273d484c2572755be4bab7ce9c3a0", + "https://bcr.bazel.build/modules/abseil-cpp/20230802.0.bcr.1/MODULE.bazel": "1c8cec495288dccd14fdae6e3f95f772c1c91857047a098fad772034264cc8cb", + "https://bcr.bazel.build/modules/abseil-cpp/20230802.0/MODULE.bazel": "d253ae36a8bd9ee3c5955384096ccb6baf16a1b1e93e858370da0a3b94f77c16", + "https://bcr.bazel.build/modules/abseil-cpp/20230802.1/MODULE.bazel": "fa92e2eb41a04df73cdabeec37107316f7e5272650f81d6cc096418fe647b915", + "https://bcr.bazel.build/modules/abseil-cpp/20240116.1/MODULE.bazel": "37bcdb4440fbb61df6a1c296ae01b327f19e9bb521f9b8e26ec854b6f97309ed", + "https://bcr.bazel.build/modules/abseil-cpp/20240116.2/MODULE.bazel": "73939767a4686cd9a520d16af5ab440071ed75cec1a876bf2fcfaf1f71987a16", + "https://bcr.bazel.build/modules/abseil-cpp/20250127.1/MODULE.bazel": "c4a89e7ceb9bf1e25cf84a9f830ff6b817b72874088bf5141b314726e46a57c1", + "https://bcr.bazel.build/modules/abseil-cpp/20250512.1/MODULE.bazel": "d209fdb6f36ffaf61c509fcc81b19e81b411a999a934a032e10cd009a0226215", + "https://bcr.bazel.build/modules/abseil-cpp/20250814.1/MODULE.bazel": "51f2312901470cdab0dbdf3b88c40cd21c62a7ed58a3de45b365ddc5b11bcab2", + "https://bcr.bazel.build/modules/abseil-cpp/20250814.1/source.json": "cea3901d7e299da7320700abbaafe57a65d039f10d0d7ea601c4a66938ea4b0c", + "https://bcr.bazel.build/modules/apple_support/1.11.1/MODULE.bazel": "1843d7cd8a58369a444fc6000e7304425fba600ff641592161d9f15b179fb896", + "https://bcr.bazel.build/modules/apple_support/1.15.1/MODULE.bazel": "a0556fefca0b1bb2de8567b8827518f94db6a6e7e7d632b4c48dc5f865bc7c85", + "https://bcr.bazel.build/modules/apple_support/1.21.0/MODULE.bazel": "ac1824ed5edf17dee2fdd4927ada30c9f8c3b520be1b5fd02a5da15bc10bff3e", + "https://bcr.bazel.build/modules/apple_support/1.21.1/MODULE.bazel": "5809fa3efab15d1f3c3c635af6974044bac8a4919c62238cce06acee8a8c11f1", + "https://bcr.bazel.build/modules/apple_support/1.24.2/MODULE.bazel": "0e62471818affb9f0b26f128831d5c40b074d32e6dda5a0d3852847215a41ca4", + "https://bcr.bazel.build/modules/apple_support/1.24.2/source.json": "2c22c9827093250406c5568da6c54e6fdf0ef06238def3d99c71b12feb057a8d", + "https://bcr.bazel.build/modules/bazel_features/1.1.1/MODULE.bazel": "27b8c79ef57efe08efccbd9dd6ef70d61b4798320b8d3c134fd571f78963dbcd", + "https://bcr.bazel.build/modules/bazel_features/1.10.0/MODULE.bazel": "f75e8807570484a99be90abcd52b5e1f390362c258bcb73106f4544957a48101", + "https://bcr.bazel.build/modules/bazel_features/1.11.0/MODULE.bazel": "f9382337dd5a474c3b7d334c2f83e50b6eaedc284253334cf823044a26de03e8", + "https://bcr.bazel.build/modules/bazel_features/1.15.0/MODULE.bazel": "d38ff6e517149dc509406aca0db3ad1efdd890a85e049585b7234d04238e2a4d", + "https://bcr.bazel.build/modules/bazel_features/1.17.0/MODULE.bazel": "039de32d21b816b47bd42c778e0454217e9c9caac4a3cf8e15c7231ee3ddee4d", + "https://bcr.bazel.build/modules/bazel_features/1.18.0/MODULE.bazel": "1be0ae2557ab3a72a57aeb31b29be347bcdc5d2b1eb1e70f39e3851a7e97041a", + "https://bcr.bazel.build/modules/bazel_features/1.19.0/MODULE.bazel": "59adcdf28230d220f0067b1f435b8537dd033bfff8db21335ef9217919c7fb58", + "https://bcr.bazel.build/modules/bazel_features/1.21.0/MODULE.bazel": "675642261665d8eea09989aa3b8afb5c37627f1be178382c320d1b46afba5e3b", + "https://bcr.bazel.build/modules/bazel_features/1.23.0/MODULE.bazel": "fd1ac84bc4e97a5a0816b7fd7d4d4f6d837b0047cf4cbd81652d616af3a6591a", + "https://bcr.bazel.build/modules/bazel_features/1.27.0/MODULE.bazel": "621eeee06c4458a9121d1f104efb80f39d34deff4984e778359c60eaf1a8cb65", + "https://bcr.bazel.build/modules/bazel_features/1.28.0/MODULE.bazel": "4b4200e6cbf8fa335b2c3f43e1d6ef3e240319c33d43d60cc0fbd4b87ece299d", + "https://bcr.bazel.build/modules/bazel_features/1.3.0/MODULE.bazel": "cdcafe83ec318cda34e02948e81d790aab8df7a929cec6f6969f13a489ccecd9", + "https://bcr.bazel.build/modules/bazel_features/1.30.0/MODULE.bazel": "a14b62d05969a293b80257e72e597c2da7f717e1e69fa8b339703ed6731bec87", + "https://bcr.bazel.build/modules/bazel_features/1.33.0/MODULE.bazel": "8b8dc9d2a4c88609409c3191165bccec0e4cb044cd7a72ccbe826583303459f6", + "https://bcr.bazel.build/modules/bazel_features/1.4.1/MODULE.bazel": "e45b6bb2350aff3e442ae1111c555e27eac1d915e77775f6fdc4b351b758b5d7", + "https://bcr.bazel.build/modules/bazel_features/1.42.1/MODULE.bazel": "275a59b5406ff18c01739860aa70ad7ccb3cfb474579411decca11c93b951080", + "https://bcr.bazel.build/modules/bazel_features/1.42.1/source.json": "fcd4396b2df85f64f2b3bb436ad870793ecf39180f1d796f913cc9276d355309", + "https://bcr.bazel.build/modules/bazel_features/1.9.1/MODULE.bazel": "8f679097876a9b609ad1f60249c49d68bfab783dd9be012faf9d82547b14815a", + "https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8", + "https://bcr.bazel.build/modules/bazel_skylib/1.1.1/MODULE.bazel": "1add3e7d93ff2e6998f9e118022c84d163917d912f5afafb3058e3d2f1545b5e", + "https://bcr.bazel.build/modules/bazel_skylib/1.2.0/MODULE.bazel": "44fe84260e454ed94ad326352a698422dbe372b21a1ac9f3eab76eb531223686", + "https://bcr.bazel.build/modules/bazel_skylib/1.2.1/MODULE.bazel": "f35baf9da0efe45fa3da1696ae906eea3d615ad41e2e3def4aeb4e8bc0ef9a7a", + "https://bcr.bazel.build/modules/bazel_skylib/1.3.0/MODULE.bazel": "20228b92868bf5cfc41bda7afc8a8ba2a543201851de39d990ec957b513579c5", + "https://bcr.bazel.build/modules/bazel_skylib/1.4.1/MODULE.bazel": "a0dcb779424be33100dcae821e9e27e4f2901d9dfd5333efe5ac6a8d7ab75e1d", + "https://bcr.bazel.build/modules/bazel_skylib/1.4.2/MODULE.bazel": "3bd40978e7a1fac911d5989e6b09d8f64921865a45822d8b09e815eaa726a651", + "https://bcr.bazel.build/modules/bazel_skylib/1.5.0/MODULE.bazel": "32880f5e2945ce6a03d1fbd588e9198c0a959bb42297b2cfaf1685b7bc32e138", + "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/MODULE.bazel": "8fdee2dbaace6c252131c00e1de4b165dc65af02ea278476187765e1a617b917", + "https://bcr.bazel.build/modules/bazel_skylib/1.7.0/MODULE.bazel": "0db596f4563de7938de764cc8deeabec291f55e8ec15299718b93c4423e9796d", + "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/MODULE.bazel": "3120d80c5861aa616222ec015332e5f8d3171e062e3e804a2a0253e1be26e59b", + "https://bcr.bazel.build/modules/bazel_skylib/1.8.1/MODULE.bazel": "88ade7293becda963e0e3ea33e7d54d3425127e0a326e0d17da085a5f1f03ff6", + "https://bcr.bazel.build/modules/bazel_skylib/1.8.2/MODULE.bazel": "69ad6927098316848b34a9142bcc975e018ba27f08c4ff403f50c1b6e646ca67", + "https://bcr.bazel.build/modules/bazel_skylib/1.8.2/source.json": "34a3c8bcf233b835eb74be9d628899bb32999d3e0eadef1947a0a562a2b16ffb", + "https://bcr.bazel.build/modules/buildozer/8.5.1/MODULE.bazel": "a35d9561b3fc5b18797c330793e99e3b834a473d5fbd3d7d7634aafc9bdb6f8f", + "https://bcr.bazel.build/modules/buildozer/8.5.1/source.json": "e3386e6ff4529f2442800dee47ad28d3e6487f36a1f75ae39ae56c70f0cd2fbd", + "https://bcr.bazel.build/modules/google_benchmark/1.8.2/MODULE.bazel": "a70cf1bba851000ba93b58ae2f6d76490a9feb74192e57ab8e8ff13c34ec50cb", + "https://bcr.bazel.build/modules/googletest/1.11.0/MODULE.bazel": "3a83f095183f66345ca86aa13c58b59f9f94a2f81999c093d4eeaa2d262d12f4", + "https://bcr.bazel.build/modules/googletest/1.14.0.bcr.1/MODULE.bazel": "22c31a561553727960057361aa33bf20fb2e98584bc4fec007906e27053f80c6", + "https://bcr.bazel.build/modules/googletest/1.14.0/MODULE.bazel": "cfbcbf3e6eac06ef9d85900f64424708cc08687d1b527f0ef65aa7517af8118f", + "https://bcr.bazel.build/modules/googletest/1.15.2/MODULE.bazel": "6de1edc1d26cafb0ea1a6ab3f4d4192d91a312fd2d360b63adaa213cd00b2108", + "https://bcr.bazel.build/modules/googletest/1.17.0/MODULE.bazel": "dbec758171594a705933a29fcf69293d2468c49ec1f2ebca65c36f504d72df46", + "https://bcr.bazel.build/modules/googletest/1.17.0/source.json": "38e4454b25fc30f15439c0378e57909ab1fd0a443158aa35aec685da727cd713", + "https://bcr.bazel.build/modules/jsoncpp/1.9.5/MODULE.bazel": "31271aedc59e815656f5736f282bb7509a97c7ecb43e927ac1a37966e0578075", + "https://bcr.bazel.build/modules/jsoncpp/1.9.6/MODULE.bazel": "2f8d20d3b7d54143213c4dfc3d98225c42de7d666011528dc8fe91591e2e17b0", + "https://bcr.bazel.build/modules/jsoncpp/1.9.6/source.json": "a04756d367a2126c3541682864ecec52f92cdee80a35735a3cb249ce015ca000", + "https://bcr.bazel.build/modules/libpfm/4.11.0/MODULE.bazel": "45061ff025b301940f1e30d2c16bea596c25b176c8b6b3087e92615adbd52902", + "https://bcr.bazel.build/modules/nlohmann_json/3.6.1/MODULE.bazel": "6f7b417dcc794d9add9e556673ad25cb3ba835224290f4f848f8e2db1e1fca74", + "https://bcr.bazel.build/modules/nlohmann_json/3.6.1/source.json": "f448c6e8963fdfa7eb831457df83ad63d3d6355018f6574fb017e8169deb43a9", + "https://bcr.bazel.build/modules/platforms/0.0.10/MODULE.bazel": "8cb8efaf200bdeb2150d93e162c40f388529a25852b332cec879373771e48ed5", + "https://bcr.bazel.build/modules/platforms/0.0.11/MODULE.bazel": "0daefc49732e227caa8bfa834d65dc52e8cc18a2faf80df25e8caea151a9413f", + "https://bcr.bazel.build/modules/platforms/0.0.4/MODULE.bazel": "9b328e31ee156f53f3c416a64f8491f7eb731742655a47c9eec4703a71644aee", + "https://bcr.bazel.build/modules/platforms/0.0.5/MODULE.bazel": "5733b54ea419d5eaf7997054bb55f6a1d0b5ff8aedf0176fef9eea44f3acda37", + "https://bcr.bazel.build/modules/platforms/0.0.6/MODULE.bazel": "ad6eeef431dc52aefd2d77ed20a4b353f8ebf0f4ecdd26a807d2da5aa8cd0615", + "https://bcr.bazel.build/modules/platforms/0.0.7/MODULE.bazel": "72fd4a0ede9ee5c021f6a8dd92b503e089f46c227ba2813ff183b71616034814", + "https://bcr.bazel.build/modules/platforms/0.0.8/MODULE.bazel": "9f142c03e348f6d263719f5074b21ef3adf0b139ee4c5133e2aa35664da9eb2d", + "https://bcr.bazel.build/modules/platforms/0.0.9/MODULE.bazel": "4a87a60c927b56ddd67db50c89acaa62f4ce2a1d2149ccb63ffd871d5ce29ebc", + "https://bcr.bazel.build/modules/platforms/1.0.0/MODULE.bazel": "f05feb42b48f1b3c225e4ccf351f367be0371411a803198ec34a389fb22aa580", + "https://bcr.bazel.build/modules/platforms/1.0.0/source.json": "f4ff1fd412e0246fd38c82328eb209130ead81d62dcd5a9e40910f867f733d96", + "https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel": "a5a29bb89544f9b97edce05642fac225a808b5b7be74038ea3640fae2f8e66a7", + "https://bcr.bazel.build/modules/protobuf/27.0/MODULE.bazel": "7873b60be88844a0a1d8f80b9d5d20cfbd8495a689b8763e76c6372998d3f64c", + "https://bcr.bazel.build/modules/protobuf/29.0-rc2/MODULE.bazel": "6241d35983510143049943fc0d57937937122baf1b287862f9dc8590fc4c37df", + "https://bcr.bazel.build/modules/protobuf/29.0-rc3/MODULE.bazel": "33c2dfa286578573afc55a7acaea3cada4122b9631007c594bf0729f41c8de92", + "https://bcr.bazel.build/modules/protobuf/29.1/MODULE.bazel": "557c3457560ff49e122ed76c0bc3397a64af9574691cb8201b4e46d4ab2ecb95", + "https://bcr.bazel.build/modules/protobuf/3.19.0/MODULE.bazel": "6b5fbb433f760a99a22b18b6850ed5784ef0e9928a72668b66e4d7ccd47db9b0", + "https://bcr.bazel.build/modules/protobuf/32.1/MODULE.bazel": "89cd2866a9cb07fee9ff74c41ceace11554f32e0d849de4e23ac55515cfada4d", + "https://bcr.bazel.build/modules/protobuf/33.4/MODULE.bazel": "114775b816b38b6d0ca620450d6b02550c60ceedfdc8d9a229833b34a223dc42", + "https://bcr.bazel.build/modules/protobuf/33.4/source.json": "555f8686b4c7d6b5ba731fbea13bf656b4bfd9a7ff629c1d9d3f6e1d6155de79", + "https://bcr.bazel.build/modules/pybind11_bazel/2.11.1/MODULE.bazel": "88af1c246226d87e65be78ed49ecd1e6f5e98648558c14ce99176da041dc378e", + "https://bcr.bazel.build/modules/pybind11_bazel/2.12.0/MODULE.bazel": "e6f4c20442eaa7c90d7190d8dc539d0ab422f95c65a57cc59562170c58ae3d34", + "https://bcr.bazel.build/modules/pybind11_bazel/2.12.0/source.json": "6900fdc8a9e95866b8c0d4ad4aba4d4236317b5c1cd04c502df3f0d33afed680", + "https://bcr.bazel.build/modules/re2/2023-09-01/MODULE.bazel": "cb3d511531b16cfc78a225a9e2136007a48cf8a677e4264baeab57fe78a80206", + "https://bcr.bazel.build/modules/re2/2024-07-02.bcr.1/MODULE.bazel": "b4963dda9b31080be1905ef085ecd7dd6cd47c05c79b9cdf83ade83ab2ab271a", + "https://bcr.bazel.build/modules/re2/2024-07-02.bcr.1/source.json": "2ff292be6ef3340325ce8a045ecc326e92cbfab47c7cbab4bd85d28971b97ac4", + "https://bcr.bazel.build/modules/re2/2024-07-02/MODULE.bazel": "0eadc4395959969297cbcf31a249ff457f2f1d456228c67719480205aa306daa", + "https://bcr.bazel.build/modules/rules_android/0.1.1/MODULE.bazel": "48809ab0091b07ad0182defb787c4c5328bd3a278938415c00a7b69b50c4d3a8", + "https://bcr.bazel.build/modules/rules_android/0.1.1/source.json": "e6986b41626ee10bdc864937ffb6d6bf275bb5b9c65120e6137d56e6331f089e", + "https://bcr.bazel.build/modules/rules_apple/3.16.0/MODULE.bazel": "0d1caf0b8375942ce98ea944be754a18874041e4e0459401d925577624d3a54a", + "https://bcr.bazel.build/modules/rules_apple/4.1.0/MODULE.bazel": "76e10fd4a48038d3fc7c5dc6e63b7063bbf5304a2e3bd42edda6ec660eebea68", + "https://bcr.bazel.build/modules/rules_apple/4.1.0/source.json": "8ee81e1708756f81b343a5eb2b2f0b953f1d25c4ab3d4a68dc02754872e80715", + "https://bcr.bazel.build/modules/rules_cc/0.0.1/MODULE.bazel": "cb2aa0747f84c6c3a78dad4e2049c154f08ab9d166b1273835a8174940365647", + "https://bcr.bazel.build/modules/rules_cc/0.0.10/MODULE.bazel": "ec1705118f7eaedd6e118508d3d26deba2a4e76476ada7e0e3965211be012002", + "https://bcr.bazel.build/modules/rules_cc/0.0.13/MODULE.bazel": "0e8529ed7b323dad0775ff924d2ae5af7640b23553dfcd4d34344c7e7a867191", + "https://bcr.bazel.build/modules/rules_cc/0.0.15/MODULE.bazel": "6704c35f7b4a72502ee81f61bf88706b54f06b3cbe5558ac17e2e14666cd5dcc", + "https://bcr.bazel.build/modules/rules_cc/0.0.16/MODULE.bazel": "7661303b8fc1b4d7f532e54e9d6565771fea666fbdf839e0a86affcd02defe87", + "https://bcr.bazel.build/modules/rules_cc/0.0.17/MODULE.bazel": "2ae1d8f4238ec67d7185d8861cb0a2cdf4bc608697c331b95bf990e69b62e64a", + "https://bcr.bazel.build/modules/rules_cc/0.0.2/MODULE.bazel": "6915987c90970493ab97393024c156ea8fb9f3bea953b2f3ec05c34f19b5695c", + "https://bcr.bazel.build/modules/rules_cc/0.0.6/MODULE.bazel": "abf360251023dfe3efcef65ab9d56beefa8394d4176dd29529750e1c57eaa33f", + "https://bcr.bazel.build/modules/rules_cc/0.0.8/MODULE.bazel": "964c85c82cfeb6f3855e6a07054fdb159aced38e99a5eecf7bce9d53990afa3e", + "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5", + "https://bcr.bazel.build/modules/rules_cc/0.1.1/MODULE.bazel": "2f0222a6f229f0bf44cd711dc13c858dad98c62d52bd51d8fc3a764a83125513", + "https://bcr.bazel.build/modules/rules_cc/0.1.2/MODULE.bazel": "557ddc3a96858ec0d465a87c0a931054d7dcfd6583af2c7ed3baf494407fd8d0", + "https://bcr.bazel.build/modules/rules_cc/0.1.5/MODULE.bazel": "88dfc9361e8b5ae1008ac38f7cdfd45ad738e4fa676a3ad67d19204f045a1fd8", + "https://bcr.bazel.build/modules/rules_cc/0.2.0/MODULE.bazel": "b5c17f90458caae90d2ccd114c81970062946f49f355610ed89bebf954f5783c", + "https://bcr.bazel.build/modules/rules_cc/0.2.13/MODULE.bazel": "eecdd666eda6be16a8d9dc15e44b5c75133405e820f620a234acc4b1fdc5aa37", + "https://bcr.bazel.build/modules/rules_cc/0.2.17/MODULE.bazel": "1849602c86cb60da8613d2de887f9566a6d354a6df6d7009f9d04a14402f9a84", + "https://bcr.bazel.build/modules/rules_cc/0.2.17/source.json": "3832f45d145354049137c0090df04629d9c2b5493dc5c2bf46f1834040133a07", + "https://bcr.bazel.build/modules/rules_cc/0.2.8/MODULE.bazel": "f1df20f0bf22c28192a794f29b501ee2018fa37a3862a1a2132ae2940a23a642", + "https://bcr.bazel.build/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "c9e8c682bf75b0e7c704166d79b599f93b72cfca5ad7477df596947891feeef6", + "https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/MODULE.bazel": "40c97d1144356f52905566c55811f13b299453a14ac7769dfba2ac38192337a8", + "https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74", + "https://bcr.bazel.build/modules/rules_java/5.3.5/MODULE.bazel": "a4ec4f2db570171e3e5eb753276ee4b389bae16b96207e9d3230895c99644b86", + "https://bcr.bazel.build/modules/rules_java/6.5.2/MODULE.bazel": "1d440d262d0e08453fa0c4d8f699ba81609ed0e9a9a0f02cd10b3e7942e61e31", + "https://bcr.bazel.build/modules/rules_java/7.10.0/MODULE.bazel": "530c3beb3067e870561739f1144329a21c851ff771cd752a49e06e3dc9c2e71a", + "https://bcr.bazel.build/modules/rules_java/7.12.2/MODULE.bazel": "579c505165ee757a4280ef83cda0150eea193eed3bef50b1004ba88b99da6de6", + "https://bcr.bazel.build/modules/rules_java/7.2.0/MODULE.bazel": "06c0334c9be61e6cef2c8c84a7800cef502063269a5af25ceb100b192453d4ab", + "https://bcr.bazel.build/modules/rules_java/7.6.1/MODULE.bazel": "2f14b7e8a1aa2f67ae92bc69d1ec0fa8d9f827c4e17ff5e5f02e91caa3b2d0fe", + "https://bcr.bazel.build/modules/rules_java/8.3.2/MODULE.bazel": "7336d5511ad5af0b8615fdc7477535a2e4e723a357b6713af439fe8cf0195017", + "https://bcr.bazel.build/modules/rules_java/8.5.1/MODULE.bazel": "d8a9e38cc5228881f7055a6079f6f7821a073df3744d441978e7a43e20226939", + "https://bcr.bazel.build/modules/rules_java/8.6.1/MODULE.bazel": "f4808e2ab5b0197f094cabce9f4b006a27766beb6a9975931da07099560ca9c2", + "https://bcr.bazel.build/modules/rules_java/9.1.0/MODULE.bazel": "ee63f27e36a3fada80342869361182f120a9819c74320e8e65b1e04ba0cd7a9d", + "https://bcr.bazel.build/modules/rules_java/9.1.0/source.json": "da589573c1dee2c9ac4a568b301269a2e8191110ff0345c1a959fa7ea6c4dfd6", + "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", + "https://bcr.bazel.build/modules/rules_jvm_external/5.1/MODULE.bazel": "33f6f999e03183f7d088c9be518a63467dfd0be94a11d0055fe2d210f89aa909", + "https://bcr.bazel.build/modules/rules_jvm_external/5.2/MODULE.bazel": "d9351ba35217ad0de03816ef3ed63f89d411349353077348a45348b096615036", + "https://bcr.bazel.build/modules/rules_jvm_external/6.3/MODULE.bazel": "c998e060b85f71e00de5ec552019347c8bca255062c990ac02d051bb80a38df0", + "https://bcr.bazel.build/modules/rules_jvm_external/6.7/MODULE.bazel": "e717beabc4d091ecb2c803c2d341b88590e9116b8bf7947915eeb33aab4f96dd", + "https://bcr.bazel.build/modules/rules_jvm_external/6.7/source.json": "5426f412d0a7fc6b611643376c7e4a82dec991491b9ce5cb1cfdd25fe2e92be4", + "https://bcr.bazel.build/modules/rules_kotlin/1.9.6/MODULE.bazel": "d269a01a18ee74d0335450b10f62c9ed81f2321d7958a2934e44272fe82dcef3", + "https://bcr.bazel.build/modules/rules_kotlin/1.9.6/source.json": "2faa4794364282db7c06600b7e5e34867a564ae91bda7cae7c29c64e9466b7d5", + "https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0", + "https://bcr.bazel.build/modules/rules_license/0.0.7/MODULE.bazel": "088fbeb0b6a419005b89cf93fe62d9517c0a2b8bb56af3244af65ecfe37e7d5d", + "https://bcr.bazel.build/modules/rules_license/1.0.0/MODULE.bazel": "a7fda60eefdf3d8c827262ba499957e4df06f659330bbe6cdbdb975b768bb65c", + "https://bcr.bazel.build/modules/rules_license/1.0.0/source.json": "a52c89e54cc311196e478f8382df91c15f7a2bfdf4c6cd0e2675cc2ff0b56efb", + "https://bcr.bazel.build/modules/rules_pkg/0.7.0/MODULE.bazel": "df99f03fc7934a4737122518bb87e667e62d780b610910f0447665a7e2be62dc", + "https://bcr.bazel.build/modules/rules_pkg/1.0.1/MODULE.bazel": "5b1df97dbc29623bccdf2b0dcd0f5cb08e2f2c9050aab1092fd39a41e82686ff", + "https://bcr.bazel.build/modules/rules_pkg/1.0.1/source.json": "bd82e5d7b9ce2d31e380dd9f50c111d678c3bdaca190cb76b0e1c71b05e1ba8a", + "https://bcr.bazel.build/modules/rules_proto/4.0.0/MODULE.bazel": "a7a7b6ce9bee418c1a760b3d84f83a299ad6952f9903c67f19e4edd964894e06", + "https://bcr.bazel.build/modules/rules_proto/5.3.0-21.7/MODULE.bazel": "e8dff86b0971688790ae75528fe1813f71809b5afd57facb44dad9e8eca631b7", + "https://bcr.bazel.build/modules/rules_proto/6.0.0-rc1/MODULE.bazel": "1e5b502e2e1a9e825eef74476a5a1ee524a92297085015a052510b09a1a09483", + "https://bcr.bazel.build/modules/rules_proto/6.0.2/MODULE.bazel": "ce916b775a62b90b61888052a416ccdda405212b6aaeb39522f7dc53431a5e73", + "https://bcr.bazel.build/modules/rules_proto/7.1.0/MODULE.bazel": "002d62d9108f75bb807cd56245d45648f38275cb3a99dcd45dfb864c5d74cb96", + "https://bcr.bazel.build/modules/rules_proto/7.1.0/source.json": "39f89066c12c24097854e8f57ab8558929f9c8d474d34b2c00ac04630ad8940e", + "https://bcr.bazel.build/modules/rules_python/0.10.2/MODULE.bazel": "cc82bc96f2997baa545ab3ce73f196d040ffb8756fd2d66125a530031cd90e5f", + "https://bcr.bazel.build/modules/rules_python/0.23.1/MODULE.bazel": "49ffccf0511cb8414de28321f5fcf2a31312b47c40cc21577144b7447f2bf300", + "https://bcr.bazel.build/modules/rules_python/0.25.0/MODULE.bazel": "72f1506841c920a1afec76975b35312410eea3aa7b63267436bfb1dd91d2d382", + "https://bcr.bazel.build/modules/rules_python/0.28.0/MODULE.bazel": "cba2573d870babc976664a912539b320cbaa7114cd3e8f053c720171cde331ed", + "https://bcr.bazel.build/modules/rules_python/0.31.0/MODULE.bazel": "93a43dc47ee570e6ec9f5779b2e64c1476a6ce921c48cc9a1678a91dd5f8fd58", + "https://bcr.bazel.build/modules/rules_python/0.33.2/MODULE.bazel": "3e036c4ad8d804a4dad897d333d8dce200d943df4827cb849840055be8d2e937", + "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c", + "https://bcr.bazel.build/modules/rules_python/1.3.0/MODULE.bazel": "8361d57eafb67c09b75bf4bbe6be360e1b8f4f18118ab48037f2bd50aa2ccb13", + "https://bcr.bazel.build/modules/rules_python/1.4.1/MODULE.bazel": "8991ad45bdc25018301d6b7e1d3626afc3c8af8aaf4bc04f23d0b99c938b73a6", + "https://bcr.bazel.build/modules/rules_python/1.6.0/MODULE.bazel": "7e04ad8f8d5bea40451cf80b1bd8262552aa73f841415d20db96b7241bd027d8", + "https://bcr.bazel.build/modules/rules_python/1.7.0/MODULE.bazel": "d01f995ecd137abf30238ad9ce97f8fc3ac57289c8b24bd0bf53324d937a14f8", + "https://bcr.bazel.build/modules/rules_python/1.7.0/source.json": "028a084b65dcf8f4dc4f82f8778dbe65df133f234b316828a82e060d81bdce32", + "https://bcr.bazel.build/modules/rules_shell/0.2.0/MODULE.bazel": "fda8a652ab3c7d8fee214de05e7a9916d8b28082234e8d2c0094505c5268ed3c", + "https://bcr.bazel.build/modules/rules_shell/0.3.0/MODULE.bazel": "de4402cd12f4cc8fda2354fce179fdb068c0b9ca1ec2d2b17b3e21b24c1a937b", + "https://bcr.bazel.build/modules/rules_shell/0.6.1/MODULE.bazel": "72e76b0eea4e81611ef5452aa82b3da34caca0c8b7b5c0c9584338aa93bae26b", + "https://bcr.bazel.build/modules/rules_shell/0.6.1/source.json": "20ec05cd5e592055e214b2da8ccb283c7f2a421ea0dc2acbf1aa792e11c03d0c", + "https://bcr.bazel.build/modules/rules_swift/1.16.0/MODULE.bazel": "4a09f199545a60d09895e8281362b1ff3bb08bbde69c6fc87aff5b92fcc916ca", + "https://bcr.bazel.build/modules/rules_swift/2.1.1/MODULE.bazel": "494900a80f944fc7aa61500c2073d9729dff0b764f0e89b824eb746959bc1046", + "https://bcr.bazel.build/modules/rules_swift/2.4.0/MODULE.bazel": "1639617eb1ede28d774d967a738b4a68b0accb40650beadb57c21846beab5efd", + "https://bcr.bazel.build/modules/rules_swift/3.1.2/MODULE.bazel": "72c8f5cf9d26427cee6c76c8e3853eb46ce6b0412a081b2b6db6e8ad56267400", + "https://bcr.bazel.build/modules/rules_swift/3.1.2/source.json": "e85761f3098a6faf40b8187695e3de6d97944e98abd0d8ce579cb2daf6319a66", + "https://bcr.bazel.build/modules/stardoc/0.5.1/MODULE.bazel": "1a05d92974d0c122f5ccf09291442580317cdd859f07a8655f1db9a60374f9f8", + "https://bcr.bazel.build/modules/stardoc/0.5.3/MODULE.bazel": "c7f6948dae6999bf0db32c1858ae345f112cacf98f174c7a8bb707e41b974f1c", + "https://bcr.bazel.build/modules/stardoc/0.7.0/MODULE.bazel": "05e3d6d30c099b6770e97da986c53bd31844d7f13d41412480ea265ac9e8079c", + "https://bcr.bazel.build/modules/stardoc/0.7.2/MODULE.bazel": "fc152419aa2ea0f51c29583fab1e8c99ddefd5b3778421845606ee628629e0e5", + "https://bcr.bazel.build/modules/stardoc/0.7.2/source.json": "58b029e5e901d6802967754adf0a9056747e8176f017cfe3607c0851f4d42216", + "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.1/MODULE.bazel": "5e463fbfba7b1701d957555ed45097d7f984211330106ccd1352c6e0af0dcf91", + "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.2/MODULE.bazel": "75aab2373a4bbe2a1260b9bf2a1ebbdbf872d3bd36f80bff058dccd82e89422f", + "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.2/source.json": "5fba48bbe0ba48761f9e9f75f92876cafb5d07c0ce059cc7a8027416de94a05b", + "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43", + "https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0", + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.5/MODULE.bazel": "eec517b5bbe5492629466e11dae908d043364302283de25581e3eb944326c4ca", + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.5/source.json": "22bc55c47af97246cfc093d0acf683a7869377de362b5d1c552c2c2e16b7a806", + "https://bcr.bazel.build/modules/zlib/1.3.1/MODULE.bazel": "751c9940dcfe869f5f7274e1295422a34623555916eb98c174c1e945594bf198" + }, + "selectedYankedVersions": {}, + "moduleExtensions": { + "@@rules_kotlin+//src/main/starlark/core/repositories:bzlmod_setup.bzl%rules_kotlin_extensions": { + "general": { + "bzlTransitiveDigest": "Ga4z8lQy1YQ5rAMy+dOl0dqcCEBnYNCXku8x3YQmDZI=", + "usagesDigest": "QI2z8ZUR+mqtbwsf2fLqYdJAkPOHdOV+tF2yVAUgRzw=", + "recordedInputs": [ + "REPO_MAPPING:rules_kotlin+,bazel_tools bazel_tools" + ], + "generatedRepoSpecs": { + "com_github_jetbrains_kotlin_git": { + "repoRuleId": "@@rules_kotlin+//src/main/starlark/core/repositories:compiler.bzl%kotlin_compiler_git_repository", + "attributes": { + "urls": [ + "https://github.com/JetBrains/kotlin/releases/download/v1.9.23/kotlin-compiler-1.9.23.zip" + ], + "sha256": "93137d3aab9afa9b27cb06a824c2324195c6b6f6179d8a8653f440f5bd58be88" + } + }, + "com_github_jetbrains_kotlin": { + "repoRuleId": "@@rules_kotlin+//src/main/starlark/core/repositories:compiler.bzl%kotlin_capabilities_repository", + "attributes": { + "git_repository_name": "com_github_jetbrains_kotlin_git", + "compiler_version": "1.9.23" + } + }, + "com_github_google_ksp": { + "repoRuleId": "@@rules_kotlin+//src/main/starlark/core/repositories:ksp.bzl%ksp_compiler_plugin_repository", + "attributes": { + "urls": [ + "https://github.com/google/ksp/releases/download/1.9.23-1.0.20/artifacts.zip" + ], + "sha256": "ee0618755913ef7fd6511288a232e8fad24838b9af6ea73972a76e81053c8c2d", + "strip_version": "1.9.23-1.0.20" + } + }, + "com_github_pinterest_ktlint": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_file", + "attributes": { + "sha256": "01b2e0ef893383a50dbeb13970fe7fa3be36ca3e83259e01649945b09d736985", + "urls": [ + "https://github.com/pinterest/ktlint/releases/download/1.3.0/ktlint" + ], + "executable": true + } + }, + "rules_android": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "sha256": "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806", + "strip_prefix": "rules_android-0.1.1", + "urls": [ + "https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip" + ] + } + } + } + } + }, + "@@rules_python+//python/extensions:config.bzl%config": { + "general": { + "bzlTransitiveDigest": "iibnRYgg8LpcfmH7EAnVwYePC3jsVaJ6Id8XxUjSZps=", + "usagesDigest": "ZVSXMAGpD+xzVNPuvF1IoLBkty7TROO0+akMapt1pAg=", + "recordedInputs": [ + "REPO_MAPPING:rules_python+,bazel_tools bazel_tools", + "REPO_MAPPING:rules_python+,pypi__build rules_python++config+pypi__build", + "REPO_MAPPING:rules_python+,pypi__click rules_python++config+pypi__click", + "REPO_MAPPING:rules_python+,pypi__colorama rules_python++config+pypi__colorama", + "REPO_MAPPING:rules_python+,pypi__importlib_metadata rules_python++config+pypi__importlib_metadata", + "REPO_MAPPING:rules_python+,pypi__installer rules_python++config+pypi__installer", + "REPO_MAPPING:rules_python+,pypi__more_itertools rules_python++config+pypi__more_itertools", + "REPO_MAPPING:rules_python+,pypi__packaging rules_python++config+pypi__packaging", + "REPO_MAPPING:rules_python+,pypi__pep517 rules_python++config+pypi__pep517", + "REPO_MAPPING:rules_python+,pypi__pip rules_python++config+pypi__pip", + "REPO_MAPPING:rules_python+,pypi__pip_tools rules_python++config+pypi__pip_tools", + "REPO_MAPPING:rules_python+,pypi__pyproject_hooks rules_python++config+pypi__pyproject_hooks", + "REPO_MAPPING:rules_python+,pypi__setuptools rules_python++config+pypi__setuptools", + "REPO_MAPPING:rules_python+,pypi__tomli rules_python++config+pypi__tomli", + "REPO_MAPPING:rules_python+,pypi__wheel rules_python++config+pypi__wheel", + "REPO_MAPPING:rules_python+,pypi__zipp rules_python++config+pypi__zipp" + ], + "generatedRepoSpecs": { + "rules_python_internal": { + "repoRuleId": "@@rules_python+//python/private:internal_config_repo.bzl%internal_config_repo", + "attributes": { + "transition_setting_generators": {}, + "transition_settings": [] + } + }, + "pypi__build": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "url": "https://files.pythonhosted.org/packages/e2/03/f3c8ba0a6b6e30d7d18c40faab90807c9bb5e9a1e3b2fe2008af624a9c97/build-1.2.1-py3-none-any.whl", + "sha256": "75e10f767a433d9a86e50d83f418e83efc18ede923ee5ff7df93b6cb0306c5d4", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + } + }, + "pypi__click": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "url": "https://files.pythonhosted.org/packages/00/2e/d53fa4befbf2cfa713304affc7ca780ce4fc1fd8710527771b58311a3229/click-8.1.7-py3-none-any.whl", + "sha256": "ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + } + }, + "pypi__colorama": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "url": "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", + "sha256": "4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + } + }, + "pypi__importlib_metadata": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "url": "https://files.pythonhosted.org/packages/2d/0a/679461c511447ffaf176567d5c496d1de27cbe34a87df6677d7171b2fbd4/importlib_metadata-7.1.0-py3-none-any.whl", + "sha256": "30962b96c0c223483ed6cc7280e7f0199feb01a0e40cfae4d4450fc6fab1f570", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + } + }, + "pypi__installer": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "url": "https://files.pythonhosted.org/packages/e5/ca/1172b6638d52f2d6caa2dd262ec4c811ba59eee96d54a7701930726bce18/installer-0.7.0-py3-none-any.whl", + "sha256": "05d1933f0a5ba7d8d6296bb6d5018e7c94fa473ceb10cf198a92ccea19c27b53", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + } + }, + "pypi__more_itertools": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "url": "https://files.pythonhosted.org/packages/50/e2/8e10e465ee3987bb7c9ab69efb91d867d93959095f4807db102d07995d94/more_itertools-10.2.0-py3-none-any.whl", + "sha256": "686b06abe565edfab151cb8fd385a05651e1fdf8f0a14191e4439283421f8684", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + } + }, + "pypi__packaging": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "url": "https://files.pythonhosted.org/packages/49/df/1fceb2f8900f8639e278b056416d49134fb8d84c5942ffaa01ad34782422/packaging-24.0-py3-none-any.whl", + "sha256": "2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + } + }, + "pypi__pep517": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "url": "https://files.pythonhosted.org/packages/25/6e/ca4a5434eb0e502210f591b97537d322546e4833dcb4d470a48c375c5540/pep517-0.13.1-py3-none-any.whl", + "sha256": "31b206f67165b3536dd577c5c3f1518e8fbaf38cbc57efff8369a392feff1721", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + } + }, + "pypi__pip": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "url": "https://files.pythonhosted.org/packages/8a/6a/19e9fe04fca059ccf770861c7d5721ab4c2aebc539889e97c7977528a53b/pip-24.0-py3-none-any.whl", + "sha256": "ba0d021a166865d2265246961bec0152ff124de910c5cc39f1156ce3fa7c69dc", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + } + }, + "pypi__pip_tools": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "url": "https://files.pythonhosted.org/packages/0d/dc/38f4ce065e92c66f058ea7a368a9c5de4e702272b479c0992059f7693941/pip_tools-7.4.1-py3-none-any.whl", + "sha256": "4c690e5fbae2f21e87843e89c26191f0d9454f362d8acdbd695716493ec8b3a9", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + } + }, + "pypi__pyproject_hooks": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "url": "https://files.pythonhosted.org/packages/ae/f3/431b9d5fe7d14af7a32340792ef43b8a714e7726f1d7b69cc4e8e7a3f1d7/pyproject_hooks-1.1.0-py3-none-any.whl", + "sha256": "7ceeefe9aec63a1064c18d939bdc3adf2d8aa1988a510afec15151578b232aa2", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + } + }, + "pypi__setuptools": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "url": "https://files.pythonhosted.org/packages/90/99/158ad0609729111163fc1f674a5a42f2605371a4cf036d0441070e2f7455/setuptools-78.1.1-py3-none-any.whl", + "sha256": "c3a9c4211ff4c309edb8b8c4f1cbfa7ae324c4ba9f91ff254e3d305b9fd54561", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + } + }, + "pypi__tomli": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "url": "https://files.pythonhosted.org/packages/97/75/10a9ebee3fd790d20926a90a2547f0bf78f371b2f13aa822c759680ca7b9/tomli-2.0.1-py3-none-any.whl", + "sha256": "939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + } + }, + "pypi__wheel": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "url": "https://files.pythonhosted.org/packages/7d/cd/d7460c9a869b16c3dd4e1e403cce337df165368c71d6af229a74699622ce/wheel-0.43.0-py3-none-any.whl", + "sha256": "55c570405f142630c6b9f72fe09d9b67cf1477fcf543ae5b8dcb1f5b7377da81", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + } + }, + "pypi__zipp": { + "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", + "attributes": { + "url": "https://files.pythonhosted.org/packages/da/55/a03fd7240714916507e1fcf7ae355bd9d9ed2e6db492595f1a67f61681be/zipp-3.18.2-py3-none-any.whl", + "sha256": "dce197b859eb796242b0622af1b8beb0a722d52aa2f57133ead08edd5bf5374e", + "type": "zip", + "build_file_content": "package(default_visibility = [\"//visibility:public\"])\n\nload(\"@rules_python//python:py_library.bzl\", \"py_library\")\n\npy_library(\n name = \"lib\",\n srcs = glob([\"**/*.py\"]),\n data = glob([\"**/*\"], exclude=[\n # These entries include those put into user-installed dependencies by\n # data_exclude to avoid non-determinism.\n \"**/*.py\",\n \"**/*.pyc\",\n \"**/*.pyc.*\", # During pyc creation, temp files named *.pyc.NNN are created\n \"**/*.dist-info/RECORD\",\n \"BUILD\",\n \"WORKSPACE\",\n ]),\n # This makes this directory a top-level in the python import\n # search path for anything that depends on this.\n imports = [\".\"],\n)\n" + } + } + } + } + }, + "@@rules_python+//python/uv:uv.bzl%uv": { + "general": { + "bzlTransitiveDigest": "ijW9KS7qsIY+yBVvJ+Nr1mzwQox09j13DnE3iIwaeTM=", + "usagesDigest": "H8dQoNZcoqP+Mu0tHZTi4KHATzvNkM5ePuEqoQdklIU=", + "recordedInputs": [ + "REPO_MAPPING:rules_python+,bazel_tools bazel_tools", + "REPO_MAPPING:rules_python+,platforms platforms" + ], + "generatedRepoSpecs": { + "uv": { + "repoRuleId": "@@rules_python+//python/uv/private:uv_toolchains_repo.bzl%uv_toolchains_repo", + "attributes": { + "toolchain_type": "'@@rules_python+//python/uv:uv_toolchain_type'", + "toolchain_names": [ + "none" + ], + "toolchain_implementations": { + "none": "'@@rules_python+//python:none'" + }, + "toolchain_compatible_with": { + "none": [ + "@platforms//:incompatible" + ] + }, + "toolchain_target_settings": {} + } + } + } + } + } + }, + "facts": {} +} diff --git a/README.md b/README.md index ba4f50c..ebb6709 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ # Burrow -![License](https://img.shields.io/github/license/hackclub/burrow) ![Apple Build Status](https://img.shields.io/github/actions/workflow/status/hackclub/burrow/build-apple.yml?branch=main&label=macos%2C%20ios&logo=Apple) ![Crate Build Status](https://img.shields.io/github/actions/workflow/status/hackclub/burrow/build-rust.yml?branch=main&label=crate&logo=Rust) - Burrow is an open source tool for burrowing through firewalls, built by teenagers at [Hack Club](https://hackclub.com/). `burrow` provides a simple command-line tool to open virtual interfaces and direct traffic through them. Routine verification now runs unprivileged with `cargo test --workspace --all-features`; only tunnel startup needs elevation. +The canonical source forge is [git.burrow.net/hackclub/burrow](https://git.burrow.net/hackclub/burrow). The repository now carries its own design and deployment record: @@ -18,7 +17,7 @@ The repository now carries its own design and deployment record: ## Contributing -Burrow is fully open source, you can fork the repo and start contributing easily. For more information and in-depth discussions, visit the `#burrow` channel on the [Hack Club Slack](https://hackclub.com/slack/), here you can ask for help and talk with other people interested in burrow. Checkout [GETTING_STARTED.md](./docs/GETTING_STARTED.md) for build instructions and [GTK_APP.md](./docs/GTK_APP.md) for the Linux app. Forge and deployment scaffolding live in [`flake.nix`](./flake.nix), [`nixos/`](./nixos), and [`.forgejo/workflows/`](./.forgejo/workflows/). Hosted mail backup operations live in [`docs/FORWARDEMAIL.md`](./docs/FORWARDEMAIL.md) and [`Tools/forwardemail-custom-s3.sh`](./Tools/forwardemail-custom-s3.sh). +Burrow is fully open source, you can fork the repo and start contributing easily. For more information and in-depth discussions, visit the `#burrow` channel on the [Hack Club Slack](https://hackclub.com/slack/), here you can ask for help and talk with other people interested in burrow. Checkout [GETTING_STARTED.md](./docs/GETTING_STARTED.md) for build instructions and [GTK_APP.md](./docs/GTK_APP.md) for the Linux app. Forge and deployment scaffolding live in [`flake.nix`](./flake.nix), [`nixos/`](./nixos), and [`.forgejo/workflows/`](./.forgejo/workflows/). Hosted mail backup operations live in [`docs/FORWARDEMAIL.md`](./docs/FORWARDEMAIL.md) and [`Tools/forwardemail-custom-s3.sh`](./Tools/forwardemail-custom-s3.sh). Platform service and distribution rollout notes live in [`docs/PLATFORM_SERVICES.md`](./docs/PLATFORM_SERVICES.md) and [`docs/DISTRIBUTION.md`](./docs/DISTRIBUTION.md). Agent and governance-sensitive work should start with [AGENTS.md](./AGENTS.md), [CONSTITUTION.md](./CONSTITUTION.md), and the relevant BEPs under [`evolution/proposals/`](./evolution/proposals/). Identity and bootstrap metadata now live in [`contributors.nix`](./contributors.nix). @@ -49,6 +48,4 @@ Burrow is open source and licensed under the [GNU General Public License v3.0](. ## Contributors - - - +See the canonical forge history for current contributors. diff --git a/Scripts/_burrow-flake.sh b/Scripts/_burrow-flake.sh index ba4e372..25fb6e1 100755 --- a/Scripts/_burrow-flake.sh +++ b/Scripts/_burrow-flake.sh @@ -27,7 +27,7 @@ burrow_prepare_flake_ref() { local resolved resolved="$(cd "${input}" && pwd)" - local cache_root="${HOME}/.cache/burrow" + local cache_root="${BURROW_FLAKE_CACHE_ROOT:-${HOME}/.cache/burrow}" mkdir -p "${cache_root}" local copy_root @@ -37,6 +37,8 @@ burrow_prepare_flake_ref() { rsync -a \ --delete \ --exclude '.git' \ + --exclude '.cache' \ + --exclude '.derived-data' \ --exclude '.direnv' \ --exclude 'result' \ --exclude 'burrow.sock' \ diff --git a/Scripts/apple/create-asc-certificate.mjs b/Scripts/apple/create-asc-certificate.mjs new file mode 100755 index 0000000..9c530d9 --- /dev/null +++ b/Scripts/apple/create-asc-certificate.mjs @@ -0,0 +1,164 @@ +#!/usr/bin/env node +import fs from "node:fs"; +import path from "node:path"; +import { webcrypto } from "node:crypto"; + +const crypto = globalThis.crypto ?? webcrypto; + +function b64url(input) { + const buf = Buffer.isBuffer(input) ? input : Buffer.from(input); + return buf + .toString("base64") + .replace(/=/g, "") + .replace(/\+/g, "-") + .replace(/\//g, "_"); +} + +function parseArgs(argv) { + const out = { _: [] }; + for (let i = 2; i < argv.length; i++) { + const arg = argv[i]; + if (arg === "--help" || arg === "-h") out.help = true; + else if (arg.startsWith("--")) { + const key = arg.slice(2); + const value = argv[i + 1]; + if (!value || value.startsWith("--")) throw new Error(`missing value for --${key}`); + out[key] = value; + i++; + } else { + out._.push(arg); + } + } + return out; +} + +async function makeJwt({ keyId, issuerId, keyPem }) { + const header = { alg: "ES256", kid: keyId, typ: "JWT" }; + const now = Math.floor(Date.now() / 1000); + const payload = { iss: issuerId, exp: now + 20 * 60, aud: "appstoreconnect-v1" }; + const input = `${b64url(JSON.stringify(header))}.${b64url(JSON.stringify(payload))}`; + const pkcs8Der = Buffer.from( + keyPem.replace(/-----BEGIN PRIVATE KEY-----|-----END PRIVATE KEY-----|\s+/g, ""), + "base64", + ); + const key = await crypto.subtle.importKey( + "pkcs8", + pkcs8Der, + { name: "ECDSA", namedCurve: "P-256" }, + false, + ["sign"], + ); + const sig = await crypto.subtle.sign( + { name: "ECDSA", hash: "SHA-256" }, + key, + new TextEncoder().encode(input), + ); + return `${input}.${b64url(Buffer.from(sig))}`; +} + +async function ascFetch(jwt, url, opts = {}) { + const res = await fetch(url, { + ...opts, + headers: { + ...(opts.headers ?? {}), + Authorization: `Bearer ${jwt}`, + "Content-Type": "application/json", + }, + }); + const text = await res.text(); + let body; + try { + body = text ? JSON.parse(text) : {}; + } catch { + body = { raw: text }; + } + if (!res.ok) { + throw new Error(`ASC ${res.status} ${url}: ${JSON.stringify(body).slice(0, 2000)}`); + } + return body; +} + +function certificateFileName(type, id) { + return `${type.toLowerCase().replace(/_/g, "-")}-${id}.cer`; +} + +function csrContentForApi(csrFile) { + const bytes = fs.readFileSync(csrFile); + const text = bytes.toString("ascii"); + const pemMatch = text.match(/-----BEGIN CERTIFICATE REQUEST-----([\s\S]+?)-----END CERTIFICATE REQUEST-----/); + if (pemMatch) { + return pemMatch[1].replace(/\s+/g, ""); + } + return bytes.toString("base64"); +} + +async function main() { + const args = parseArgs(process.argv); + if (args.help) { + console.log("Usage: create-asc-certificate.mjs --key-id ID --issuer-id ID --key-file AuthKey.p8 --certificate-type IOS_DISTRIBUTION --csr-file file.csr --out-dir DIR"); + process.exit(0); + } + + const keyId = args["key-id"] ?? process.env.APP_STORE_CONNECT_KEY_ID; + const issuerId = args["issuer-id"] ?? process.env.APP_STORE_CONNECT_ISSUER_ID; + const keyFile = args["key-file"] ?? process.env.APP_STORE_CONNECT_KEY_FILE; + const certificateType = args["certificate-type"] ?? "IOS_DISTRIBUTION"; + const csrFile = args["csr-file"]; + const outDir = args["out-dir"] ?? "."; + const outFile = args["out-file"]; + const metadataFile = args["metadata-file"]; + + if (!keyId || !issuerId || !keyFile || !csrFile) { + throw new Error("required: --key-id --issuer-id --key-file --csr-file"); + } + + const jwt = await makeJwt({ + keyId, + issuerId, + keyPem: fs.readFileSync(keyFile, "utf8"), + }); + const csrContent = csrContentForApi(csrFile); + const created = await ascFetch(jwt, "https://api.appstoreconnect.apple.com/v1/certificates", { + method: "POST", + body: JSON.stringify({ + data: { + type: "certificates", + attributes: { + certificateType, + csrContent, + }, + }, + }), + }); + + const cert = created?.data; + const id = cert?.id; + const content = cert?.attributes?.certificateContent; + if (!id || !content) { + throw new Error(`ASC response did not include certificate id/content: ${JSON.stringify(created).slice(0, 2000)}`); + } + + fs.mkdirSync(outDir, { recursive: true }); + const certificatePath = outFile ?? path.join(outDir, certificateFileName(certificateType, id)); + fs.writeFileSync(certificatePath, Buffer.from(content, "base64")); + + const metadata = { + id, + certificateType: cert?.attributes?.certificateType ?? certificateType, + displayName: cert?.attributes?.displayName, + name: cert?.attributes?.name, + platform: cert?.attributes?.platform, + expirationDate: cert?.attributes?.expirationDate, + serialNumber: cert?.attributes?.serialNumber, + certificatePath, + }; + if (metadataFile) { + fs.writeFileSync(metadataFile, `${JSON.stringify(metadata, null, 2)}\n`); + } + process.stdout.write(`${JSON.stringify(metadata, null, 2)}\n`); +} + +main().catch((err) => { + console.error(err?.stack || String(err)); + process.exit(1); +}); diff --git a/Scripts/apple/google-kms-csr.py b/Scripts/apple/google-kms-csr.py new file mode 100755 index 0000000..15a7d89 --- /dev/null +++ b/Scripts/apple/google-kms-csr.py @@ -0,0 +1,249 @@ +#!/usr/bin/env python3 +"""Build an Apple-compatible PKCS#10 CSR backed by Google Cloud KMS. + +The script intentionally implements only the RSA/SHA-256 subset Burrow needs for +Apple Developer ID and iOS Distribution certificate requests. It fetches the KMS +public key, builds CertificationRequestInfo locally, asks KMS to sign that DER +payload, and writes a standard PEM CSR. +""" + +from __future__ import annotations + +import argparse +import base64 +import os +import subprocess +import sys +import tempfile +from pathlib import Path + + +DEFAULT_PROJECT = "project-88c23ce9-918a-470a-b33" +DEFAULT_LOCATION = "global" +DEFAULT_KEYRING = "burrow-identity" +DEFAULT_KEY = "apple-developer-id-application" +DEFAULT_VERSION = "1" +DEFAULT_COMMON_NAME = "Burrow Developer ID Application" +DEFAULT_EMAIL = "release@burrow.net" + + +def der_length(length: int) -> bytes: + if length < 0: + raise ValueError("negative DER length") + if length < 0x80: + return bytes([length]) + encoded = length.to_bytes((length.bit_length() + 7) // 8, "big") + return bytes([0x80 | len(encoded)]) + encoded + + +def der(tag: int, body: bytes) -> bytes: + return bytes([tag]) + der_length(len(body)) + body + + +def der_sequence(*items: bytes) -> bytes: + return der(0x30, b"".join(items)) + + +def der_set(*items: bytes) -> bytes: + return der(0x31, b"".join(items)) + + +def der_integer(value: int) -> bytes: + if value < 0: + raise ValueError("negative INTEGER is not supported") + raw = value.to_bytes(max(1, (value.bit_length() + 7) // 8), "big") + if raw[0] & 0x80: + raw = b"\x00" + raw + return der(0x02, raw) + + +def der_null() -> bytes: + return der(0x05, b"") + + +def der_bit_string(value: bytes) -> bytes: + return der(0x03, b"\x00" + value) + + +def der_utf8(value: str) -> bytes: + return der(0x0C, value.encode("utf-8")) + + +def der_printable(value: str) -> bytes: + return der(0x13, value.encode("ascii")) + + +def der_ia5(value: str) -> bytes: + return der(0x16, value.encode("ascii")) + + +def der_oid(dotted: str) -> bytes: + parts = [int(part) for part in dotted.split(".")] + if len(parts) < 2 or parts[0] > 2 or parts[1] > 39: + raise ValueError(f"unsupported OID: {dotted}") + body = bytes([40 * parts[0] + parts[1]]) + for value in parts[2:]: + if value < 0: + raise ValueError(f"negative OID component: {dotted}") + encoded = [value & 0x7F] + value >>= 7 + while value: + encoded.append(0x80 | (value & 0x7F)) + value >>= 7 + body += bytes(reversed(encoded)) + return der(0x06, body) + + +def name_attribute(oid: str, value_der: bytes) -> bytes: + return der_set(der_sequence(der_oid(oid), value_der)) + + +def subject_name(common_name: str, email_address: str, country: str | None) -> bytes: + attrs: list[bytes] = [] + if country: + if len(country) != 2 or not country.isalpha(): + raise ValueError("--country must be a two-letter ISO country code") + attrs.append(name_attribute("2.5.4.6", der_printable(country.upper()))) + if email_address: + attrs.append(name_attribute("1.2.840.113549.1.9.1", der_ia5(email_address))) + attrs.append(name_attribute("2.5.4.3", der_utf8(common_name))) + return der_sequence(*attrs) + + +def pem_to_der(pem: bytes) -> bytes: + lines = [ + line.strip() + for line in pem.splitlines() + if line and not line.startswith(b"-----") + ] + if not lines: + raise ValueError("PEM input did not contain base64 data") + return base64.b64decode(b"".join(lines), validate=True) + + +def pem_wrap(label: str, body: bytes) -> str: + encoded = base64.b64encode(body).decode("ascii") + lines = [f"-----BEGIN {label}-----"] + lines.extend(encoded[i : i + 64] for i in range(0, len(encoded), 64)) + lines.append(f"-----END {label}-----") + return "\n".join(lines) + "\n" + + +def run(command: list[str]) -> None: + subprocess.run(command, check=True) + + +def fetch_public_key(args: argparse.Namespace, output: Path) -> None: + command = [ + args.gcloud, + "kms", + "keys", + "versions", + "get-public-key", + args.kms_version, + "--location", + args.kms_location, + "--keyring", + args.kms_keyring, + "--key", + args.kms_key, + "--output-file", + str(output), + ] + if args.gcloud_project: + command.extend(["--project", args.gcloud_project]) + run(command) + + +def kms_sign(args: argparse.Namespace, payload: bytes) -> bytes: + with tempfile.TemporaryDirectory(prefix="burrow-kms-csr.") as tmp: + payload_path = Path(tmp) / "certification-request-info.der" + signature_path = Path(tmp) / "signature.b64" + payload_path.write_bytes(payload) + command = [ + args.gcloud, + "kms", + "asymmetric-sign", + "--location", + args.kms_location, + "--keyring", + args.kms_keyring, + "--key", + args.kms_key, + "--version", + args.kms_version, + "--digest-algorithm", + "sha256", + "--input-file", + str(payload_path), + "--signature-file", + str(signature_path), + ] + if args.gcloud_project: + command.extend(["--project", args.gcloud_project]) + run(command) + signature = signature_path.read_bytes() + try: + return base64.b64decode(signature.strip(), validate=True) + except ValueError: + return signature + + +def build_csr(args: argparse.Namespace, spki_der: bytes) -> bytes: + cri = der_sequence( + der_integer(0), + subject_name(args.common_name, args.email_address, args.country), + spki_der, + b"\xA0\x00", + ) + signature = kms_sign(args, cri) + signature_algorithm = der_sequence( + der_oid("1.2.840.113549.1.1.11"), + der_null(), + ) + return der_sequence(cri, signature_algorithm, der_bit_string(signature)) + + +def parse_args(argv: list[str]) -> argparse.Namespace: + parser = argparse.ArgumentParser( + description="Generate an Apple-compatible CSR backed by a Google Cloud KMS RSA signing key.", + ) + parser.add_argument("--gcloud-project", default=os.environ.get("GOOGLE_CLOUD_PROJECT") or os.environ.get("BURROW_GOOGLE_PROJECT_ID") or DEFAULT_PROJECT) + parser.add_argument("--kms-location", default=os.environ.get("BURROW_KMS_LOCATION", DEFAULT_LOCATION)) + parser.add_argument("--kms-keyring", default=os.environ.get("BURROW_KMS_KEYRING", DEFAULT_KEYRING)) + parser.add_argument("--kms-key", default=os.environ.get("BURROW_APPLE_KMS_KEY") or os.environ.get("BURROW_APPLE_DEVELOPER_ID_KMS_KEY", DEFAULT_KEY)) + parser.add_argument("--kms-version", default=os.environ.get("BURROW_KMS_VERSION", DEFAULT_VERSION)) + parser.add_argument("--common-name", default=os.environ.get("BURROW_APPLE_CSR_COMMON_NAME") or os.environ.get("BURROW_APPLE_DEVELOPER_ID_CSR_COMMON_NAME", DEFAULT_COMMON_NAME)) + parser.add_argument("--email-address", default=os.environ.get("BURROW_APPLE_CSR_EMAIL") or os.environ.get("BURROW_APPLE_DEVELOPER_ID_CSR_EMAIL", DEFAULT_EMAIL)) + parser.add_argument("--country", default=os.environ.get("BURROW_APPLE_CSR_COUNTRY") or os.environ.get("BURROW_APPLE_DEVELOPER_ID_CSR_COUNTRY", "US")) + parser.add_argument("--public-key-pem", help="Existing KMS public-key PEM path. If omitted, gcloud fetches it.") + parser.add_argument("--public-key-output", help="Write the fetched/used public key PEM to this path.") + parser.add_argument("--output", default="developer-id-application.certSigningRequest") + parser.add_argument("--gcloud", default=os.environ.get("GCLOUD", "gcloud")) + return parser.parse_args(argv) + + +def main(argv: list[str]) -> int: + args = parse_args(argv) + output = Path(args.output) + + with tempfile.TemporaryDirectory(prefix="burrow-kms-csr.") as tmp: + public_key_path = Path(args.public_key_pem) if args.public_key_pem else Path(tmp) / "kms-public.pem" + if not args.public_key_pem: + fetch_public_key(args, public_key_path) + public_key_pem = public_key_path.read_bytes() + spki_der = pem_to_der(public_key_pem) + csr = build_csr(args, spki_der) + + output.parent.mkdir(parents=True, exist_ok=True) + output.write_text(pem_wrap("CERTIFICATE REQUEST", csr), encoding="ascii") + if args.public_key_output: + public_output = Path(args.public_key_output) + public_output.parent.mkdir(parents=True, exist_ok=True) + public_output.write_bytes(public_key_pem) + print(f"wrote {output}") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main(sys.argv[1:])) diff --git a/Scripts/apple/profile-entitlements.py b/Scripts/apple/profile-entitlements.py new file mode 100755 index 0000000..26bd10d --- /dev/null +++ b/Scripts/apple/profile-entitlements.py @@ -0,0 +1,120 @@ +#!/usr/bin/env python3 +"""Extract signing entitlements from an Apple provisioning profile.""" + +from __future__ import annotations + +import argparse +import plistlib +import subprocess +import sys +from pathlib import Path + +PROFILE_REQUIRED_KEYS = { + "application-identifier", + "beta-reports-active", + "com.apple.developer.team-identifier", + "com.apple.developer.default-data-protection", + "keychain-access-groups", +} + + +def decode_profile(path: Path) -> dict: + commands = [ + ["security", "cms", "-D", "-i", str(path)], + ["openssl", "smime", "-inform", "DER", "-verify", "-noverify", "-in", str(path)], + ["openssl", "cms", "-inform", "DER", "-verify", "-noverify", "-in", str(path)], + ] + errors: list[str] = [] + for command in commands: + try: + proc = subprocess.run( + command, + check=False, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + except FileNotFoundError: + continue + if proc.returncode == 0 and proc.stdout: + return plistlib.loads(proc.stdout) + errors.append(f"{command[0]} exited {proc.returncode}: {proc.stderr.decode(errors='replace').strip()}") + raise RuntimeError(f"unable to decode provisioning profile {path}: {'; '.join(errors)}") + + +def load_entitlements_template(path: Path) -> dict: + value = plistlib.loads(path.read_bytes()) + if not isinstance(value, dict): + raise RuntimeError(f"entitlements template is not a dictionary: {path}") + return value + + +def _has_build_setting(value: object) -> bool: + if isinstance(value, str): + return "$(" in value + if isinstance(value, list): + return any(_has_build_setting(item) for item in value) + if isinstance(value, dict): + return any(_has_build_setting(item) for item in value.values()) + return False + + +def _filter_list(template_value: list, profile_value: object) -> list: + if not isinstance(profile_value, list): + return template_value + profile_set = set(profile_value) + filtered = [item for item in template_value if item in profile_set] + return filtered + + +def filter_entitlements(profile_entitlements: dict, template_entitlements: dict) -> dict: + filtered = { + key: profile_entitlements[key] + for key in PROFILE_REQUIRED_KEYS + if key in profile_entitlements + } + + for key, template_value in template_entitlements.items(): + if key not in profile_entitlements: + print( + f"warning: entitlement {key} requested by template but absent from provisioning profile; omitting", + file=sys.stderr, + ) + continue + + profile_value = profile_entitlements[key] + if _has_build_setting(template_value): + filtered[key] = profile_value + elif isinstance(template_value, list): + filtered[key] = _filter_list(template_value, profile_value) + else: + filtered[key] = template_value + + return dict(sorted(filtered.items())) + + +def main(argv: list[str]) -> int: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("profile", type=Path) + parser.add_argument("--output", "-o", type=Path, required=True) + parser.add_argument( + "--template", + type=Path, + help="Optional entitlements template used to filter profile entitlements for a target.", + ) + args = parser.parse_args(argv) + + profile = decode_profile(args.profile) + entitlements = profile.get("Entitlements") + if not isinstance(entitlements, dict): + raise RuntimeError(f"profile has no Entitlements dictionary: {args.profile}") + + if args.template: + entitlements = filter_entitlements(entitlements, load_entitlements_template(args.template)) + + args.output.parent.mkdir(parents=True, exist_ok=True) + args.output.write_bytes(plistlib.dumps(entitlements, fmt=plistlib.FMT_XML)) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main(sys.argv[1:])) diff --git a/Scripts/apple/sign-release-artifacts-kms.sh b/Scripts/apple/sign-release-artifacts-kms.sh new file mode 100755 index 0000000..526c6d6 --- /dev/null +++ b/Scripts/apple/sign-release-artifacts-kms.sh @@ -0,0 +1,263 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "$repo_root" + +platform="${1:-all}" +build_number="${BUILD_NUMBER:-${RELEASE_BUILD_NUMBER:-${RELEASE_REF:-manual}}}" +out_root="${BURROW_RELEASE_OUT:-${repo_root}/dist/builds/${build_number}}" +apple_root="${out_root}/apple" +bundle_id="${BURROW_APPLE_BUNDLE_ID:-net.burrow.app}" +network_extension_bundle_id="${BURROW_APPLE_NETWORK_EXTENSION_BUNDLE_ID:-${bundle_id}.network}" +notarize_macos="${BURROW_NOTARIZE_MACOS:-false}" +sparkle_sign_with_kms="${BURROW_SPARKLE_SIGN_WITH_KMS:-true}" + +truthy() { + case "${1:-}" in + 1|true|TRUE|True|yes|YES|Yes|y|Y|on|ON|On) return 0 ;; + *) return 1 ;; + esac +} + +sha256_file() { + local file="$1" + if command -v shasum >/dev/null 2>&1; then + shasum -a 256 "$file" > "${file}.sha256" + else + sha256sum "$file" > "${file}.sha256" + fi +} + +safe_profile_slug() { + python3 - "$1" <<'PY' +import re +import sys + +print(re.sub(r"[^A-Za-z0-9]", "", sys.argv[1]).lower()) +PY +} + +profile_for() { + local identifier="$1" + local suffix="$2" + local slug path + slug="$(safe_profile_slug "$identifier")" + for path in \ + ".forgejo/actions/export/${slug}${suffix}.provisionprofile" \ + ".forgejo/actions/export/${slug}${suffix}.mobileprovision" \ + "Apple/Profiles/${slug}${suffix}.provisionprofile" \ + "Apple/Profiles/${slug}${suffix}.mobileprovision"; do + if [[ -s "$path" ]]; then + printf '%s\n' "$path" + return 0 + fi + done + return 1 +} + +require_tool() { + if ! command -v "$1" >/dev/null 2>&1; then + echo "error: missing required tool: $1" >&2 + exit 1 + fi +} + +extract_profile_entitlements() { + local profile="$1" + local output="$2" + local template="${3:-}" + local args=("$profile" --output "$output") + if [[ -n "$template" ]]; then + args+=(--template "$template") + fi + Scripts/apple/profile-entitlements.py "${args[@]}" +} + +sign_bundle() { + local family="$1" + local bundle_path="$2" + local entitlements="$3" + local runtime_flag=() + if [[ "$family" == "developer-id" ]]; then + runtime_flag=(--runtime) + fi + Scripts/apple/sign-with-google-kms.sh \ + --family "$family" \ + --path "$bundle_path" \ + --entitlements "$entitlements" \ + "${runtime_flag[@]}" +} + +write_notary_api_key_json() { + local out="$1" + if [[ -z "${ASC_API_KEY_ID:-}" || -z "${ASC_API_ISSUER_ID:-}" || -z "${ASC_API_KEY_PATH:-}" ]]; then + echo "macOS notarization requires ASC_API_KEY_ID, ASC_API_ISSUER_ID, and ASC_API_KEY_PATH" >&2 + exit 1 + fi + rcodesign encode-app-store-connect-api-key \ + --output-path "$out" \ + "$ASC_API_ISSUER_ID" \ + "$ASC_API_KEY_ID" \ + "$ASC_API_KEY_PATH" +} + +sign_ios() { + local unsigned_ipa app_profile ext_profile work_dir app ext app_entitlements ext_entitlements output_ipa + unsigned_ipa="${apple_root}/Burrow-iOS-${build_number}.unsigned.ipa" + if [[ ! -s "$unsigned_ipa" ]]; then + echo "error: missing staged unsigned iOS IPA: $unsigned_ipa" >&2 + exit 1 + fi + + app_profile="$(profile_for "$bundle_id" "appstore")" || { + echo "error: missing iOS App Store provisioning profile for ${bundle_id}" >&2 + exit 1 + } + ext_profile="$(profile_for "$network_extension_bundle_id" "appstore")" || { + echo "error: missing iOS App Store provisioning profile for ${network_extension_bundle_id}" >&2 + exit 1 + } + + work_dir="$(mktemp -d "${TMPDIR:-/tmp}/burrow-ios-kms-sign.XXXXXX")" + trap 'rm -rf "${work_dir:-}"' RETURN + unzip -q "$unsigned_ipa" -d "$work_dir" + app="${work_dir}/Payload/Burrow.app" + ext="${app}/PlugIns/BurrowNetworkExtension.appex" + if [[ ! -d "$app" || ! -d "$ext" ]]; then + echo "error: unsigned IPA is missing Burrow.app or BurrowNetworkExtension.appex" >&2 + exit 1 + fi + + cp "$app_profile" "${app}/embedded.mobileprovision" + cp "$ext_profile" "${ext}/embedded.mobileprovision" + app_entitlements="${work_dir}/app-entitlements.plist" + ext_entitlements="${work_dir}/extension-entitlements.plist" + extract_profile_entitlements "$app_profile" "$app_entitlements" Apple/App/App-iOS.entitlements + extract_profile_entitlements "$ext_profile" "$ext_entitlements" Apple/NetworkExtension/NetworkExtension-iOS.entitlements + + rm -rf "${app}/_CodeSignature" "${ext}/_CodeSignature" + sign_bundle ios "$ext" "$ext_entitlements" + sign_bundle ios "$app" "$app_entitlements" + + output_ipa="${apple_root}/Burrow-iOS-${build_number}.ipa" + rm -f "$output_ipa" + (cd "$work_dir" && zip -qry "$output_ipa" Payload) + sha256_file "$output_ipa" +} + +write_sparkle_appcast() { + local artifact="$1" + local channel sparkle_dir length pubdate url + channel="${SPARKLE_CHANNEL:-build-${build_number}}" + sparkle_dir="${out_root}/sparkle/${channel}" + mkdir -p "$sparkle_dir" + cp "$artifact" "$sparkle_dir/" + length="$(wc -c < "$artifact" | tr -d ' ')" + pubdate="$(LC_ALL=C date -u '+%a, %d %b %Y %H:%M:%S +0000')" + url="${SPARKLE_DOWNLOAD_PREFIX:-https://releases.burrow.net/sparkle}/${channel}/$(basename "$artifact")" + cat > "${sparkle_dir}/appcast.xml" < + + + Burrow ${channel} + + Burrow ${build_number} + ${pubdate} + ${build_number} + 0.1 + + + + +EOF + if truthy "$sparkle_sign_with_kms"; then + Scripts/sparkle/sign-appcast-kms.py \ + --appcast "${sparkle_dir}/appcast.xml" \ + --artifact-dir "$sparkle_dir" + fi +} + +sign_macos() { + local unsigned_zip app_profile ext_profile work_dir app ext app_entitlements ext_entitlements output_zip notary_zip key_json + unsigned_zip="${apple_root}/Burrow-macOS-${build_number}.unsigned.zip" + if [[ ! -s "$unsigned_zip" ]]; then + echo "error: missing staged unsigned macOS ZIP: $unsigned_zip" >&2 + exit 1 + fi + + app_profile="$(profile_for "$bundle_id" "developerid")" || { + echo "error: missing macOS Developer ID provisioning profile for ${bundle_id}" >&2 + exit 1 + } + ext_profile="$(profile_for "$network_extension_bundle_id" "developerid")" || { + echo "error: missing macOS Developer ID provisioning profile for ${network_extension_bundle_id}" >&2 + exit 1 + } + + work_dir="$(mktemp -d "${TMPDIR:-/tmp}/burrow-macos-kms-sign.XXXXXX")" + trap 'rm -rf "${work_dir:-}"' RETURN + unzip -q "$unsigned_zip" -d "$work_dir" + app="$(find "$work_dir" -maxdepth 2 -type d -name 'Burrow.app' -print | head -n 1)" + if [[ -z "$app" || ! -d "$app" ]]; then + echo "error: unsigned macOS ZIP does not contain Burrow.app" >&2 + exit 1 + fi + + ext="${app}/Contents/PlugIns/BurrowNetworkExtension.appex" + cp "$app_profile" "${app}/Contents/embedded.provisionprofile" + app_entitlements="${work_dir}/app-entitlements.plist" + extract_profile_entitlements "$app_profile" "$app_entitlements" + + if [[ -d "$ext" ]]; then + cp "$ext_profile" "${ext}/Contents/embedded.provisionprofile" + ext_entitlements="${work_dir}/extension-entitlements.plist" + extract_profile_entitlements "$ext_profile" "$ext_entitlements" + rm -rf "${ext}/Contents/_CodeSignature" + sign_bundle developer-id "$ext" "$ext_entitlements" + fi + + rm -rf "${app}/Contents/_CodeSignature" + sign_bundle developer-id "$app" "$app_entitlements" + + if truthy "$notarize_macos"; then + key_json="${work_dir}/notary-api-key.json" + notary_zip="${work_dir}/Burrow.notary.zip" + write_notary_api_key_json "$key_json" + (cd "$(dirname "$app")" && zip -qry "$notary_zip" "$(basename "$app")") + rcodesign notary-submit --api-key-file "$key_json" --wait "$notary_zip" + rcodesign staple "$app" + fi + + output_zip="${apple_root}/Burrow-macOS-${build_number}.zip" + rm -f "$output_zip" + (cd "$(dirname "$app")" && zip -qry "$output_zip" "$(basename "$app")") + sha256_file "$output_zip" + write_sparkle_appcast "$output_zip" +} + +require_tool python3 +require_tool unzip +require_tool zip +require_tool rcodesign +require_tool gcloud +mkdir -p "$apple_root" + +case "$platform" in + all) + sign_ios + sign_macos + ;; + ios) + sign_ios + ;; + macos) + sign_macos + ;; + *) + echo "unknown Apple KMS signing platform: $platform" >&2 + exit 64 + ;; +esac + +find "$out_root" -type f -print | sort diff --git a/Scripts/apple/sign-with-google-kms.sh b/Scripts/apple/sign-with-google-kms.sh new file mode 100755 index 0000000..33d5c7e --- /dev/null +++ b/Scripts/apple/sign-with-google-kms.sh @@ -0,0 +1,263 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "$repo_root" + +family="" +path="" +entitlements="" +certificate="" +kms_key="" +kms_version="" +runtime=false +timestamp_url="" + +usage() { + cat <<'EOF' +Usage: Scripts/apple/sign-with-google-kms.sh --family ios|developer-id --path [options] + +Options: + --entitlements XML entitlements for bundle signing + --certificate Apple public certificate matching the KMS key + --kms-key Google KMS crypto key name/resource + --kms-version Google KMS crypto key version + --runtime Set hardened-runtime code-signature flags +EOF +} + +while [[ $# -gt 0 ]]; do + case "$1" in + --family) + family="${2:?missing value for --family}" + shift 2 + ;; + --path) + path="${2:?missing value for --path}" + shift 2 + ;; + --entitlements) + entitlements="${2:?missing value for --entitlements}" + shift 2 + ;; + --certificate) + certificate="${2:?missing value for --certificate}" + shift 2 + ;; + --kms-key) + kms_key="${2:?missing value for --kms-key}" + shift 2 + ;; + --kms-version) + kms_version="${2:?missing value for --kms-version}" + shift 2 + ;; + --runtime) + runtime=true + shift + ;; + -h|--help) + usage + exit 0 + ;; + *) + echo "error: unknown argument $1" >&2 + usage >&2 + exit 64 + ;; + esac +done + +case "$family" in + ios) + certificate="${certificate:-Apple/Certificates/ios-distribution-3G42677598.cer}" + kms_key="${kms_key:-${BURROW_IOS_DISTRIBUTION_KMS_KEY:-apple-ios-distribution}}" + kms_version="${kms_version:-${BURROW_IOS_DISTRIBUTION_KMS_VERSION:-1}}" + timestamp_url="${BURROW_IOS_CODESIGN_TIMESTAMP_URL:-none}" + ;; + developer-id) + certificate="${certificate:-Apple/Certificates/developer-id-application-9JKN6HXBHC.cer}" + kms_key="${kms_key:-${BURROW_DEVELOPER_ID_KMS_KEY:-apple-developer-id-application}}" + kms_version="${kms_version:-${BURROW_DEVELOPER_ID_KMS_VERSION:-1}}" + timestamp_url="${BURROW_DEVELOPER_ID_TIMESTAMP_URL:-${BURROW_APPLE_TIMESTAMP_URL:-}}" + ;; + *) + echo "error: --family must be ios or developer-id" >&2 + exit 64 + ;; +esac + +if [[ -z "$path" ]]; then + echo "error: --path is required" >&2 + exit 64 +fi +if [[ "$path" != /* ]]; then + path="$repo_root/$path" +fi +if [[ "$certificate" != /* ]]; then + certificate="$repo_root/$certificate" +fi +if [[ -n "$entitlements" && "$entitlements" != /* ]]; then + entitlements="$repo_root/$entitlements" +fi +if [[ ! -e "$path" ]]; then + echo "error: signing target does not exist: $path" >&2 + exit 1 +fi +if [[ ! -s "$certificate" ]]; then + echo "error: Apple certificate is missing or empty: $certificate" >&2 + exit 1 +fi +if [[ -n "$entitlements" && ! -s "$entitlements" ]]; then + echo "error: entitlements file is missing or empty: $entitlements" >&2 + exit 1 +fi + +require_tool() { + if ! command -v "$1" >/dev/null 2>&1; then + echo "error: missing required tool: $1" >&2 + exit 1 + fi +} + +resolve_module() { + local candidate + for candidate in \ + "${BURROW_APPLE_PKCS11_MODULE:-}" \ + "${BURROW_GCP_KMS_PKCS11_MODULE:-}" \ + "${BURROW_PKCS11_MODULE:-}" \ + "$(command -v google-kms-pkcs11-module >/dev/null 2>&1 && google-kms-pkcs11-module || true)" \ + /nix/store/*-google-kms-pkcs11-*/lib/libkmsp11.so \ + /nix/store/*-google-kms-pkcs11-*/lib/libkmsp11.dylib; do + if [[ -n "$candidate" && -f "$candidate" ]]; then + printf '%s\n' "$candidate" + return 0 + fi + done + return 1 +} + +cert_public_key() { + local cert_file="$1" + local out="$2" + if ! openssl x509 -inform DER -in "$cert_file" -pubkey -noout >"$out" 2>/dev/null; then + openssl x509 -in "$cert_file" -pubkey -noout >"$out" + fi +} + +public_fingerprint() { + openssl pkey -pubin -in "$1" -outform DER \ + | openssl dgst -sha256 -binary \ + | od -An -tx1 \ + | tr -d ' \n' +} + +resolve_kms_parts() { + local resource="$1" + local key_ring="${BURROW_GCP_KMS_KEY_RING:-${GOOGLE_KMS_KEY_RING:-projects/${GOOGLE_CLOUD_PROJECT:-project-88c23ce9-918a-470a-b33}/locations/${BURROW_KMS_LOCATION:-global}/keyRings/${BURROW_KMS_KEYRING:-burrow-identity}}}" + + if [[ "$resource" =~ ^projects/([^/]+)/locations/([^/]+)/keyRings/([^/]+)/cryptoKeys/([^/]+)/cryptoKeyVersions/([^/]+)$ ]]; then + printf '%s\n%s\n%s\n%s\n%s\n' "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "${BASH_REMATCH[3]}" "${BASH_REMATCH[4]}" "${BASH_REMATCH[5]}" + return 0 + fi + if [[ "$resource" =~ ^projects/([^/]+)/locations/([^/]+)/keyRings/([^/]+)/cryptoKeys/([^/]+)$ ]]; then + printf '%s\n%s\n%s\n%s\n%s\n' "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "${BASH_REMATCH[3]}" "${BASH_REMATCH[4]}" "$kms_version" + return 0 + fi + if [[ ! "$key_ring" =~ ^projects/([^/]+)/locations/([^/]+)/keyRings/([^/]+)$ ]]; then + echo "error: invalid KMS key ring resource: $key_ring" >&2 + exit 1 + fi + printf '%s\n%s\n%s\n%s\n%s\n' "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "${BASH_REMATCH[3]}" "$resource" "$kms_version" +} + +verify_certificate_matches_kms() { + local work_dir="$1" + local cert_public="$work_dir/apple-public.pem" + local kms_public="$work_dir/kms-public.pem" + local project location keyring key version expected actual + kms_info="$(resolve_kms_parts "$kms_key")" + project="$(printf '%s\n' "$kms_info" | sed -n '1p')" + location="$(printf '%s\n' "$kms_info" | sed -n '2p')" + keyring="$(printf '%s\n' "$kms_info" | sed -n '3p')" + key="$(printf '%s\n' "$kms_info" | sed -n '4p')" + version="$(printf '%s\n' "$kms_info" | sed -n '5p')" + if [[ -z "$version" ]]; then + echo "error: KMS key version is required for Apple release signing" >&2 + exit 1 + fi + + cert_public_key "$certificate" "$cert_public" + expected="$(public_fingerprint "$cert_public")" + gcloud kms keys versions get-public-key "$version" \ + --project="$project" \ + --location="$location" \ + --keyring="$keyring" \ + --key="$key" \ + --output-file="$kms_public" >/dev/null + actual="$(public_fingerprint "$kms_public")" + if [[ "$actual" != "$expected" ]]; then + echo "error: Apple certificate public key does not match Google KMS key" >&2 + echo "family=$family" >&2 + echo "kms_key=$key" >&2 + echo "kms_version=$version" >&2 + echo "certificate_spki_sha256=$expected" >&2 + echo "kms_spki_sha256=$actual" >&2 + exit 1 + fi +} + +require_tool rcodesign +require_tool openssl +require_tool od +require_tool gcloud + +if ! rcodesign sign --help 2>&1 | grep -Fq -- "--pkcs11-library"; then + echo "error: rcodesign does not include PKCS#11 signing support" >&2 + exit 1 +fi + +module="$(resolve_module || true)" +if [[ -z "$module" ]]; then + echo "error: unable to locate Google KMS PKCS#11 module" >&2 + exit 1 +fi + +work_dir="$(mktemp -d "${TMPDIR:-/tmp}/burrow-apple-kms-sign.XXXXXX")" +trap 'rm -rf "$work_dir"' EXIT + +eval "$(Scripts/release/google-kms-pkcs11-materialize.sh --emit-env)" +verify_certificate_matches_kms "$work_dir" + +real_openssl="$(command -v openssl)" +export BURROW_REAL_OPENSSL="${BURROW_REAL_OPENSSL:-$real_openssl}" +export BURROW_OPENSSL="$repo_root/Scripts/release/google-kms-openssl-dgst-shim.sh" +export BURROW_APPLE_PKCS11_BACKEND=gcp-kms +export BURROW_APPLE_PKCS11_SIGN_WITH_OPENSSL_PROVIDER=true +export BURROW_APPLE_PKCS11_SIGN_WITH_GCLOUD=true +export BURROW_GCP_KMS_ACTIVE_CRYPTO_KEY="$kms_key" +export BURROW_GCP_KMS_ACTIVE_CRYPTO_KEY_VERSION="$kms_version" + +pin="${BURROW_APPLE_PKCS11_PIN:-${BURROW_GCP_KMS_PKCS11_PIN:-${BURROW_PKCS11_PIN:-ignored}}}" +token_label="${BURROW_APPLE_PKCS11_TOKEN_LABEL:-${BURROW_GCP_KMS_PKCS11_TOKEN_LABEL:-${BURROW_PKCS11_TOKEN_LABEL:-burrow-release}}}" + +args=( + sign + --pkcs11-library "$module" + --pkcs11-certificate-file "$certificate" + --pkcs11-token-label "$token_label" + --pkcs11-key-label "$kms_key" + --pkcs11-pin "$pin" +) +if [[ -n "$timestamp_url" ]]; then + args+=(--timestamp-url "$timestamp_url") +fi +if [[ -n "$entitlements" ]]; then + args+=(--entitlements-xml-file "$entitlements") +fi +if [[ "$runtime" == "true" ]]; then + args+=(--code-signature-flags runtime) +fi +args+=("$path") + +rcodesign "${args[@]}" diff --git a/Scripts/apple/sync-provisioning-profiles.mjs b/Scripts/apple/sync-provisioning-profiles.mjs new file mode 100755 index 0000000..1a592d6 --- /dev/null +++ b/Scripts/apple/sync-provisioning-profiles.mjs @@ -0,0 +1,331 @@ +#!/usr/bin/env node +import fs from "node:fs"; +import path from "node:path"; +import { webcrypto } from "node:crypto"; + +const crypto = globalThis.crypto ?? webcrypto; + +function b64url(input) { + const buf = Buffer.isBuffer(input) ? input : Buffer.from(input); + return buf + .toString("base64") + .replace(/=/g, "") + .replace(/\+/g, "-") + .replace(/\//g, "_"); +} + +function parseArgs(argv) { + const out = { _: [] }; + for (let i = 2; i < argv.length; i++) { + const arg = argv[i]; + if (arg === "--help" || arg === "-h") out.help = true; + else if (arg.startsWith("--")) { + const key = arg.slice(2); + const value = argv[i + 1]; + if (!value || value.startsWith("--")) throw new Error(`missing value for --${key}`); + out[key] = value; + i++; + } else { + out._.push(arg); + } + } + return out; +} + +async function makeJwt({ keyId, issuerId, keyPem }) { + const header = { alg: "ES256", kid: keyId, typ: "JWT" }; + const now = Math.floor(Date.now() / 1000); + const payload = { iss: issuerId, exp: now + 20 * 60, aud: "appstoreconnect-v1" }; + const input = `${b64url(JSON.stringify(header))}.${b64url(JSON.stringify(payload))}`; + const pkcs8Der = Buffer.from( + keyPem.replace(/-----BEGIN PRIVATE KEY-----|-----END PRIVATE KEY-----|\s+/g, ""), + "base64", + ); + const key = await crypto.subtle.importKey( + "pkcs8", + pkcs8Der, + { name: "ECDSA", namedCurve: "P-256" }, + false, + ["sign"], + ); + const sig = await crypto.subtle.sign( + { name: "ECDSA", hash: "SHA-256" }, + key, + new TextEncoder().encode(input), + ); + return `${input}.${b64url(Buffer.from(sig))}`; +} + +async function ascFetch(jwt, url, opts = {}) { + const res = await fetch(url, { + ...opts, + headers: { + ...(opts.headers ?? {}), + Authorization: `Bearer ${jwt}`, + "Content-Type": "application/json", + }, + }); + const text = await res.text(); + let body; + try { + body = text ? JSON.parse(text) : {}; + } catch { + body = { raw: text }; + } + if (!res.ok) { + throw new Error(`ASC ${res.status} ${url}: ${JSON.stringify(body).slice(0, 2000)}`); + } + return body; +} + +function truthy(value) { + return ["1", "true", "yes", "on"].includes(String(value ?? "").toLowerCase()); +} + +function safeFileName(identifier, suffix) { + return `${identifier.replace(/[^A-Za-z0-9]/g, "").toLowerCase()}${suffix}`; +} + +function bundleDisplayName(identifier, appId) { + return identifier === appId ? "Burrow App" : "Burrow Network Extension"; +} + +async function findCertificate(jwt, preferredTypes, preferredId) { + const certs = await ascFetch( + jwt, + "https://api.appstoreconnect.apple.com/v1/certificates?limit=200", + ); + const data = certs.data ?? []; + if (preferredId) { + const cert = data.find((item) => item?.id === preferredId); + if (!cert) throw new Error(`unable to locate certificate id ${preferredId} via ASC API`); + const type = cert?.attributes?.certificateType; + if (preferredTypes.length && !preferredTypes.includes(type)) { + throw new Error(`certificate ${preferredId} has type ${type}, expected ${preferredTypes.join(" or ")}`); + } + return cert; + } + for (const type of preferredTypes) { + const cert = data.find((item) => item?.attributes?.certificateType === type); + if (cert) return cert; + } + throw new Error(`unable to locate certificate type ${preferredTypes.join(" or ")} via ASC API`); +} + +async function resolveBundle(jwt, target, { createMissing, platform }) { + const bundleResp = await ascFetch( + jwt, + `https://api.appstoreconnect.apple.com/v1/bundleIds?limit=5&filter[identifier]=${encodeURIComponent(target.identifier)}`, + ); + let bundle = (bundleResp.data ?? []).find( + (item) => item?.attributes?.identifier === target.identifier, + ); + if (bundle || !createMissing) return bundle; + + const created = await ascFetch(jwt, "https://api.appstoreconnect.apple.com/v1/bundleIds", { + method: "POST", + body: JSON.stringify({ + data: { + type: "bundleIds", + attributes: { + identifier: target.identifier, + name: target.bundleName ?? target.name, + platform, + }, + }, + }), + }); + bundle = created?.data; + if (bundle?.id) { + process.stdout.write(`created bundle id ${target.identifier} (${platform})\n`); + } + return bundle; +} + +async function listCapabilityTypes(jwt, bundleId) { + const resp = await ascFetch( + jwt, + `https://api.appstoreconnect.apple.com/v1/bundleIds/${bundleId}/bundleIdCapabilities`, + ); + return new Set((resp.data ?? []).map((item) => item?.attributes?.capabilityType).filter(Boolean)); +} + +async function enableCapability(jwt, bundleId, capabilityType, settings) { + await ascFetch(jwt, "https://api.appstoreconnect.apple.com/v1/bundleIdCapabilities", { + method: "POST", + body: JSON.stringify({ + data: { + type: "bundleIdCapabilities", + attributes: { + capabilityType, + ...(settings ? { settings } : {}), + }, + relationships: { + bundleId: { + data: { + id: bundleId, + type: "bundleIds", + }, + }, + }, + }, + }), + }); +} + +async function profileIncludesCertificate(jwt, profileId, certificateId) { + const resp = await ascFetch( + jwt, + `https://api.appstoreconnect.apple.com/v1/profiles/${profileId}/certificates?limit=200`, + ); + return (resp.data ?? []).some((item) => item?.id === certificateId); +} + +async function ensureCapabilities(jwt, bundle, capabilities) { + const existing = await listCapabilityTypes(jwt, bundle.id); + for (const capability of capabilities) { + if (existing.has(capability.type)) continue; + try { + await enableCapability(jwt, bundle.id, capability.type, capability.settings); + process.stdout.write(`enabled ${capability.type} for ${bundle.attributes.identifier}\n`); + } catch (err) { + process.stderr.write(`warning: could not enable ${capability.type} for ${bundle.attributes.identifier}: ${err.message}\n`); + } + } +} + +async function syncTarget(jwt, cert, profileType, target, outDir, options) { + const bundle = await resolveBundle(jwt, target, options); + if (!bundle) throw new Error(`bundleId not found in ASC: ${target.identifier}`); + + if (options.enableCapabilities && target.capabilities?.length) { + await ensureCapabilities(jwt, bundle, target.capabilities); + } + + const existing = await ascFetch( + jwt, + `https://api.appstoreconnect.apple.com/v1/profiles?limit=10&filter[profileType]=${encodeURIComponent(profileType)}&filter[name]=${encodeURIComponent(target.name)}`, + ); + let profileId = (existing.data ?? []).find((item) => item?.attributes?.name === target.name)?.id; + if (profileId && options.replaceCertificateMismatch) { + const includesCertificate = await profileIncludesCertificate(jwt, profileId, cert.id); + if (!includesCertificate) { + await ascFetch(jwt, `https://api.appstoreconnect.apple.com/v1/profiles/${profileId}`, { + method: "DELETE", + }); + process.stdout.write(`deleted stale profile ${target.name}; it did not include certificate ${cert.id}\n`); + profileId = undefined; + } + } + if (!profileId) { + const created = await ascFetch(jwt, "https://api.appstoreconnect.apple.com/v1/profiles", { + method: "POST", + body: JSON.stringify({ + data: { + type: "profiles", + attributes: { name: target.name, profileType }, + relationships: { + bundleId: { data: { type: "bundleIds", id: bundle.id } }, + certificates: { data: [{ type: "certificates", id: cert.id }] }, + }, + }, + }), + }); + profileId = created?.data?.id; + } + if (!profileId) throw new Error(`failed to resolve/create profile for ${target.identifier}`); + + const profile = await ascFetch(jwt, `https://api.appstoreconnect.apple.com/v1/profiles/${profileId}`); + const content = profile?.data?.attributes?.profileContent; + if (!content) throw new Error(`profileContent missing for ${target.name} (${profileId})`); + + fs.mkdirSync(outDir, { recursive: true }); + const profileBytes = Buffer.from(content, "base64"); + const profilePath = path.join(outDir, target.file); + fs.writeFileSync(profilePath, profileBytes); + if (target.mobileFile) { + fs.writeFileSync(path.join(outDir, target.mobileFile), profileBytes); + } + process.stdout.write(`synced ${target.identifier} -> ${profilePath}\n`); +} + +async function main() { + const args = parseArgs(process.argv); + if (args.help) { + console.log("Usage: sync-provisioning-profiles.mjs --platform ios|macos|all --key-id ID --issuer-id ID --key-file AuthKey.p8 --out-dir DIR [--ios-certificate-id ID] [--macos-certificate-id ID] [--replace-certificate-mismatch true]"); + process.exit(0); + } + + const platform = args.platform ?? "all"; + const keyId = args["key-id"]; + const issuerId = args["issuer-id"]; + const keyFile = args["key-file"]; + const outDir = args["out-dir"] ?? ".forgejo/actions/export"; + const appId = args["app-id"] ?? "net.burrow.app"; + const networkId = args["network-id"] ?? `${appId}.network`; + const iosCertificateId = args["ios-certificate-id"] ?? process.env.BURROW_IOS_DISTRIBUTION_CERTIFICATE_ID; + const macosCertificateId = args["macos-certificate-id"] ?? process.env.BURROW_DEVELOPER_ID_CERTIFICATE_ID; + const createMissing = truthy(args["create-missing-bundle-ids"]); + const enableCapabilities = createMissing || truthy(args["enable-capabilities"]); + const replaceCertificateMismatch = truthy(args["replace-certificate-mismatch"]); + const bundlePlatform = args["bundle-platform"] ?? "UNIVERSAL"; + const associatedDomains = (args["associated-domains"] ?? "applinks:burrow.rs?mode=developer,webcredentials:burrow.rs?mode=developer") + .split(",") + .map((item) => item.trim()) + .filter(Boolean); + const appCapabilities = [ + { type: "NETWORK_EXTENSIONS" }, + { type: "APP_GROUPS" }, + { + type: "ASSOCIATED_DOMAINS", + settings: [{ key: "ASSOCIATED_DOMAIN_IDS", options: associatedDomains.map((key) => ({ key, enabled: true })) }], + }, + ]; + const extensionCapabilities = [ + { type: "NETWORK_EXTENSIONS" }, + { type: "APP_GROUPS" }, + ]; + const options = { createMissing, enableCapabilities, replaceCertificateMismatch, platform: bundlePlatform }; + + if (!keyId || !issuerId || !keyFile) throw new Error("required: --key-id --issuer-id --key-file"); + + const jwt = await makeJwt({ keyId, issuerId, keyPem: fs.readFileSync(keyFile, "utf8") }); + + if (platform === "ios" || platform === "all") { + const cert = await findCertificate(jwt, ["IOS_DISTRIBUTION", "DISTRIBUTION", "APPLE_DISTRIBUTION"], iosCertificateId); + const targets = [appId, networkId].map((identifier) => ({ + identifier, + name: `${identifier}.app-store`, + bundleName: bundleDisplayName(identifier, appId), + file: safeFileName(identifier, "appstore.provisionprofile"), + mobileFile: safeFileName(identifier, "appstore.mobileprovision"), + capabilities: identifier === appId ? appCapabilities : extensionCapabilities, + })); + for (const target of targets) { + await syncTarget(jwt, cert, "IOS_APP_STORE", target, outDir, options); + } + } + + if (platform === "macos" || platform === "all") { + const cert = await findCertificate( + jwt, + ["DEVELOPER_ID_APPLICATION", "DEVELOPER_ID_APPLICATION_G2"], + macosCertificateId, + ); + const targets = [appId, networkId].map((identifier) => ({ + identifier, + name: `${identifier}.developer-id`, + bundleName: bundleDisplayName(identifier, appId), + file: safeFileName(identifier, "developerid.provisionprofile"), + capabilities: identifier === appId ? appCapabilities : extensionCapabilities, + })); + for (const target of targets) { + await syncTarget(jwt, cert, "MAC_APP_DIRECT", target, outDir, options); + } + } +} + +main().catch((err) => { + console.error(err?.stack || String(err)); + process.exit(1); +}); diff --git a/Scripts/authentik-sync-burrow-directory.sh b/Scripts/authentik-sync-burrow-directory.sh index 277c5f4..68dbcff 100644 --- a/Scripts/authentik-sync-burrow-directory.sh +++ b/Scripts/authentik-sync-burrow-directory.sh @@ -6,6 +6,7 @@ bootstrap_token="${AUTHENTIK_BOOTSTRAP_TOKEN:-}" directory_json="${AUTHENTIK_BURROW_DIRECTORY_JSON:-[]}" users_group="${AUTHENTIK_BURROW_USERS_GROUP:-burrow-users}" admins_group="${AUTHENTIK_BURROW_ADMINS_GROUP:-burrow-admins}" +extra_groups_json="${AUTHENTIK_BURROW_EXTRA_GROUPS_JSON:-[]}" forgejo_application_slug="${AUTHENTIK_FORGEJO_APPLICATION_SLUG:-}" usage() { @@ -20,6 +21,7 @@ Optional environment: AUTHENTIK_URL AUTHENTIK_BURROW_USERS_GROUP AUTHENTIK_BURROW_ADMINS_GROUP + AUTHENTIK_BURROW_EXTRA_GROUPS_JSON AUTHENTIK_FORGEJO_APPLICATION_SLUG EOF } @@ -39,6 +41,11 @@ if ! printf '%s' "$directory_json" | jq -e 'type == "array"' >/dev/null; then exit 1 fi +if ! printf '%s' "$extra_groups_json" | jq -e 'type == "array"' >/dev/null; then + echo "error: AUTHENTIK_BURROW_EXTRA_GROUPS_JSON must be a JSON array" >&2 + exit 1 +fi + api() { local method="$1" local path="$2" @@ -251,6 +258,9 @@ ensure_application_group_binding() { wait_for_authentik ensure_group "$users_group" >/dev/null ensure_group "$admins_group" >/dev/null +while IFS= read -r group_name; do + ensure_group "$group_name" >/dev/null +done < <(printf '%s\n' "$extra_groups_json" | jq -r '.[]') while IFS= read -r user_spec; do ensure_user "$user_spec" diff --git a/Scripts/authentik-sync-forgejo-oidc.sh b/Scripts/authentik-sync-forgejo-oidc.sh index 7b292dc..b490698 100644 --- a/Scripts/authentik-sync-forgejo-oidc.sh +++ b/Scripts/authentik-sync-forgejo-oidc.sh @@ -11,8 +11,7 @@ client_secret="${AUTHENTIK_FORGEJO_CLIENT_SECRET:-}" launch_url="${AUTHENTIK_FORGEJO_LAUNCH_URL:-https://git.burrow.net/}" redirect_uris_json="${AUTHENTIK_FORGEJO_REDIRECT_URIS_JSON:-[ \"https://git.burrow.net/user/oauth2/burrow.net/callback\", - \"https://git.burrow.net/user/oauth2/authentik/callback\", - \"https://git.burrow.net/user/oauth2/GitHub/callback\" + \"https://git.burrow.net/user/oauth2/authentik/callback\" ]}" usage() { diff --git a/Scripts/authentik-sync-google-wif-oidc.sh b/Scripts/authentik-sync-google-wif-oidc.sh new file mode 100755 index 0000000..c8bae10 --- /dev/null +++ b/Scripts/authentik-sync-google-wif-oidc.sh @@ -0,0 +1,347 @@ +#!/usr/bin/env bash +set -euo pipefail + +authentik_url="${AUTHENTIK_URL:-https://auth.burrow.net}" +bootstrap_token="${AUTHENTIK_BOOTSTRAP_TOKEN:-}" +application_slug="${AUTHENTIK_GOOGLE_WIF_APPLICATION_SLUG:-google-cloud}" +application_name="${AUTHENTIK_GOOGLE_WIF_APPLICATION_NAME:-Google Cloud WIF}" +provider_name="${AUTHENTIK_GOOGLE_WIF_PROVIDER_NAME:-Google Cloud WIF}" +template_slug="${AUTHENTIK_GOOGLE_WIF_TEMPLATE_SLUG:-ts}" +client_id="${AUTHENTIK_GOOGLE_WIF_CLIENT_ID:-google-wif.burrow.net}" +client_secret="${AUTHENTIK_GOOGLE_WIF_CLIENT_SECRET:-}" +launch_url="${AUTHENTIK_GOOGLE_WIF_LAUNCH_URL:-https://console.cloud.google.com/}" +redirect_uris_json="${AUTHENTIK_GOOGLE_WIF_REDIRECT_URIS_JSON:-[]}" +access_group="${AUTHENTIK_GOOGLE_WIF_ACCESS_GROUP:-}" + +usage() { + cat <<'EOF' +Usage: Scripts/authentik-sync-google-wif-oidc.sh + +Reconciles the Authentik OIDC provider used as the Google Workload Identity +Federation issuer for Burrow release runners. + +Required environment: + AUTHENTIK_BOOTSTRAP_TOKEN + AUTHENTIK_GOOGLE_WIF_CLIENT_SECRET + +Optional environment: + AUTHENTIK_URL + AUTHENTIK_GOOGLE_WIF_APPLICATION_SLUG + AUTHENTIK_GOOGLE_WIF_APPLICATION_NAME + AUTHENTIK_GOOGLE_WIF_PROVIDER_NAME + AUTHENTIK_GOOGLE_WIF_TEMPLATE_SLUG + AUTHENTIK_GOOGLE_WIF_CLIENT_ID + AUTHENTIK_GOOGLE_WIF_LAUNCH_URL + AUTHENTIK_GOOGLE_WIF_REDIRECT_URIS_JSON + AUTHENTIK_GOOGLE_WIF_ACCESS_GROUP (optional; leave empty for client credentials) + +AUTHENTIK_GOOGLE_WIF_CLIENT_SECRET is the Authentik client-credentials secret +used by Forgejo runners. For service-account authentication, store +base64(":"). +EOF +} + +if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then + usage + exit 0 +fi + +if [[ -z "$bootstrap_token" ]]; then + echo "error: AUTHENTIK_BOOTSTRAP_TOKEN is required" >&2 + exit 1 +fi + +if [[ -z "$client_secret" || "$client_secret" == PENDING* ]]; then + echo "Google WIF OIDC client secret is not configured; skipping Authentik Google WIF sync." >&2 + exit 0 +fi + +if ! printf '%s' "$redirect_uris_json" | jq -e 'type == "array"' >/dev/null; then + echo "error: AUTHENTIK_GOOGLE_WIF_REDIRECT_URIS_JSON must be a JSON array" >&2 + exit 1 +fi + +api() { + local method="$1" + local path="$2" + local data="${3:-}" + + if [[ -n "$data" ]]; then + curl -fsS \ + -X "$method" \ + -H "Authorization: Bearer ${bootstrap_token}" \ + -H "Content-Type: application/json" \ + -d "$data" \ + "${authentik_url}${path}" + else + curl -fsS \ + -X "$method" \ + -H "Authorization: Bearer ${bootstrap_token}" \ + "${authentik_url}${path}" + fi +} + +api_with_status() { + local method="$1" + local path="$2" + local data="${3:-}" + local response_file status + + response_file="$(mktemp)" + trap 'rm -f "$response_file"' RETURN + + if [[ -n "$data" ]]; then + status="$( + curl -sS \ + -o "$response_file" \ + -w '%{http_code}' \ + -X "$method" \ + -H "Authorization: Bearer ${bootstrap_token}" \ + -H "Content-Type: application/json" \ + -d "$data" \ + "${authentik_url}${path}" + )" + else + status="$( + curl -sS \ + -o "$response_file" \ + -w '%{http_code}' \ + -X "$method" \ + -H "Authorization: Bearer ${bootstrap_token}" \ + "${authentik_url}${path}" + )" + fi + + printf '%s\n' "$status" + cat "$response_file" +} + +wait_for_authentik() { + for _ in $(seq 1 90); do + if curl -fsS "${authentik_url}/-/health/ready/" >/dev/null 2>&1; then + return 0 + fi + sleep 2 + done + echo "error: Authentik did not become ready at ${authentik_url}" >&2 + exit 1 +} + +wait_for_authentik + +template_provider="$( + api GET "/api/v3/providers/oauth2/?page_size=200" \ + | jq -c --arg slug "$template_slug" '.results[]? | select(.assigned_application_slug == $slug)' \ + | head -n1 +)" + +if [[ -z "$template_provider" ]]; then + echo "error: could not resolve Authentik OAuth provider template ${template_slug}" >&2 + exit 1 +fi + +authorization_flow="$(printf '%s\n' "$template_provider" | jq -r '.authorization_flow')" +invalidation_flow="$(printf '%s\n' "$template_provider" | jq -r '.invalidation_flow')" +property_mappings="$(printf '%s\n' "$template_provider" | jq -c '.property_mappings')" +signing_key="$(printf '%s\n' "$template_provider" | jq -r '.signing_key')" + +provider_payload="$( + jq -n \ + --arg name "$provider_name" \ + --arg authorization_flow "$authorization_flow" \ + --arg invalidation_flow "$invalidation_flow" \ + --arg client_id "$client_id" \ + --arg client_secret "$client_secret" \ + --arg signing_key "$signing_key" \ + --argjson property_mappings "$property_mappings" \ + --argjson redirect_uris "$redirect_uris_json" \ + '{ + name: $name, + authorization_flow: $authorization_flow, + invalidation_flow: $invalidation_flow, + client_type: "confidential", + grant_types: ["client_credentials"], + client_id: $client_id, + client_secret: $client_secret, + include_claims_in_id_token: true, + redirect_uris: ($redirect_uris | map({matching_mode: "strict", url: .})), + property_mappings: $property_mappings, + signing_key: $signing_key, + issuer_mode: "per_provider", + sub_mode: "hashed_user_id" + }' +)" + +existing_provider="$( + api GET "/api/v3/providers/oauth2/?page_size=200" \ + | jq -c \ + --arg application_slug "$application_slug" \ + --arg provider_name "$provider_name" \ + '.results[]? | select(.assigned_application_slug == $application_slug or .name == $provider_name)' \ + | head -n1 +)" + +if [[ -n "$existing_provider" ]]; then + provider_pk="$(printf '%s\n' "$existing_provider" | jq -r '.pk')" + api PATCH "/api/v3/providers/oauth2/${provider_pk}/" "$provider_payload" >/dev/null +else + provider_pk="$( + api POST "/api/v3/providers/oauth2/" "$provider_payload" \ + | jq -r '.pk // empty' + )" +fi + +if [[ -z "${provider_pk:-}" ]]; then + echo "error: Google WIF OIDC provider did not return a primary key" >&2 + exit 1 +fi + +application_payload="$( + jq -n \ + --arg name "$application_name" \ + --arg slug "$application_slug" \ + --arg provider "$provider_pk" \ + --arg launch_url "$launch_url" \ + '{ + name: $name, + slug: $slug, + provider: ($provider | tonumber), + meta_launch_url: $launch_url, + open_in_new_tab: false, + policy_engine_mode: "any" + }' +)" + +existing_application="$( + api GET "/api/v3/core/applications/?page_size=200" \ + | jq -c --arg slug "$application_slug" '.results[]? | select(.slug == $slug)' \ + | head -n1 +)" + +if [[ -z "$existing_application" ]]; then + direct_application_result="$(api_with_status GET "/api/v3/core/applications/${application_slug}/")" + direct_application_status="$(printf '%s\n' "$direct_application_result" | sed -n '1p')" + direct_application_body="$(printf '%s\n' "$direct_application_result" | sed '1d')" + if [[ "$direct_application_status" == "200" ]]; then + existing_application="$direct_application_body" + fi +fi + +if [[ -n "$existing_application" ]]; then + application_pk="$(printf '%s\n' "$existing_application" | jq -r '.pk')" + api PATCH "/api/v3/core/applications/${application_slug}/" "$application_payload" >/dev/null +else + create_application_result="$( + api_with_status POST "/api/v3/core/applications/" "$application_payload" + )" + create_application_status="$(printf '%s\n' "$create_application_result" | sed -n '1p')" + create_application_body="$(printf '%s\n' "$create_application_result" | sed '1d')" + + if [[ "$create_application_status" =~ ^20[01]$ ]]; then + application_pk="$(printf '%s\n' "$create_application_body" | jq -r '.pk // empty')" + elif [[ "$create_application_status" == "400" ]] && printf '%s\n' "$create_application_body" | jq -e ' + (.slug // [] | index("Application with this slug already exists.")) != null + or (.provider // [] | index("Application with this provider already exists.")) != null + ' >/dev/null; then + application_pk="$( + api GET "/api/v3/core/applications/?page_size=200" \ + | jq -r --arg slug "$application_slug" '.results[]? | select(.slug == $slug) | .pk // empty' \ + | head -n1 + )" + if [[ -z "$application_pk" ]]; then + direct_application_result="$(api_with_status GET "/api/v3/core/applications/${application_slug}/")" + direct_application_status="$(printf '%s\n' "$direct_application_result" | sed -n '1p')" + direct_application_body="$(printf '%s\n' "$direct_application_result" | sed '1d')" + if [[ "$direct_application_status" == "200" ]]; then + application_pk="$(printf '%s\n' "$direct_application_body" | jq -r '.pk // empty')" + fi + fi + else + printf '%s\n' "$create_application_body" >&2 + echo "error: could not reconcile Authentik application ${application_slug}" >&2 + exit 1 + fi +fi + +if [[ -z "${application_pk:-}" ]]; then + echo "error: Google WIF OIDC application did not return a primary key" >&2 + exit 1 +fi + +delete_binding() { + local binding_pk="$1" + api DELETE "/api/v3/policies/bindings/${binding_pk}/" >/dev/null || true +} + +delete_application_group_bindings_except() { + local keep_group_pk="${1:-}" + local binding_pks + + binding_pks="$( + api GET "/api/v3/policies/bindings/?page_size=500" \ + | jq -r \ + --arg target "$application_pk" \ + --arg keep_group "$keep_group_pk" \ + '.results[]? + | select((.target | tostring) == $target and .group != null) + | select(($keep_group == "") or ((.group | tostring) != $keep_group)) + | .pk' + )" + + while IFS= read -r binding_pk; do + [[ -n "$binding_pk" ]] || continue + delete_binding "$binding_pk" + done <<< "$binding_pks" +} + +if [[ -n "$access_group" ]]; then + group_pk="$( + api GET "/api/v3/core/groups/?page_size=200" \ + | jq -r --arg name "$access_group" '.results[]? | select(.name == $name) | .pk' \ + | head -n1 + )" + if [[ -z "$group_pk" ]]; then + echo "warning: Authentik Google WIF access group ${access_group} was not found; application policy left unchanged." >&2 + else + delete_application_group_bindings_except "$group_pk" + existing_binding="$( + api GET "/api/v3/policies/bindings/?page_size=500" \ + | jq -r \ + --arg target "$application_pk" \ + --arg group "$group_pk" \ + '.results[]? + | select((.target | tostring) == $target and (.group | tostring) == $group) + | .pk' \ + | head -n1 + )" + if [[ -z "$existing_binding" ]]; then + api POST "/api/v3/policies/bindings/" "$( + jq -n \ + --arg target "$application_pk" \ + --arg group "$group_pk" \ + '{ + target: $target, + group: $group, + negate: false, + order: 0, + enabled: true, + timeout: 30, + failure_result: false + }' + )" >/dev/null || true + fi + fi +else + delete_application_group_bindings_except "" +fi + +for _ in $(seq 1 30); do + if curl -fsS "${authentik_url}/application/o/${application_slug}/.well-known/openid-configuration" >/dev/null 2>&1; then + echo "Synced Authentik Google WIF OIDC application ${application_slug} (${application_name})." + exit 0 + fi + sleep 2 +done + +echo "warning: Google WIF OIDC issuer document for ${application_slug} was not immediately readable; keeping reconciled config." >&2 +echo "Synced Authentik Google WIF OIDC application ${application_slug} (${application_name})." diff --git a/Scripts/authentik-sync-grafana-oidc.sh b/Scripts/authentik-sync-grafana-oidc.sh new file mode 100755 index 0000000..0d32c06 --- /dev/null +++ b/Scripts/authentik-sync-grafana-oidc.sh @@ -0,0 +1,332 @@ +#!/usr/bin/env bash +set -euo pipefail + +authentik_url="${AUTHENTIK_URL:-https://auth.burrow.net}" +bootstrap_token="${AUTHENTIK_BOOTSTRAP_TOKEN:-}" +application_slug="${AUTHENTIK_GRAFANA_APPLICATION_SLUG:-grafana}" +application_name="${AUTHENTIK_GRAFANA_APPLICATION_NAME:-Burrow Grafana}" +provider_name="${AUTHENTIK_GRAFANA_PROVIDER_NAME:-Burrow Grafana}" +template_slug="${AUTHENTIK_GRAFANA_TEMPLATE_SLUG:-ts}" +client_id="${AUTHENTIK_GRAFANA_CLIENT_ID:-graphs.burrow.net}" +client_secret="${AUTHENTIK_GRAFANA_CLIENT_SECRET:-}" +launch_url="${AUTHENTIK_GRAFANA_LAUNCH_URL:-https://graphs.burrow.net/}" +access_group="${AUTHENTIK_GRAFANA_ACCESS_GROUP:-}" +redirect_uris_json="${AUTHENTIK_GRAFANA_REDIRECT_URIS_JSON:-[ + \"https://graphs.burrow.net/login/generic_oauth\" +]}" + +usage() { + cat <<'EOF' +Usage: Scripts/authentik-sync-grafana-oidc.sh + +Required environment: + AUTHENTIK_BOOTSTRAP_TOKEN + AUTHENTIK_GRAFANA_CLIENT_SECRET + +Optional environment: + AUTHENTIK_URL + AUTHENTIK_GRAFANA_APPLICATION_SLUG + AUTHENTIK_GRAFANA_APPLICATION_NAME + AUTHENTIK_GRAFANA_PROVIDER_NAME + AUTHENTIK_GRAFANA_TEMPLATE_SLUG + AUTHENTIK_GRAFANA_CLIENT_ID + AUTHENTIK_GRAFANA_LAUNCH_URL + AUTHENTIK_GRAFANA_REDIRECT_URIS_JSON + AUTHENTIK_GRAFANA_ACCESS_GROUP +EOF +} + +if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then + usage + exit 0 +fi + +if [[ -z "$bootstrap_token" ]]; then + echo "error: AUTHENTIK_BOOTSTRAP_TOKEN is required" >&2 + exit 1 +fi + +if [[ -z "$client_secret" || "$client_secret" == PENDING* ]]; then + echo "Grafana OIDC client secret is not configured; skipping Authentik Grafana sync." >&2 + exit 0 +fi + +if ! printf '%s' "$redirect_uris_json" | jq -e 'type == "array" and length > 0' >/dev/null; then + echo "error: AUTHENTIK_GRAFANA_REDIRECT_URIS_JSON must be a non-empty JSON array" >&2 + exit 1 +fi + +api() { + local method="$1" + local path="$2" + local data="${3:-}" + + if [[ -n "$data" ]]; then + curl -fsS \ + -X "$method" \ + -H "Authorization: Bearer ${bootstrap_token}" \ + -H "Content-Type: application/json" \ + -d "$data" \ + "${authentik_url}${path}" + else + curl -fsS \ + -X "$method" \ + -H "Authorization: Bearer ${bootstrap_token}" \ + "${authentik_url}${path}" + fi +} + +api_with_status() { + local method="$1" + local path="$2" + local data="${3:-}" + local response_file status + + response_file="$(mktemp)" + trap 'rm -f "$response_file"' RETURN + + if [[ -n "$data" ]]; then + status="$( + curl -sS \ + -o "$response_file" \ + -w '%{http_code}' \ + -X "$method" \ + -H "Authorization: Bearer ${bootstrap_token}" \ + -H "Content-Type: application/json" \ + -d "$data" \ + "${authentik_url}${path}" + )" + else + status="$( + curl -sS \ + -o "$response_file" \ + -w '%{http_code}' \ + -X "$method" \ + -H "Authorization: Bearer ${bootstrap_token}" \ + "${authentik_url}${path}" + )" + fi + + printf '%s\n' "$status" + cat "$response_file" +} + +wait_for_authentik() { + for _ in $(seq 1 90); do + if curl -fsS "${authentik_url}/-/health/ready/" >/dev/null 2>&1; then + return 0 + fi + sleep 2 + done + echo "error: Authentik did not become ready at ${authentik_url}" >&2 + exit 1 +} + +lookup_group_pk() { + local group_name="$1" + + api GET "/api/v3/core/groups/?page_size=200" \ + | jq -r --arg group_name "$group_name" '.results[]? | select(.name == $group_name) | .pk // empty' \ + | head -n1 +} + +lookup_application_pk() { + local slug="$1" + local application_pk lookup_result lookup_status + + application_pk="$( + api GET "/api/v3/core/applications/?page_size=200" \ + | jq -r --arg slug "$slug" '.results[]? | select(.slug == $slug) | .pk // empty' \ + | head -n1 + )" + + if [[ -n "$application_pk" ]]; then + printf '%s\n' "$application_pk" + return 0 + fi + + lookup_result="$(api_with_status GET "/api/v3/core/applications/${slug}/")" + lookup_status="$(printf '%s\n' "$lookup_result" | sed -n '1p')" + if [[ "$lookup_status" =~ ^20[01]$ ]]; then + printf '%s\n' "$lookup_result" | sed '1d' | jq -r '.pk // empty' + fi +} + +ensure_application_group_binding() { + local application_slug="$1" + local group_name="$2" + local application_pk group_pk existing payload binding_pk + + application_pk="$(lookup_application_pk "$application_slug")" + if [[ -z "$application_pk" ]]; then + echo "warning: could not resolve Authentik application ${application_slug}; skipping application group binding" >&2 + return 0 + fi + + group_pk="$(lookup_group_pk "$group_name")" + if [[ -z "$group_pk" ]]; then + echo "error: could not resolve Authentik group ${group_name}" >&2 + exit 1 + fi + + existing="$( + api GET "/api/v3/policies/bindings/?page_size=200&target=${application_pk}" \ + | jq -c --arg group_pk "$group_pk" '.results[]? | select(.group == $group_pk)' \ + | head -n1 + )" + + payload="$( + jq -cn \ + --arg target "$application_pk" \ + --arg group "$group_pk" \ + '{ + group: $group, + target: $target, + negate: false, + enabled: true, + order: 100, + timeout: 30, + failure_result: false + }' + )" + + if [[ -n "$existing" ]]; then + binding_pk="$(printf '%s\n' "$existing" | jq -r '.pk')" + api PATCH "/api/v3/policies/bindings/${binding_pk}/" "$payload" >/dev/null + else + api POST "/api/v3/policies/bindings/" "$payload" >/dev/null + fi +} + +wait_for_authentik + +template_provider="$( + api GET "/api/v3/providers/oauth2/?page_size=200" \ + | jq -c --arg template_slug "$template_slug" '.results[]? | select(.assigned_application_slug == $template_slug)' \ + | head -n1 +)" + +if [[ -z "$template_provider" ]]; then + echo "error: could not resolve the Authentik OAuth provider template ${template_slug}" >&2 + exit 1 +fi + +authorization_flow="$(printf '%s\n' "$template_provider" | jq -r '.authorization_flow')" +invalidation_flow="$(printf '%s\n' "$template_provider" | jq -r '.invalidation_flow')" +property_mappings="$(printf '%s\n' "$template_provider" | jq -c '.property_mappings')" +signing_key="$(printf '%s\n' "$template_provider" | jq -r '.signing_key')" + +provider_payload="$( + jq -n \ + --arg name "$provider_name" \ + --arg authorization_flow "$authorization_flow" \ + --arg invalidation_flow "$invalidation_flow" \ + --arg client_id "$client_id" \ + --arg client_secret "$client_secret" \ + --arg signing_key "$signing_key" \ + --argjson property_mappings "$property_mappings" \ + --argjson redirect_uris "$redirect_uris_json" \ + '{ + name: $name, + authorization_flow: $authorization_flow, + invalidation_flow: $invalidation_flow, + client_type: "confidential", + client_id: $client_id, + client_secret: $client_secret, + include_claims_in_id_token: true, + redirect_uris: ($redirect_uris | map({matching_mode: "strict", url: .})), + property_mappings: $property_mappings, + signing_key: $signing_key, + issuer_mode: "per_provider", + sub_mode: "hashed_user_id" + }' +)" + +existing_provider="$( + api GET "/api/v3/providers/oauth2/?page_size=200" \ + | jq -c \ + --arg application_slug "$application_slug" \ + --arg provider_name "$provider_name" \ + '.results[]? | select(.assigned_application_slug == $application_slug or .name == $provider_name)' \ + | head -n1 +)" + +if [[ -n "$existing_provider" ]]; then + provider_pk="$(printf '%s\n' "$existing_provider" | jq -r '.pk')" + api PATCH "/api/v3/providers/oauth2/${provider_pk}/" "$provider_payload" >/dev/null +else + provider_pk="$( + api POST "/api/v3/providers/oauth2/" "$provider_payload" \ + | jq -r '.pk // empty' + )" +fi + +if [[ -z "${provider_pk:-}" ]]; then + echo "error: Grafana OIDC provider did not return a primary key" >&2 + exit 1 +fi + +application_payload="$( + jq -n \ + --arg name "$application_name" \ + --arg slug "$application_slug" \ + --arg provider "$provider_pk" \ + --arg launch_url "$launch_url" \ + '{ + name: $name, + slug: $slug, + provider: ($provider | tonumber), + meta_launch_url: $launch_url, + open_in_new_tab: false, + policy_engine_mode: "any" + }' +)" + +existing_application="$( + api GET "/api/v3/core/applications/?page_size=200" \ + | jq -c --arg slug "$application_slug" '.results[]? | select(.slug == $slug)' \ + | head -n1 +)" + +if [[ -n "$existing_application" ]]; then + application_pk="$(printf '%s\n' "$existing_application" | jq -r '.pk')" +else + create_application_result="$( + api_with_status POST "/api/v3/core/applications/" "$application_payload" + )" + create_application_status="$(printf '%s\n' "$create_application_result" | sed -n '1p')" + create_application_body="$(printf '%s\n' "$create_application_result" | sed '1d')" + + if [[ "$create_application_status" =~ ^20[01]$ ]]; then + application_pk="$(printf '%s\n' "$create_application_body" | jq -r '.pk // empty')" + elif [[ "$create_application_status" == "400" ]] && printf '%s\n' "$create_application_body" | jq -e ' + (.slug // [] | index("Application with this slug already exists.")) != null + or (.provider // [] | index("Application with this provider already exists.")) != null + ' >/dev/null; then + application_pk="existing-duplicate" + else + printf '%s\n' "$create_application_body" >&2 + echo "error: could not reconcile Authentik application ${application_slug}" >&2 + exit 1 + fi +fi + +if [[ -z "${application_pk:-}" ]]; then + echo "error: Grafana OIDC application did not return a primary key" >&2 + exit 1 +fi + +if [[ -n "$access_group" ]]; then + ensure_application_group_binding "$application_slug" "$access_group" +fi + +for _ in $(seq 1 30); do + if curl -fsS "${authentik_url}/application/o/${application_slug}/.well-known/openid-configuration" >/dev/null 2>&1; then + echo "Synced Authentik Grafana OIDC application ${application_slug} (${application_name})." + exit 0 + fi + sleep 2 +done + +echo "warning: Grafana OIDC issuer document for ${application_slug} was not immediately readable; keeping reconciled config." >&2 +echo "Synced Authentik Grafana OIDC application ${application_slug} (${application_name})." diff --git a/Scripts/check-brand-icon-lowres.sh b/Scripts/check-brand-icon-lowres.sh new file mode 100755 index 0000000..c9243a9 --- /dev/null +++ b/Scripts/check-brand-icon-lowres.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +cd "$repo_root" + +output_dir_arg="${1:-design/brand/low-res}" +if [[ "$output_dir_arg" = /* ]]; then + output_dir="$output_dir_arg" +else + output_dir="$repo_root/$output_dir_arg" +fi +master="$output_dir/burrow-icon-1024.png" +checked_in_master="$repo_root/design/brand/burrow-owl-icon-master.png" +source_master="$checked_in_master" +sizes=(16 20 24 29 32 40 48 64 80 128 256) + +require_tool() { + if ! command -v "$1" >/dev/null 2>&1; then + echo "error: required tool not found: $1" >&2 + exit 127 + fi +} + +require_tool magick +require_tool awk + +mkdir -p "$output_dir" + +magick "$checked_in_master" -colorspace sRGB -strip "PNG32:$master" + +printf "size,colors,gray_stddev,status\n" >"$output_dir/report.csv" + +for size in "${sizes[@]}"; do + image="$output_dir/burrow-icon-${size}.png" + magick "$source_master" -colorspace sRGB -resize "${size}x${size}!" -strip "PNG32:$image" + + actual="$(magick "$image" -format "%wx%h" info:)" + if [[ "$actual" != "${size}x${size}" ]]; then + echo "error: $image rendered as $actual, expected ${size}x${size}" >&2 + exit 1 + fi + + colors="$(magick "$image" -format "%k" info:)" + stddev="$(magick "$image" -colorspace Gray -format "%[fx:standard_deviation]" info:)" + min_colors=$((size * 4)) + if (( min_colors < 48 )); then + min_colors=48 + fi + if (( min_colors > 900 )); then + min_colors=900 + fi + + awk -v size="$size" -v colors="$colors" -v min_colors="$min_colors" -v stddev="$stddev" ' + BEGIN { + if (colors < min_colors) { + printf "error: %dpx icon has only %d colors; expected at least %d\n", size, colors, min_colors > "/dev/stderr"; + exit 1; + } + if (stddev < 0.08) { + printf "error: %dpx icon grayscale stddev is %.6f; expected at least 0.08\n", size, stddev > "/dev/stderr"; + exit 1; + } + } + ' + + printf "%s,%s,%s,ok\n" "$size" "$colors" "$stddev" >>"$output_dir/report.csv" +done + +preview_inputs=() +pixel_preview_inputs=() +for size in 256 128 80 64 48 40 32 29 24 20 16; do + preview="$output_dir/preview-${size}.png" + if (( size <= 32 )); then + filter=Point + else + filter=Lanczos + fi + magick "$output_dir/burrow-icon-${size}.png" -filter "$filter" -resize 128x128 "$preview" + preview_inputs+=("$preview") + + if (( size <= 32 )); then + pixel_preview="$output_dir/pixel-preview-${size}.png" + magick "$output_dir/burrow-icon-${size}.png" -filter Point -resize 128x128 "$pixel_preview" + pixel_preview_inputs+=("$pixel_preview") + fi +done + +magick -background "#202020" -gravity center "${preview_inputs[@]}" +append "$output_dir/preview-strip.png" +magick -background "#202020" -gravity center "${pixel_preview_inputs[@]}" +append "$output_dir/pixel-preview-strip.png" + +echo "low-res icon exports written to $output_dir" diff --git a/Scripts/check-forge-host.sh b/Scripts/check-forge-host.sh index 0f79bf4..e4ba995 100755 --- a/Scripts/check-forge-host.sh +++ b/Scripts/check-forge-host.sh @@ -75,6 +75,7 @@ set -euo pipefail base_services=( forgejo.service + grafana.service caddy.service burrow-forgejo-bootstrap.service burrow-forgejo-runner-bootstrap.service @@ -89,6 +90,7 @@ nsc_services=( tailnet_services=( burrow-authentik-runtime.service burrow-authentik-ready.service + burrow-authentik-grafana-oidc.service headscale.service headscale-bootstrap.service ) @@ -161,6 +163,8 @@ if [[ "${EXPECT_TAILNET}" == "1" ]]; then echo "== agenix ==" ls -l /run/agenix || true test -s /run/agenix/burrowAuthentikEnv + test -s /run/agenix/burrowGrafanaAdminPassword + test -s /run/agenix/burrowGrafanaOidcClientSecret test -s /run/agenix/burrowHeadscaleOidcClientSecret fi @@ -177,6 +181,7 @@ if command -v curl >/dev/null 2>&1; then curl -fsS -o /dev/null -w 'forgejo_login %{http_code}\n' http://127.0.0.1:3000/user/login curl -fsS -o /dev/null -H 'Host: burrow.net' -w 'burrow_root %{http_code}\n' http://127.0.0.1/ curl -fsS -o /dev/null -H 'Host: git.burrow.net' -w 'git_login %{http_code}\n' http://127.0.0.1/user/login + curl -fsS -o /dev/null -H 'Host: graphs.burrow.net' -w 'grafana_login %{http_code}\n' http://127.0.0.1/login if [[ "${EXPECT_TAILNET}" == "1" ]]; then curl -fsS -o /dev/null -H 'Host: auth.burrow.net' -w 'authentik_ready %{http_code}\n' http://127.0.0.1/-/health/ready/ curl -sS -o /dev/null -H 'Host: ts.burrow.net' -w 'headscale_root %{http_code}\n' http://127.0.0.1/ || true diff --git a/Scripts/ci/backup-garage-to-gcs.sh b/Scripts/ci/backup-garage-to-gcs.sh new file mode 100755 index 0000000..9bd95e5 --- /dev/null +++ b/Scripts/ci/backup-garage-to-gcs.sh @@ -0,0 +1,104 @@ +#!/usr/bin/env bash +set -euo pipefail + +: "${BURROW_GARAGE_ENDPOINT:?BURROW_GARAGE_ENDPOINT is required}" +: "${AWS_ACCESS_KEY_ID:?AWS_ACCESS_KEY_ID is required for Garage backup}" +: "${AWS_SECRET_ACCESS_KEY:?AWS_SECRET_ACCESS_KEY is required for Garage backup}" + +repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "${repo_root}" + +if ! command -v aws >/dev/null 2>&1; then + echo "aws CLI is required for Garage backup" >&2 + exit 127 +fi + +if ! command -v gcloud >/dev/null 2>&1; then + echo "gcloud is required for GCS backup" >&2 + exit 127 +fi + +if ! gcloud auth list --filter=status:ACTIVE --format='value(account)' | grep -q .; then + Scripts/ci/google-wif-auth.sh +fi + +export AWS_DEFAULT_REGION="${BURROW_GARAGE_REGION:-garage}" +export AWS_EC2_METADATA_DISABLED=true +export AWS_REQUEST_CHECKSUM_CALCULATION="${AWS_REQUEST_CHECKSUM_CALCULATION:-when_required}" +export AWS_RESPONSE_CHECKSUM_VALIDATION="${AWS_RESPONSE_CHECKSUM_VALIDATION:-when_required}" + +requested_releases=0 +requested_packages=0 +requested_nix_cache=0 +IFS=',' read -r -a requested_items <<< "${BURROW_GARAGE_BACKUP_SET:-all}" + +for raw_item in "${requested_items[@]}"; do + item="${raw_item//[[:space:]]/}" + case "$item" in + "" ) + ;; + all ) + requested_releases=1 + requested_packages=1 + requested_nix_cache=1 + ;; + release|releases ) + requested_releases=1 + ;; + package|packages ) + requested_packages=1 + ;; + attic|nix|nix-cache|nix_cache ) + requested_nix_cache=1 + ;; + * ) + echo "unknown Garage backup set item: $item" >&2 + exit 64 + ;; + esac +done + +if [[ "$requested_releases" == "0" && "$requested_packages" == "0" && "$requested_nix_cache" == "0" ]]; then + echo "no Garage backup buckets selected" >&2 + exit 1 +fi + +work_root="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/burrow-garage-backup" +rsync_flags=(--recursive) +if [[ "${BURROW_GARAGE_BACKUP_DELETE:-false}" == "true" ]]; then + rsync_flags+=(--delete-unmatched-destination-objects) +fi + +sync_bucket() { + local name="$1" + local garage_bucket="$2" + local gcs_bucket="$3" + local source_dir="${work_root}/${name}" + + rm -rf "$source_dir" + mkdir -p "$source_dir" + + aws --endpoint-url "$BURROW_GARAGE_ENDPOINT" s3 sync "s3://${garage_bucket}" "$source_dir" --no-progress + gcloud storage rsync "${rsync_flags[@]}" "$source_dir" "gs://${gcs_bucket}" +} + +if [[ "$requested_releases" == "1" ]]; then + sync_bucket \ + releases \ + "${BURROW_RELEASE_GARAGE_BUCKET:-burrow-releases}" \ + "${BURROW_RELEASE_GCS_BUCKET:-burrow-net-releases}" +fi + +if [[ "$requested_packages" == "1" ]]; then + sync_bucket \ + packages \ + "${BURROW_PACKAGE_GARAGE_BUCKET:-burrow-packages}" \ + "${BURROW_PACKAGE_GCS_BUCKET:-burrow-net-packages}" +fi + +if [[ "$requested_nix_cache" == "1" ]]; then + sync_bucket \ + nix-cache \ + "${BURROW_NIX_CACHE_GARAGE_BUCKET:-attic}" \ + "${BURROW_NIX_CACHE_GCS_BUCKET:-burrow-net-nix-cache}" +fi diff --git a/Scripts/ci/build-release-artifacts.sh b/Scripts/ci/build-release-artifacts.sh index 20b4c06..ca8bcb0 100755 --- a/Scripts/ci/build-release-artifacts.sh +++ b/Scripts/ci/build-release-artifacts.sh @@ -4,17 +4,8 @@ set -euo pipefail repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)" cd "${repo_root}" -release_ref="${RELEASE_REF:-manual-${GITHUB_SHA:-unknown}}" -target="x86_64-unknown-linux-gnu" -out_dir="${repo_root}/dist" -staging="${out_dir}/burrow-${release_ref}-${target}" +build_number="${BUILD_NUMBER:-${RELEASE_REF:-manual-${GITHUB_SHA:-unknown}}}" +export BUILD_NUMBER="$build_number" +export BURROW_RELEASE_OUT="${BURROW_RELEASE_OUT:-${repo_root}/dist/builds/${build_number}}" -mkdir -p "${staging}" - -cargo build --locked --release -p burrow --bin burrow -install -m 0755 target/release/burrow "${staging}/burrow" -cp README.md "${staging}/README.md" - -tarball="${out_dir}/burrow-${release_ref}-${target}.tar.gz" -tar -C "${out_dir}" -czf "${tarball}" "$(basename "${staging}")" -shasum -a 256 "${tarball}" > "${tarball}.sha256" +Scripts/ci/package-release-artifacts.sh "${1:-all}" diff --git a/Scripts/ci/check-release-config.sh b/Scripts/ci/check-release-config.sh new file mode 100755 index 0000000..17bc3e6 --- /dev/null +++ b/Scripts/ci/check-release-config.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +set -euo pipefail + +require_env() { + local name="$1" + if [[ -z "${!name:-}" ]]; then + echo "missing required environment variable: ${name}" >&2 + return 1 + fi +} + +require_file_or_env() { + local file_name="$1" + local env_name="$2" + if [[ -n "${!file_name:-}" && -f "${!file_name:-}" ]]; then + return 0 + fi + if [[ -n "${!env_name:-}" ]]; then + return 0 + fi + echo "missing required ${file_name} file or ${env_name} environment value" >&2 + return 1 +} + +case "${1:-all}" in + gcs) + require_env BURROW_GOOGLE_PROJECT_ID + require_env BURROW_GOOGLE_PROJECT_NUMBER + require_env BURROW_GOOGLE_WIF_POOL_ID + require_env BURROW_GOOGLE_WIF_PROVIDER_ID + require_env BURROW_GOOGLE_WIF_SERVICE_ACCOUNT + require_env BURROW_AUTHENTIK_WIF_ISSUER + require_env BURROW_AUTHENTIK_WIF_AUDIENCE + require_env BURROW_AUTHENTIK_WIF_CLIENT_ID + if [[ -z "${BURROW_AUTHENTIK_WIF_TOKEN:-}" && -z "${BURROW_AUTHENTIK_WIF_CLIENT_SECRET:-}" ]]; then + if [[ -z "${BURROW_AUTHENTIK_WIF_TOKEN_FILE:-}" || ! -f "${BURROW_AUTHENTIK_WIF_TOKEN_FILE:-}" ]]; then + echo "missing Authentik WIF token, token file, or client secret" >&2 + exit 1 + fi + fi + ;; + app-store) + require_env ASC_API_KEY_ID + require_env ASC_API_ISSUER_ID + require_file_or_env ASC_API_KEY_PATH ASC_API_KEY_BASE64 + ;; + apple-signing) + require_file_or_env APPLE_SIGNING_CERTIFICATE_PATH APPLE_SIGNING_CERTIFICATE_BASE64 + require_env APPLE_SIGNING_CERTIFICATE_PASSWORD + ;; + sparkle) + "$0" gcs + ;; + microsoft-store) + require_env MICROSOFT_TENANT_ID + require_env MICROSOFT_CLIENT_ID + require_env MICROSOFT_CLIENT_SECRET + ;; + all) + "$0" gcs + "$0" app-store + "$0" apple-signing + ;; + *) + echo "unknown release config group: $1" >&2 + exit 64 + ;; +esac diff --git a/Scripts/ci/distribute-testflight.sh b/Scripts/ci/distribute-testflight.sh new file mode 100755 index 0000000..7c09ee1 --- /dev/null +++ b/Scripts/ci/distribute-testflight.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash +set -euo pipefail + +Scripts/ci/check-release-config.sh app-store + +build_number="${BUILD_NUMBER:?BUILD_NUMBER is required}" +distribute_external="${TESTFLIGHT_DISTRIBUTE_EXTERNAL:-false}" +testflight_groups="${TESTFLIGHT_GROUPS:-}" +uses_non_exempt="${IOS_USES_NON_EXEMPT_ENCRYPTION:-false}" +wait_processing_timeout="${TESTFLIGHT_WAIT_PROCESSING_TIMEOUT_SECONDS:-7200}" + +if [[ -z "$distribute_external" ]]; then + distribute_external="false" +fi +case "$distribute_external" in + true|false) + ;; + *) + echo "::error ::TESTFLIGHT_DISTRIBUTE_EXTERNAL must be true or false." >&2 + exit 1 + ;; +esac +if [[ -z "$uses_non_exempt" ]]; then + uses_non_exempt="false" +fi +case "$uses_non_exempt" in + true|false) + ;; + *) + echo "::error ::IOS_USES_NON_EXEMPT_ENCRYPTION must be true or false." >&2 + exit 1 + ;; +esac +case "$wait_processing_timeout" in + ""|*[!0-9]*) + echo "::error ::TESTFLIGHT_WAIT_PROCESSING_TIMEOUT_SECONDS must be an integer number of seconds." >&2 + exit 1 + ;; +esac + +api_key_json="$(mktemp "${RUNNER_TEMP:-/tmp}/burrow-appstore-api-key.XXXXXX.json")" +key_file="$(mktemp "${RUNNER_TEMP:-/tmp}/burrow-appstore-key.XXXXXX.p8")" +cleanup() { + rm -f "$api_key_json" "$key_file" +} +trap cleanup EXIT + +if [[ -n "${ASC_API_KEY_PATH:-}" && -f "${ASC_API_KEY_PATH:-}" ]]; then + cp "$ASC_API_KEY_PATH" "$key_file" +else + printf '%s' "$ASC_API_KEY_BASE64" | base64 --decode > "$key_file" +fi + +KEY_FILE="$key_file" nix develop .#ci -c python3 -c 'import json, os, pathlib; print(json.dumps({"key_id": os.environ["ASC_API_KEY_ID"], "issuer_id": os.environ["ASC_API_ISSUER_ID"], "key": pathlib.Path(os.environ["KEY_FILE"]).read_text(), "duration": 1200, "in_house": False}))' > "$api_key_json" + +args=( + run pilot + "api_key_path:${api_key_json}" + "app_identifier:${BURROW_APPLE_BUNDLE_ID:-net.burrow.app}" + "app_platform:ios" + "distribute_only:true" + "build_number:${build_number}" + "wait_processing_interval:30" + "wait_processing_timeout_duration:${wait_processing_timeout}" + "distribute_external:${distribute_external}" + "uses_non_exempt_encryption:${uses_non_exempt}" +) + +if [[ "$distribute_external" == "true" ]]; then + if [[ -z "$testflight_groups" ]]; then + echo "::error ::TESTFLIGHT_GROUPS is required for external TestFlight distribution." >&2 + exit 1 + fi + args+=("groups:${testflight_groups}") +else + args+=( + "skip_submission:true" + "notify_external_testers:false" + ) + if [[ -n "$testflight_groups" ]]; then + echo "::warning ::Ignoring TESTFLIGHT_GROUPS for internal-only TestFlight distribution; App Store Connect manages internal tester group availability." >&2 + fi +fi + +nix run nixpkgs#fastlane -- "${args[@]}" diff --git a/Scripts/ci/ensure-nix.sh b/Scripts/ci/ensure-nix.sh index 14be895..05a56af 100755 --- a/Scripts/ci/ensure-nix.sh +++ b/Scripts/ci/ensure-nix.sh @@ -134,6 +134,14 @@ fi source_nix_profile || true export PATH="${HOME}/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/nix/var/nix/profiles/default/sbin:${PATH}" +if [[ -n "${GITHUB_PATH:-}" ]]; then + { + echo "${HOME}/.nix-profile/bin" + echo "/nix/var/nix/profiles/default/bin" + echo "/nix/var/nix/profiles/default/sbin" + } >> "${GITHUB_PATH}" +fi + config_root="${XDG_CONFIG_HOME:-$HOME/.config}" config_file="${config_root}/nix/nix.conf" if [[ -e "${config_file}" && ! -w "${config_file}" ]]; then @@ -143,13 +151,18 @@ if [[ -e "${config_file}" && ! -w "${config_file}" ]]; then fi mkdir -p "$(dirname -- "${config_file}")" -cat > "${config_file}" <<'EOF' -experimental-features = nix-command flakes -sandbox = true -fallback = true -substituters = https://cache.nixos.org -trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= -EOF +{ + echo "experimental-features = nix-command flakes" + echo "sandbox = true" + echo "fallback = true" + if [[ -n "${BURROW_NIX_CACHE_PUBLIC_KEY:-}" ]]; then + echo "substituters = ${BURROW_NIX_CACHE_URL:-https://nix.burrow.net/${BURROW_NIX_CACHE_NAME:-burrow}} https://cache.nixos.org" + echo "trusted-public-keys = ${BURROW_NIX_CACHE_PUBLIC_KEY} cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + else + echo "substituters = https://cache.nixos.org" + echo "trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + fi +} > "${config_file}" command -v nix >/dev/null 2>&1 || { echo "nix is still unavailable after bootstrap" >&2 diff --git a/Scripts/ci/ensure-nsc.sh b/Scripts/ci/ensure-nsc.sh new file mode 100755 index 0000000..87cd9d9 --- /dev/null +++ b/Scripts/ci/ensure-nsc.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +set -euo pipefail + +if command -v nsc >/dev/null 2>&1; then + nsc version || true + exit 0 +fi + +if ! command -v curl >/dev/null 2>&1; then + echo "::error ::curl is required to install nsc" >&2 + exit 1 +fi +if ! command -v tar >/dev/null 2>&1; then + echo "::error ::tar is required to install nsc" >&2 + exit 1 +fi + +os="$(uname -s | tr '[:upper:]' '[:lower:]')" +arch="$(uname -m)" +case "$arch" in + x86_64|amd64) arch="amd64" ;; + aarch64|arm64) arch="arm64" ;; + *) + echo "::error ::Unsupported arch for nsc: ${arch}" >&2 + exit 1 + ;; +esac + +if [[ "$os" != "linux" ]]; then + echo "::warning ::nsc bootstrap is only supported on Linux; relying on the runner or Nix shell for ${os}." + exit 1 +fi + +version="${NSC_VERSION:-0.0.520}" +expected_sha256="" +case "${version}/${arch}" in + 0.0.506/amd64) expected_sha256="4a093e0269878a9514e7c00d99b88a924f307ad15fb9d1595ee5f6582f99a0f0" ;; + 0.0.506/arm64) expected_sha256="6acf074b67fcbaaf59a4437f6bd40da7e38438c427849c1b5fcf4621ce75aee2" ;; +esac + +asset="nsc_${version}_linux_${arch}.tar.gz" +url="https://get.namespace.so/packages/nsc/v${version}/${asset}" +tmp_dir="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/burrow-nsc.$$" +install_dir="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/nsc-bin" +mkdir -p "$tmp_dir" "$install_dir" +trap 'rm -rf "$tmp_dir"' EXIT + +curl -fsSL -o "${tmp_dir}/${asset}" "$url" +if [[ -n "$expected_sha256" ]] && command -v sha256sum >/dev/null 2>&1; then + actual_sha256="$(sha256sum "${tmp_dir}/${asset}" | awk '{print $1}')" + if [[ "$actual_sha256" != "$expected_sha256" ]]; then + echo "::error ::nsc ${asset} sha256 mismatch: expected ${expected_sha256}, got ${actual_sha256}" >&2 + exit 1 + fi +fi + +tar -xzf "${tmp_dir}/${asset}" -C "$tmp_dir" +for bin in nsc bazel-credential-nsc docker-credential-nsc; do + if [[ -x "${tmp_dir}/${bin}" ]]; then + install -m 0755 "${tmp_dir}/${bin}" "${install_dir}/${bin}" + fi +done + +if [[ ! -x "${install_dir}/nsc" || ! -x "${install_dir}/bazel-credential-nsc" ]]; then + echo "::error ::Failed to install nsc and bazel-credential-nsc from ${asset}" >&2 + exit 1 +fi + +if [[ -n "${GITHUB_PATH:-}" ]]; then + echo "${install_dir}" >> "${GITHUB_PATH}" +fi +export PATH="${install_dir}:$PATH" +nsc version || true diff --git a/Scripts/ci/ensure-spacectl.sh b/Scripts/ci/ensure-spacectl.sh new file mode 100755 index 0000000..8216a94 --- /dev/null +++ b/Scripts/ci/ensure-spacectl.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +set -euo pipefail + +if command -v spacectl >/dev/null 2>&1; then + spacectl version || true + exit 0 +fi + +if ! command -v curl >/dev/null 2>&1; then + echo "::error ::curl is required to install spacectl" >&2 + exit 1 +fi +if ! command -v tar >/dev/null 2>&1; then + echo "::error ::tar is required to install spacectl" >&2 + exit 1 +fi + +os="$(uname -s | tr '[:upper:]' '[:lower:]')" +arch="$(uname -m)" +case "$arch" in + x86_64|amd64) arch="amd64" ;; + aarch64|arm64) arch="arm64" ;; + *) + echo "::error ::Unsupported arch for spacectl: ${arch}" >&2 + exit 1 + ;; +esac + +if [[ "$os" != "linux" && "$os" != "darwin" ]]; then + echo "::error ::Unsupported OS for spacectl: ${os}" >&2 + exit 1 +fi + +version="${SPACECTL_VERSION:-v0.5.0}" +version_num="${version#v}" +asset="spacectl_${version_num}_${os}_${arch}.tar.gz" +url="https://github.com/namespacelabs/spacectl/releases/download/${version}/${asset}" +tmp_dir="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/burrow-spacectl.$$" +install_dir="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/spacectl-bin" +mkdir -p "$tmp_dir" "$install_dir" +trap 'rm -rf "$tmp_dir"' EXIT + +curl -fsSL -o "${tmp_dir}/${asset}" "$url" +tar -xzf "${tmp_dir}/${asset}" -C "$tmp_dir" + +bin="${tmp_dir}/spacectl" +if [[ ! -x "$bin" ]]; then + bin="$(find "$tmp_dir" -maxdepth 3 -type f -name spacectl -perm -111 | head -n1 || true)" +fi +if [[ -z "${bin}" || ! -x "${bin}" ]]; then + echo "::error ::Failed to locate spacectl binary in ${asset}" >&2 + exit 1 +fi + +install -m 0755 "$bin" "${install_dir}/spacectl" +if [[ -n "${GITHUB_PATH:-}" ]]; then + echo "${install_dir}" >> "${GITHUB_PATH}" +fi +export PATH="${install_dir}:$PATH" +spacectl version || true diff --git a/Scripts/ci/google-wif-auth.sh b/Scripts/ci/google-wif-auth.sh new file mode 100755 index 0000000..c3eda3c --- /dev/null +++ b/Scripts/ci/google-wif-auth.sh @@ -0,0 +1,156 @@ +#!/usr/bin/env bash +set -euo pipefail + +project_id="${GOOGLE_CLOUD_PROJECT:-${BURROW_GOOGLE_PROJECT_ID:-project-88c23ce9-918a-470a-b33}}" +project_number="${BURROW_GOOGLE_PROJECT_NUMBER:-416198671487}" +pool_id="${BURROW_GOOGLE_WIF_POOL_ID:-burrow-authentik}" +provider_id="${BURROW_GOOGLE_WIF_PROVIDER_ID:-forgejo-runners}" +service_account="${BURROW_GOOGLE_WIF_SERVICE_ACCOUNT:-burrow-forgejo-runner@project-88c23ce9-918a-470a-b33.iam.gserviceaccount.com}" +authentik_issuer="${BURROW_AUTHENTIK_WIF_ISSUER:-https://auth.burrow.net/application/o/google-cloud/}" +authentik_token_endpoint="${BURROW_AUTHENTIK_WIF_TOKEN_ENDPOINT:-}" +authentik_audience="${BURROW_AUTHENTIK_WIF_AUDIENCE:-google-wif.burrow.net}" +authentik_client_id="${BURROW_AUTHENTIK_WIF_CLIENT_ID:-${AUTHENTIK_GOOGLE_WIF_CLIENT_ID:-google-wif.burrow.net}}" +authentik_client_secret="${BURROW_AUTHENTIK_WIF_CLIENT_SECRET:-${AUTHENTIK_GOOGLE_WIF_CLIENT_SECRET:-}}" +authentik_token_file="${BURROW_AUTHENTIK_WIF_TOKEN_FILE:-}" +authentik_token="${BURROW_AUTHENTIK_WIF_TOKEN:-}" +work_dir="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/burrow-google-wif" +emit_env=1 + +usage() { + cat <<'EOF' +Usage: Scripts/ci/google-wif-auth.sh [--no-emit-env] + +Authenticates gcloud to the Burrow Google project through Authentik-issued OIDC +and Google Workload Identity Federation. No Google service-account JSON key is +used or written. + +Inputs: + GOOGLE_CLOUD_PROJECT / BURROW_GOOGLE_PROJECT_ID + BURROW_GOOGLE_PROJECT_NUMBER + BURROW_GOOGLE_WIF_POOL_ID + BURROW_GOOGLE_WIF_PROVIDER_ID + BURROW_GOOGLE_WIF_SERVICE_ACCOUNT + BURROW_AUTHENTIK_WIF_ISSUER + BURROW_AUTHENTIK_WIF_TOKEN_ENDPOINT + BURROW_AUTHENTIK_WIF_AUDIENCE + BURROW_AUTHENTIK_WIF_TOKEN or BURROW_AUTHENTIK_WIF_TOKEN_FILE + +If no token is supplied, the script requests one from Authentik using +BURROW_AUTHENTIK_WIF_CLIENT_ID and BURROW_AUTHENTIK_WIF_CLIENT_SECRET. +EOF +} + +while [[ "$#" -gt 0 ]]; do + case "$1" in + --no-emit-env) + emit_env=0 + ;; + -h|--help) + usage + exit 0 + ;; + *) + echo "unknown argument: $1" >&2 + exit 64 + ;; + esac + shift +done + +require_command() { + if ! command -v "$1" >/dev/null 2>&1; then + echo "$1 is required for Google WIF authentication" >&2 + exit 127 + fi +} + +require_command gcloud +require_command curl +require_command jq + +resolve_token_endpoint() { + if [[ -n "$authentik_token_endpoint" ]]; then + printf '%s\n' "$authentik_token_endpoint" + return + fi + + local issuer_no_slash="${authentik_issuer%/}" + local discovered="" + if discovered="$( + curl -fsS "${issuer_no_slash}/.well-known/openid-configuration" 2>/dev/null \ + | jq -r '.token_endpoint // empty' 2>/dev/null + )" && [[ -n "$discovered" ]]; then + printf '%s\n' "$discovered" + return + fi + + case "$issuer_no_slash" in + */application/o/*) + printf '%s/application/o/token/\n' "${issuer_no_slash%%/application/o/*}" + ;; + *) + printf '%s/token/\n' "$issuer_no_slash" + ;; + esac +} + +mkdir -p "$work_dir" +chmod 0700 "$work_dir" + +token_path="$work_dir/authentik-oidc-token.jwt" +credential_config="$work_dir/google-wif-credentials.json" + +if [[ -n "$authentik_token_file" ]]; then + if [[ ! -s "$authentik_token_file" ]]; then + echo "Authentik WIF token file is empty or missing: $authentik_token_file" >&2 + exit 1 + fi + cp "$authentik_token_file" "$token_path" +elif [[ -n "$authentik_token" ]]; then + printf '%s' "$authentik_token" > "$token_path" +else + if [[ -z "$authentik_client_secret" ]]; then + echo "missing Authentik WIF token. Set BURROW_AUTHENTIK_WIF_TOKEN, BURROW_AUTHENTIK_WIF_TOKEN_FILE, or BURROW_AUTHENTIK_WIF_CLIENT_SECRET." >&2 + exit 1 + fi + token_endpoint="$(resolve_token_endpoint)" + curl -fsS \ + -d grant_type=client_credentials \ + -d client_id="$authentik_client_id" \ + -d client_secret="$authentik_client_secret" \ + -d scope="openid profile email groups" \ + -d audience="$authentik_audience" \ + "$token_endpoint" \ + | jq -r '.id_token // .access_token // empty' > "$token_path" +fi + +chmod 0600 "$token_path" +if [[ ! -s "$token_path" ]]; then + echo "Authentik did not return an OIDC token for Google WIF" >&2 + exit 1 +fi + +provider_resource="projects/${project_number}/locations/global/workloadIdentityPools/${pool_id}/providers/${provider_id}" +gcloud iam workload-identity-pools create-cred-config "$provider_resource" \ + --service-account "$service_account" \ + --subject-token-type="urn:ietf:params:oauth:token-type:jwt" \ + --credential-source-file "$token_path" \ + --output-file "$credential_config" + +chmod 0600 "$credential_config" +export CLOUDSDK_CORE_PROJECT="$project_id" +export GOOGLE_CLOUD_PROJECT="$project_id" +gcloud auth login --cred-file="$credential_config" --brief + +{ + echo "GOOGLE_APPLICATION_CREDENTIALS=$credential_config" + echo "CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=$credential_config" + echo "CLOUDSDK_CORE_PROJECT=$project_id" + echo "GOOGLE_CLOUD_PROJECT=$project_id" +} > "$work_dir/google-wif.env" + +if [[ "$emit_env" == "1" && -n "${GITHUB_ENV:-}" ]]; then + cat "$work_dir/google-wif.env" >> "$GITHUB_ENV" +fi + +echo "Authenticated gcloud through Authentik WIF as ${service_account} in ${project_id}." diff --git a/Scripts/ci/install-apple-signing-assets.sh b/Scripts/ci/install-apple-signing-assets.sh new file mode 100755 index 0000000..c5dc0a9 --- /dev/null +++ b/Scripts/ci/install-apple-signing-assets.sh @@ -0,0 +1,124 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "$repo_root" + +signing_ready=0 +keychain_path="" + +write_env() { + local key="$1" + local value="$2" + if [[ -n "${GITHUB_ENV:-}" ]]; then + echo "${key}=${value}" >> "$GITHUB_ENV" + fi +} + +install_profile_file() { + local source="$1" + [[ -f "$source" ]] || return 0 + + local uuid + uuid="$(security cms -D -i "$source" 2>/dev/null | plutil -extract UUID raw -o - - 2>/dev/null || true)" + if [[ -z "$uuid" ]]; then + uuid="$(basename "$source")" + fi + + local profiles_dir="$HOME/Library/MobileDevice/Provisioning Profiles" + mkdir -p "$profiles_dir" + cp "$source" "${profiles_dir}/${uuid}.provisionprofile" + echo "Installed provisioning profile ${uuid}." +} + +install_profile_base64() { + local name="$1" + local value="${!name:-}" + [[ -n "$value" ]] || return 0 + + local out="${RUNNER_TEMP:-/tmp}/${name}.provisionprofile" + printf '%s' "$value" | base64 --decode > "$out" + install_profile_file "$out" +} + +install_profile_env_path() { + local name="$1" + local path="${!name:-}" + [[ -n "$path" ]] || return 0 + if [[ ! -f "$path" ]]; then + echo "::error ::${name} points to a missing provisioning profile: ${path}" >&2 + exit 1 + fi + install_profile_file "$path" +} + +for profile in \ + Apple/Profiles/*.provisionprofile \ + Apple/Profiles/*.mobileprovision \ + .forgejo/actions/export/*.provisionprofile \ + .forgejo/actions/export/*.mobileprovision; do + [[ -e "$profile" ]] || continue + install_profile_file "$profile" +done +install_profile_env_path APPLE_PROVISIONING_PROFILE_PATH +install_profile_env_path APPLE_NETWORK_EXTENSION_PROVISIONING_PROFILE_PATH +install_profile_env_path APPLE_MACOS_PROVISIONING_PROFILE_PATH +install_profile_base64 APPLE_PROVISIONING_PROFILE_BASE64 +install_profile_base64 APPLE_NETWORK_EXTENSION_PROVISIONING_PROFILE_BASE64 +install_profile_base64 APPLE_MACOS_PROVISIONING_PROFILE_BASE64 + +cert_base64="${APPLE_SIGNING_CERTIFICATE_BASE64:-${APPLE_DISTRIBUTION_CERTIFICATE_BASE64:-}}" +cert_path_env="${APPLE_SIGNING_CERTIFICATE_PATH:-${APPLE_DISTRIBUTION_CERTIFICATE_PATH:-}}" +cert_password="${APPLE_SIGNING_CERTIFICATE_PASSWORD:-${APPLE_DISTRIBUTION_CERTIFICATE_PASSWORD:-}}" +keychain_password="${APPLE_KEYCHAIN_PASSWORD:-${cert_password}}" + +if [[ -n "$cert_base64" || -n "$cert_path_env" ]]; then + if [[ -z "$cert_password" ]]; then + echo "::error ::APPLE_SIGNING_CERTIFICATE_PASSWORD is required when Apple signing certificate material is set." >&2 + exit 1 + fi + + cert_path="${RUNNER_TEMP:-/tmp}/burrow-apple-signing.p12" + keychain_path="$HOME/Library/Keychains/BurrowRelease.keychain-db" + if [[ -n "$cert_path_env" ]]; then + if [[ ! -f "$cert_path_env" ]]; then + echo "::error ::APPLE_SIGNING_CERTIFICATE_PATH points to a missing file: ${cert_path_env}" >&2 + exit 1 + fi + cp "$cert_path_env" "$cert_path" + else + printf '%s' "$cert_base64" | base64 --decode > "$cert_path" + fi + + security create-keychain -p "$keychain_password" "$keychain_path" || true + security set-keychain-settings -lut 21600 "$keychain_path" + security unlock-keychain -p "$keychain_password" "$keychain_path" + security import "$cert_path" \ + -k "$keychain_path" \ + -P "$cert_password" \ + -T /usr/bin/codesign \ + -T /usr/bin/security \ + -T /usr/bin/productbuild \ + -T /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild + security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$keychain_password" "$keychain_path" >/dev/null + + existing="$(security list-keychains -d user | sed 's/[ "]//g' || true)" + if ! printf '%s\n' "$existing" | grep -Fxq "$keychain_path"; then + security list-keychains -d user -s "$keychain_path" $existing + fi + + signing_ready=1 + write_env BURROW_APPLE_KEYCHAIN_PATH "$keychain_path" +else + identities="$(security find-identity -v -p codesigning 2>/dev/null || true)" + if printf '%s\n' "$identities" | grep -Eq '"(Apple Distribution|Developer ID Application):'; then + signing_ready=1 + fi +fi + +write_env BURROW_APPLE_SIGNING_READY "$signing_ready" +if [[ "$signing_ready" == "1" ]]; then + echo "Apple signing assets are available." +else + echo "::notice ::Apple signing certificate is not configured; release lane will build unsigned validation artifacts only." +fi diff --git a/Scripts/ci/nscloud-cache.sh b/Scripts/ci/nscloud-cache.sh new file mode 100755 index 0000000..1f9ce09 --- /dev/null +++ b/Scripts/ci/nscloud-cache.sh @@ -0,0 +1,257 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [[ "$#" -eq 0 ]]; then + echo "No cache modes specified; skipping." + exit 0 +fi + +want_bazel_cache=0 +for mode in "$@"; do + if [[ "$mode" == "bazel" ]]; then + want_bazel_cache=1 + break + fi +done + +portable_mkdir() { + hash -r >/dev/null 2>&1 || true + command -p mkdir "$@" +} + +optional_timeout() { + local duration="$1" + shift + if command -v timeout >/dev/null 2>&1; then + timeout "$duration" "$@" + else + "$@" + fi +} + +append_bazel_storage_cache() { + local bazelrc_path="$1" + local cache_root="${BURROW_BAZEL_STORAGE_CACHE:-}" + if [[ -z "$cache_root" && -n "${NSC_CACHE_PATH:-}" ]]; then + cache_root="${NSC_CACHE_PATH}/bazel" + fi + if [[ -z "$cache_root" ]]; then + return 0 + fi + + portable_mkdir -p "${cache_root}/disk" "${cache_root}/repository" + { + echo "build --disk_cache=${cache_root}/disk" + echo "build --repository_cache=${cache_root}/repository" + } >> "$bazelrc_path" + echo "Namespace Bazel storage cache configured: ${cache_root}" +} + +configure_bazel_remote_cache() { + if [[ "$want_bazel_cache" != "1" ]]; then + return 0 + fi + + local bazelrc_path + bazelrc_path="${NSC_BAZELRC_PATH:-${TMPDIR:-/tmp}/burrow-nsc-cache.bazelrc}" + portable_mkdir -p "$(dirname "$bazelrc_path")" + + if [[ "$(uname -s 2>/dev/null || true)" == "Darwin" ]]; then + append_bazel_storage_cache "$bazelrc_path" + export BURROW_BAZEL_NSCCACHE_ACTIVE=0 + export BURROW_BAZEL_NSCCACHE_BAZELRC="$bazelrc_path" + echo "::warning ::Namespace Bazel remote cache probe skipped on macOS; using local Bazel repository/disk cache." + if [[ -n "${GITHUB_ENV:-}" ]]; then + echo "BURROW_BAZEL_NSCCACHE_ACTIVE=0" >> "$GITHUB_ENV" + echo "BURROW_BAZEL_NSCCACHE_BAZELRC=$bazelrc_path" >> "$GITHUB_ENV" + echo "NSC_BAZELRC_PATH=$bazelrc_path" >> "$GITHUB_ENV" + fi + return 0 + fi + + export BURROW_BAZEL_NSCCACHE_ACTIVE=0 + if ! command -v nsc >/dev/null 2>&1; then + if bash Scripts/ci/ensure-nsc.sh; then + nsc_bin_dir="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/nsc-bin" + if [[ -x "${nsc_bin_dir}/nsc" ]]; then + export PATH="${nsc_bin_dir}:$PATH" + fi + else + echo "::warning ::nsc not found; using local Bazel disk cache only." + if [[ -n "${GITHUB_ENV:-}" ]]; then + echo "BURROW_BAZEL_NSCCACHE_ACTIVE=0" >> "$GITHUB_ENV" + fi + return 0 + fi + fi + + local probe_timeout="${BURROW_NSC_CACHE_PROBE_TIMEOUT:-30s}" + if optional_timeout "$probe_timeout" nsc auth check-login >/dev/null 2>&1 && + optional_timeout "$probe_timeout" nsc cache bazel setup --bazelrc "$bazelrc_path" >/dev/null 2>&1; then + append_bazel_storage_cache "$bazelrc_path" + export BURROW_BAZEL_NSCCACHE_BAZELRC="$bazelrc_path" + export BURROW_BAZEL_NSCCACHE_ACTIVE=1 + echo "Namespace Bazel cache configured: $bazelrc_path" + if [[ -n "${GITHUB_ENV:-}" ]]; then + { + echo "BURROW_BAZEL_NSCCACHE_ACTIVE=1" + echo "BURROW_BAZEL_NSCCACHE_BAZELRC=$bazelrc_path" + echo "NSC_BAZELRC_PATH=$bazelrc_path" + } >> "$GITHUB_ENV" + fi + else + append_bazel_storage_cache "$bazelrc_path" + echo "::warning ::Namespace Bazel remote cache unavailable; using local Bazel repository/disk cache." + if [[ -n "${GITHUB_ENV:-}" ]]; then + echo "BURROW_BAZEL_NSCCACHE_ACTIVE=0" >> "$GITHUB_ENV" + echo "BURROW_BAZEL_NSCCACHE_BAZELRC=$bazelrc_path" >> "$GITHUB_ENV" + echo "NSC_BAZELRC_PATH=$bazelrc_path" >> "$GITHUB_ENV" + fi + fi +} + +cache_root="${NSC_CACHE_PATH:-}" +if [[ -z "$cache_root" ]]; then + ensure_dir() { + local dir="$1" + if portable_mkdir -p "$dir" 2>/dev/null; then + return 0 + fi + if [[ "$(id -u)" != "0" ]] && command -v sudo >/dev/null 2>&1 && sudo -n true >/dev/null 2>&1; then + sudo mkdir -p "$dir" >/dev/null 2>&1 || return 1 + return 0 + fi + return 1 + } + + if [[ "$(uname -s 2>/dev/null || true)" == "Linux" ]]; then + tmp_root="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/burrow-nscloud-cache" + for candidate in "/cache/nscloud" "$tmp_root" "$PWD/.nscloud-cache"; do + if ensure_dir "$candidate"; then + cache_root="$candidate" + break + fi + done + else + tmp_root="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/burrow-nscloud-cache" + for candidate in "$tmp_root" "$PWD/.nscloud-cache"; do + if ensure_dir "$candidate"; then + cache_root="$candidate" + break + fi + done + fi +fi + +if [[ -z "$cache_root" ]]; then + echo "NSCloud cache volume not configured (NSC_CACHE_PATH missing); skipping." + configure_bazel_remote_cache + exit 0 +fi + +export NSC_CACHE_PATH="$cache_root" +if [[ -n "${GITHUB_ENV:-}" ]]; then + echo "NSC_CACHE_PATH=$cache_root" >> "$GITHUB_ENV" +fi + +mode_args=() +for mode in "$@"; do + [[ -z "$mode" ]] && continue + if [[ "$mode" == "bazel" ]]; then + continue + fi + if [[ "$mode" == "nix" && "${BURROW_NSC_DIRECT_NIX_VOLUME:-0}" == "1" ]]; then + echo "Namespace Nix cache volume is mounted directly at /nix; skipping spacectl nix mount." + continue + fi + if [[ "$mode" == "nix" && "$(uname -s)" == "Darwin" ]]; then + echo "Skipping late Nix cache mount on macOS; using existing Nix profile and Bazel cache." + continue + fi + mode_args+=("--mode=${mode}") +done + +if [[ "${#mode_args[@]}" -eq 0 ]]; then + echo "No filesystem cache modes require mounting; skipping spacectl cache mount." + configure_bazel_remote_cache + exit 0 +fi + +spacectl_bin_dir="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/spacectl-bin" +if ! command -v spacectl >/dev/null 2>&1; then + if ! bash Scripts/ci/ensure-spacectl.sh; then + echo "::warning ::Unable to install spacectl; skipping filesystem cache mount." + configure_bazel_remote_cache + exit 0 + fi + if [[ -x "${spacectl_bin_dir}/spacectl" ]]; then + export PATH="${spacectl_bin_dir}:$PATH" + fi +fi + +portable_mkdir -p "$cache_root" 2>/dev/null || true + +args=(-o json cache mount "--dry_run=false" "--cache_root=${cache_root}" "${mode_args[@]}") +echo "Mounting NSCloud cache: spacectl ${args[*]//${cache_root}/}" + +spacectl_bin="$(command -v spacectl)" +run_mount=("$spacectl_bin" "${args[@]}") +if [[ "$(id -u)" != "0" ]]; then + if ! command -v sudo >/dev/null 2>&1 || ! sudo -n true >/dev/null 2>&1; then + echo "::warning ::spacectl cache mount requires passwordless sudo; skipping filesystem cache." + configure_bazel_remote_cache + exit 0 + fi + run_mount=(sudo -n env "PATH=$PATH" "$spacectl_bin" "${args[@]}") +fi + +tmp_err="$(mktemp "${TMPDIR:-/tmp}/spacectl.XXXXXX")" +cleanup() { + rm -f "$tmp_err" +} +trap cleanup EXIT + +json="" +if ! json="$("${run_mount[@]}" 2>"$tmp_err")"; then + echo "::warning ::spacectl cache mount failed; skipping filesystem cache." + if [[ -n "$json" ]]; then + printf '%s\n' "$json" || true + fi + if [[ -s "$tmp_err" ]]; then + sed -n '1,200p' "$tmp_err" || true + fi + configure_bazel_remote_cache + exit 0 +fi + +if command -v python3 >/dev/null 2>&1; then + NSC_MOUNT_JSON="$json" python3 - <<'PY' +import json +import os +import sys + +raw = os.environ.get("NSC_MOUNT_JSON", "").strip() +if not raw: + sys.exit(0) + +try: + payload = json.loads(raw) +except Exception as exc: + print(f"::warning ::Unable to parse spacectl JSON output; skipping cache env export: {exc}") + sys.exit(0) + +if payload.get("error"): + print(f"::warning ::spacectl cache mount skipped: {payload.get('message') or 'error=true'}") + sys.exit(0) + +add_envs = (payload.get("output") or {}).get("add_envs") or {} +gh_env = os.environ.get("GITHUB_ENV") +if gh_env and isinstance(add_envs, dict): + with open(gh_env, "a", encoding="utf-8") as f: + for key, value in add_envs.items(): + if key and value is not None: + f.write(f"{key}={value}\n") +PY +fi + +configure_bazel_remote_cache diff --git a/Scripts/ci/package-apple-artifacts.sh b/Scripts/ci/package-apple-artifacts.sh new file mode 100755 index 0000000..c910f0d --- /dev/null +++ b/Scripts/ci/package-apple-artifacts.sh @@ -0,0 +1,592 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "$repo_root" + +platform="${1:-all}" +build_number="${BUILD_NUMBER:-${RELEASE_BUILD_NUMBER:-${RELEASE_REF:-manual}}}" +out_root="${BURROW_RELEASE_OUT:-${repo_root}/dist/builds/${build_number}}" +apple_root="${out_root}/apple" +archives_root="${apple_root}/archives" +derived_data="${BURROW_DERIVED_DATA_PATH:-${repo_root}/.derived-data/apple}" +source_packages="${BURROW_SWIFTPM_CACHE_PATH:-${XDG_CACHE_HOME:-${HOME}/.cache}/burrow/swiftpm}" +project="Apple/Burrow.xcodeproj" +scheme="${BURROW_APPLE_SCHEME:-App}" +bundle_id="${BURROW_APPLE_BUNDLE_ID:-net.burrow.app}" +network_extension_bundle_id="${BURROW_APPLE_NETWORK_EXTENSION_BUNDLE_ID:-${bundle_id}.network}" +signing_ready="${BURROW_APPLE_SIGNING_READY:-0}" +signing_mode="${BURROW_APPLE_SIGNING_MODE:-keychain}" +require_signing="${BURROW_APPLE_REQUIRE_SIGNING:-false}" +sparkle_feed_url="${BURROW_SPARKLE_FEED_URL:-https://releases.burrow.net/sparkle/appcast.xml}" +sparkle_public_ed_key="${BURROW_SPARKLE_PUBLIC_ED_KEY:-uugZuJeqvvKd91NZ6F1Fv2cQenUbIG/ZW3L9MuaEz30=}" +sparkle_sign_with_kms="${BURROW_SPARKLE_SIGN_WITH_KMS:-false}" +notarize_macos="${BURROW_NOTARIZE_MACOS:-false}" + +mkdir -p "$apple_root" "$archives_root" "$derived_data" "$source_packages" + +truthy() { + case "${1:-}" in + 1|true|TRUE|True|yes|YES|Yes|y|Y|on|ON|On) return 0 ;; + *) return 1 ;; + esac +} + +sha256_file() { + local file="$1" + if command -v shasum >/dev/null 2>&1; then + shasum -a 256 "$file" > "${file}.sha256" + else + sha256sum "$file" > "${file}.sha256" + fi +} + +safe_profile_slug() { + python3 - "$1" <<'PY' +import re +import sys + +print(re.sub(r"[^A-Za-z0-9]", "", sys.argv[1]).lower()) +PY +} + +profile_for() { + local identifier="$1" + local suffix="$2" + local slug path + slug="$(safe_profile_slug "$identifier")" + for path in \ + ".forgejo/actions/export/${slug}${suffix}.provisionprofile" \ + ".forgejo/actions/export/${slug}${suffix}.mobileprovision" \ + "Apple/Profiles/${slug}${suffix}.provisionprofile" \ + "Apple/Profiles/${slug}${suffix}.mobileprovision"; do + if [[ -s "$path" ]]; then + printf '%s\n' "$path" + return 0 + fi + done + return 1 +} + +generate_entitlements_from_profile() { + local profile="$1" + local output="$2" + local template="${3:-}" + local args=("$profile" --output "$output") + if [[ -n "$template" ]]; then + args+=(--template "$template") + fi + Scripts/apple/profile-entitlements.py "${args[@]}" +} + +apple_signing_available() { + if [[ "$signing_mode" == "google-kms" || "$signing_mode" == "google-kms-staged" || "$signing_mode" == "kms" ]]; then + return 0 + fi + [[ "$signing_ready" == "1" ]] +} + +kms_sign_bundle() { + local family="$1" + local bundle_path="$2" + local entitlements="$3" + local runtime_flag=() + if [[ "$family" == "developer-id" ]]; then + runtime_flag=(--runtime) + fi + Scripts/apple/sign-with-google-kms.sh \ + --family "$family" \ + --path "$bundle_path" \ + --entitlements "$entitlements" \ + "${runtime_flag[@]}" +} + +kms_sign_file() { + local family="$1" + local file_path="$2" + local runtime_flag=() + if [[ "$family" == "developer-id" ]]; then + runtime_flag=(--runtime) + fi + Scripts/apple/sign-with-google-kms.sh \ + --family "$family" \ + --path "$file_path" \ + "${runtime_flag[@]}" +} + +write_version() { + mkdir -p Apple/Configuration + printf 'CURRENT_PROJECT_VERSION = %s\n' "$build_number" > Apple/Configuration/Version.xcconfig +} + +xcode_common_args=( + -project "$project" + -scheme "$scheme" + -configuration Release + -derivedDataPath "$derived_data" + -clonedSourcePackagesDirPath "$source_packages" + CURRENT_PROJECT_VERSION="$build_number" + APP_BUNDLE_IDENTIFIER="$bundle_id" + NETWORK_EXTENSION_BUNDLE_IDENTIFIER="$network_extension_bundle_id" + BURROW_SPARKLE_FEED_URL="$sparkle_feed_url" + BURROW_SPARKLE_PUBLIC_ED_KEY="$sparkle_public_ed_key" +) + +xcode_auth_args=() +if [[ -n "${ASC_API_KEY_ID:-}" && -n "${ASC_API_ISSUER_ID:-}" && -n "${ASC_API_KEY_PATH:-}" && -f "${ASC_API_KEY_PATH:-}" ]]; then + xcode_auth_args+=( + -authenticationKeyID "$ASC_API_KEY_ID" + -authenticationKeyIssuerID "$ASC_API_ISSUER_ID" + -authenticationKeyPath "$ASC_API_KEY_PATH" + ) +fi + +if [[ -n "${BURROW_APPLE_KEYCHAIN_PATH:-}" ]]; then + xcode_common_args+=(OTHER_CODE_SIGN_FLAGS="--keychain ${BURROW_APPLE_KEYCHAIN_PATH}") +fi + +require_xcodebuild() { + if ! command -v xcodebuild >/dev/null 2>&1; then + echo "xcodebuild is required for Apple release artifacts" >&2 + exit 1 + fi + xcodebuild -version + xcrun --find swiftc >/dev/null +} + +unsigned_note() { + local platform_name="$1" + local artifact_name="$2" + { + echo "Burrow ${platform_name} signing assets were not available." + echo + echo "The lane built an unsigned validation artifact instead of an uploadable release artifact." + echo "Seal the Apple release credentials with agenix and let CI sync provisioning profiles from App Store Connect to produce ${artifact_name}." + } > "${apple_root}/README-${platform_name}-unsigned.txt" +} + +ensure_signing_or_note() { + local platform_name="$1" + local artifact_name="$2" + if apple_signing_available; then + return 0 + fi + if truthy "$require_signing"; then + echo "Apple signing is required for ${platform_name}, but signing assets are not configured." >&2 + exit 1 + fi + unsigned_note "$platform_name" "$artifact_name" + return 1 +} + +write_export_options() { + local method="$1" + local path="$2" + cat > "$path" < + + + + method + ${method} + destination + export + signingStyle + automatic + stripSwiftSymbols + + teamID + ${DEVELOPMENT_TEAM:-P6PV2R9443} + + +EOF +} + +build_ios_unsigned() { + local product_dir zip_path + xcodebuild build \ + "${xcode_common_args[@]}" \ + -destination "generic/platform=iOS Simulator" \ + ARCHS=arm64 \ + ONLY_ACTIVE_ARCH=YES \ + CODE_SIGNING_ALLOWED=NO \ + CODE_SIGNING_REQUIRED=NO + + product_dir="${derived_data}/Build/Products/Release-iphonesimulator" + zip_path="${apple_root}/Burrow-iOS-simulator-${build_number}.unsigned.zip" + if [[ -d "${product_dir}/Burrow.app" ]]; then + (cd "$product_dir" && zip -qr "$zip_path" Burrow.app) + sha256_file "$zip_path" + fi +} + +build_ios_release() { + local archive_path export_dir export_options ipa + if ! ensure_signing_or_note "iOS" "Burrow-iOS-${build_number}.ipa"; then + build_ios_unsigned + return 0 + fi + if [[ "$signing_mode" == "google-kms-staged" ]]; then + build_ios_kms_staged + return 0 + fi + if [[ "$signing_mode" == "google-kms" || "$signing_mode" == "kms" ]]; then + build_ios_kms_release + return 0 + fi + + archive_path="${archives_root}/Burrow-iOS-${build_number}.xcarchive" + export_dir="${apple_root}/ios-export" + export_options="${apple_root}/ExportOptions-iOS.plist" + write_export_options "app-store-connect" "$export_options" + + xcodebuild archive \ + "${xcode_common_args[@]}" \ + -destination "generic/platform=iOS" \ + -archivePath "$archive_path" \ + ARCHS=arm64 \ + -allowProvisioningUpdates \ + "${xcode_auth_args[@]}" + + xcodebuild -exportArchive \ + -archivePath "$archive_path" \ + -exportPath "$export_dir" \ + -exportOptionsPlist "$export_options" \ + -allowProvisioningUpdates \ + "${xcode_auth_args[@]}" + + ipa="$(find "$export_dir" -maxdepth 1 -type f -name '*.ipa' | sort | head -n 1 || true)" + if [[ -z "$ipa" ]]; then + echo "iOS export completed but did not produce an IPA" >&2 + exit 1 + fi + cp "$ipa" "${apple_root}/Burrow-iOS-${build_number}.ipa" + sha256_file "${apple_root}/Burrow-iOS-${build_number}.ipa" +} + +build_ios_kms_staged() { + local product_dir source_app stage_dir ipa + xcodebuild build \ + "${xcode_common_args[@]}" \ + -destination "generic/platform=iOS" \ + ARCHS=arm64 \ + ONLY_ACTIVE_ARCH=YES \ + SKIP_INSTALL=NO \ + CODE_SIGNING_ALLOWED=NO \ + CODE_SIGNING_REQUIRED=NO \ + CODE_SIGN_IDENTITY= + + product_dir="${derived_data}/Build/Products/Release-iphoneos" + source_app="${product_dir}/Burrow.app" + if [[ ! -d "$source_app" ]]; then + echo "iOS build completed but did not produce Burrow.app" >&2 + exit 1 + fi + + stage_dir="${apple_root}/ios-unsigned/Payload" + rm -rf "$stage_dir" + mkdir -p "$stage_dir" + ditto "$source_app" "${stage_dir}/Burrow.app" + ipa="${apple_root}/Burrow-iOS-${build_number}.unsigned.ipa" + rm -f "$ipa" + (cd "${apple_root}/ios-unsigned" && zip -qry "$ipa" Payload) + sha256_file "$ipa" +} + +build_ios_kms_release() { + local product_dir source_app stage_dir app ext app_profile ext_profile app_entitlements ext_entitlements ipa + xcodebuild build \ + "${xcode_common_args[@]}" \ + -destination "generic/platform=iOS" \ + ARCHS=arm64 \ + ONLY_ACTIVE_ARCH=YES \ + SKIP_INSTALL=NO \ + CODE_SIGNING_ALLOWED=NO \ + CODE_SIGNING_REQUIRED=NO \ + CODE_SIGN_IDENTITY= + + product_dir="${derived_data}/Build/Products/Release-iphoneos" + source_app="${product_dir}/Burrow.app" + if [[ ! -d "$source_app" ]]; then + echo "iOS build completed but did not produce Burrow.app" >&2 + exit 1 + fi + + stage_dir="${apple_root}/ios-kms/Payload" + rm -rf "$stage_dir" + mkdir -p "$stage_dir" + ditto "$source_app" "${stage_dir}/Burrow.app" + app="${stage_dir}/Burrow.app" + ext="${app}/PlugIns/BurrowNetworkExtension.appex" + if [[ ! -d "$ext" ]]; then + echo "iOS app is missing BurrowNetworkExtension.appex" >&2 + exit 1 + fi + + app_profile="$(profile_for "$bundle_id" "appstore")" || { + echo "missing iOS App Store provisioning profile for ${bundle_id}" >&2 + exit 1 + } + ext_profile="$(profile_for "$network_extension_bundle_id" "appstore")" || { + echo "missing iOS App Store provisioning profile for ${network_extension_bundle_id}" >&2 + exit 1 + } + cp "$app_profile" "${app}/embedded.mobileprovision" + cp "$ext_profile" "${ext}/embedded.mobileprovision" + + app_entitlements="${apple_root}/ios-kms/app-entitlements.plist" + ext_entitlements="${apple_root}/ios-kms/extension-entitlements.plist" + generate_entitlements_from_profile "$app_profile" "$app_entitlements" Apple/App/App-iOS.entitlements + generate_entitlements_from_profile "$ext_profile" "$ext_entitlements" Apple/NetworkExtension/NetworkExtension-iOS.entitlements + + rm -rf "${app}/_CodeSignature" "${ext}/_CodeSignature" + kms_sign_bundle ios "$ext" "$ext_entitlements" + kms_sign_bundle ios "$app" "$app_entitlements" + + ipa="${apple_root}/Burrow-iOS-${build_number}.ipa" + rm -f "$ipa" + (cd "${apple_root}/ios-kms" && zip -qry "$ipa" Payload) + sha256_file "$ipa" +} + +build_macos_unsigned() { + local product_dir zip_path + xcodebuild build \ + "${xcode_common_args[@]}" \ + -destination "platform=macOS" \ + CODE_SIGNING_ALLOWED=NO \ + CODE_SIGNING_REQUIRED=NO + + product_dir="${derived_data}/Build/Products/Release" + zip_path="${apple_root}/Burrow-macOS-${build_number}.unsigned.zip" + if [[ -d "${product_dir}/Burrow.app" ]]; then + ditto -c -k --keepParent "${product_dir}/Burrow.app" "$zip_path" + sha256_file "$zip_path" + fi +} + +build_macos_release() { + local archive_path export_dir export_options app dmg channel sparkle_dir length pubdate url + if ! ensure_signing_or_note "macOS" "Burrow-macOS-${build_number}.dmg"; then + build_macos_unsigned + return 0 + fi + if [[ "$signing_mode" == "google-kms-staged" ]]; then + build_macos_kms_staged + return 0 + fi + if [[ "$signing_mode" == "google-kms" || "$signing_mode" == "kms" ]]; then + build_macos_kms_release + return 0 + fi + + archive_path="${archives_root}/Burrow-macOS-${build_number}.xcarchive" + export_dir="${apple_root}/macos-export" + export_options="${apple_root}/ExportOptions-macOS.plist" + write_export_options "${BURROW_MACOS_EXPORT_METHOD:-developer-id}" "$export_options" + + xcodebuild archive \ + "${xcode_common_args[@]}" \ + -destination "generic/platform=macOS" \ + -archivePath "$archive_path" \ + -allowProvisioningUpdates \ + "${xcode_auth_args[@]}" + + xcodebuild -exportArchive \ + -archivePath "$archive_path" \ + -exportPath "$export_dir" \ + -exportOptionsPlist "$export_options" \ + -allowProvisioningUpdates \ + "${xcode_auth_args[@]}" + + app="$(find "$export_dir" -maxdepth 2 -type d -name 'Burrow.app' | sort | head -n 1 || true)" + if [[ -z "$app" ]]; then + echo "macOS export completed but did not produce Burrow.app" >&2 + exit 1 + fi + + dmg="${apple_root}/Burrow-macOS-${build_number}.dmg" + rm -f "$dmg" + hdiutil create -volname "Burrow ${build_number}" -srcfolder "$app" -ov -format UDZO "$dmg" + sha256_file "$dmg" + + channel="${SPARKLE_CHANNEL:-build-${build_number}}" + sparkle_dir="${out_root}/sparkle/${channel}" + mkdir -p "$sparkle_dir" + cp "$dmg" "$sparkle_dir/" + length="$(wc -c < "$dmg" | tr -d ' ')" + pubdate="$(LC_ALL=C date -u '+%a, %d %b %Y %H:%M:%S +0000')" + url="${SPARKLE_DOWNLOAD_PREFIX:-https://releases.burrow.net/sparkle}/${channel}/$(basename "$dmg")" + cat > "${sparkle_dir}/appcast.xml" < + + + Burrow ${channel} + + Burrow ${build_number} + ${pubdate} + ${build_number} + 0.1 + + + + +EOF + + if truthy "$sparkle_sign_with_kms"; then + Scripts/sparkle/sign-appcast-kms.py \ + --appcast "${sparkle_dir}/appcast.xml" \ + --artifact-dir "$sparkle_dir" + fi +} + +build_macos_kms_staged() { + local product_dir source_app zip_path + xcodebuild build \ + "${xcode_common_args[@]}" \ + -destination "platform=macOS" \ + CODE_SIGNING_ALLOWED=NO \ + CODE_SIGNING_REQUIRED=NO \ + CODE_SIGN_IDENTITY= + + product_dir="${derived_data}/Build/Products/Release" + source_app="${product_dir}/Burrow.app" + if [[ ! -d "$source_app" ]]; then + echo "macOS build completed but did not produce Burrow.app" >&2 + exit 1 + fi + + zip_path="${apple_root}/Burrow-macOS-${build_number}.unsigned.zip" + rm -f "$zip_path" + ditto -c -k --keepParent "$source_app" "$zip_path" + sha256_file "$zip_path" +} + +write_sparkle_appcast() { + local dmg="$1" + local channel sparkle_dir length pubdate url + channel="${SPARKLE_CHANNEL:-build-${build_number}}" + sparkle_dir="${out_root}/sparkle/${channel}" + mkdir -p "$sparkle_dir" + cp "$dmg" "$sparkle_dir/" + length="$(wc -c < "$dmg" | tr -d ' ')" + pubdate="$(LC_ALL=C date -u '+%a, %d %b %Y %H:%M:%S +0000')" + url="${SPARKLE_DOWNLOAD_PREFIX:-https://releases.burrow.net/sparkle}/${channel}/$(basename "$dmg")" + cat > "${sparkle_dir}/appcast.xml" < + + + Burrow ${channel} + + Burrow ${build_number} + ${pubdate} + ${build_number} + 0.1 + + + + +EOF + + if truthy "$sparkle_sign_with_kms"; then + Scripts/sparkle/sign-appcast-kms.py \ + --appcast "${sparkle_dir}/appcast.xml" \ + --artifact-dir "$sparkle_dir" + fi +} + +notarize_dmg_if_requested() { + local dmg="$1" + local key_json + if ! truthy "$notarize_macos"; then + return 0 + fi + if [[ -z "${ASC_API_KEY_ID:-}" || -z "${ASC_API_ISSUER_ID:-}" || -z "${ASC_API_KEY_PATH:-}" ]]; then + echo "macOS notarization requires ASC_API_KEY_ID, ASC_API_ISSUER_ID, and ASC_API_KEY_PATH" >&2 + exit 1 + fi + key_json="${apple_root}/notary-api-key.json" + rcodesign encode-app-store-connect-api-key \ + --output-path "$key_json" \ + "$ASC_API_ISSUER_ID" \ + "$ASC_API_KEY_ID" \ + "$ASC_API_KEY_PATH" + rcodesign notary-submit --api-key-file "$key_json" --wait --staple "$dmg" + rm -f "$key_json" +} + +build_macos_kms_release() { + local product_dir source_app app ext app_profile ext_profile app_entitlements ext_entitlements dmg + xcodebuild build \ + "${xcode_common_args[@]}" \ + -destination "platform=macOS" \ + CODE_SIGNING_ALLOWED=NO \ + CODE_SIGNING_REQUIRED=NO \ + CODE_SIGN_IDENTITY= + + product_dir="${derived_data}/Build/Products/Release" + source_app="${product_dir}/Burrow.app" + if [[ ! -d "$source_app" ]]; then + echo "macOS build completed but did not produce Burrow.app" >&2 + exit 1 + fi + + app="${apple_root}/macos-kms/Burrow.app" + rm -rf "$app" + mkdir -p "$(dirname "$app")" + ditto "$source_app" "$app" + ext="${app}/Contents/PlugIns/BurrowNetworkExtension.appex" + + app_profile="$(profile_for "$bundle_id" "developerid")" || { + echo "missing macOS Developer ID provisioning profile for ${bundle_id}" >&2 + exit 1 + } + cp "$app_profile" "${app}/Contents/embedded.provisionprofile" + app_entitlements="${apple_root}/macos-kms/app-entitlements.plist" + generate_entitlements_from_profile "$app_profile" "$app_entitlements" + + if [[ -d "$ext" ]]; then + ext_profile="$(profile_for "$network_extension_bundle_id" "developerid")" || { + echo "missing macOS Developer ID provisioning profile for ${network_extension_bundle_id}" >&2 + exit 1 + } + cp "$ext_profile" "${ext}/Contents/embedded.provisionprofile" + ext_entitlements="${apple_root}/macos-kms/extension-entitlements.plist" + generate_entitlements_from_profile "$ext_profile" "$ext_entitlements" + rm -rf "${ext}/Contents/_CodeSignature" + kms_sign_bundle developer-id "$ext" "$ext_entitlements" + fi + + rm -rf "${app}/Contents/_CodeSignature" + kms_sign_bundle developer-id "$app" "$app_entitlements" + + dmg="${apple_root}/Burrow-macOS-${build_number}.dmg" + rm -f "$dmg" + hdiutil create -volname "Burrow ${build_number}" -srcfolder "$app" -ov -format UDZO "$dmg" + kms_sign_file developer-id "$dmg" + notarize_dmg_if_requested "$dmg" + sha256_file "$dmg" + write_sparkle_appcast "$dmg" +} + +require_xcodebuild +write_version + +case "$platform" in + all) + build_ios_release + build_macos_release + ;; + ios) + build_ios_release + ;; + macos) + build_macos_release + ;; + *) + echo "unknown Apple release platform: $platform" >&2 + exit 64 + ;; +esac + +find "$out_root" -type f -print | sort diff --git a/Scripts/ci/package-release-artifacts.sh b/Scripts/ci/package-release-artifacts.sh new file mode 100755 index 0000000..4ee85ee --- /dev/null +++ b/Scripts/ci/package-release-artifacts.sh @@ -0,0 +1,332 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "${repo_root}" + +platform="${1:-all}" +build_number="${BUILD_NUMBER:-${RELEASE_BUILD_NUMBER:-${RELEASE_REF:-manual}}}" +out_root="${BURROW_RELEASE_OUT:-${repo_root}/dist/builds/${build_number}}" + +mkdir -p "${out_root}" + +sha256_file() { + local file="$1" + if command -v shasum >/dev/null 2>&1; then + shasum -a 256 "$file" > "${file}.sha256" + else + sha256sum "$file" > "${file}.sha256" + fi +} + +burrow_crate_version() { + awk -F '"' '/^version = / { print $2; exit }' burrow/Cargo.toml +} + +package_release_suffix() { + printf '%s' "$build_number" | tr -c 'A-Za-z0-9.+~' '.' +} + +arch_package_suffix() { + printf '%s' "$build_number" | tr -c 'A-Za-z0-9.+_' '.' +} + +deb_arch_for_target() { + case "$1" in + x86_64-unknown-linux-gnu) printf 'amd64' ;; + aarch64-unknown-linux-gnu) printf 'arm64' ;; + riscv64gc-unknown-linux-gnu) printf 'riscv64' ;; + *) return 1 ;; + esac +} + +rpm_arch_for_target() { + case "$1" in + x86_64-unknown-linux-gnu) printf 'x86_64' ;; + aarch64-unknown-linux-gnu) printf 'aarch64' ;; + riscv64gc-unknown-linux-gnu) printf 'riscv64' ;; + *) return 1 ;; + esac +} + +pacman_arch_for_target() { + case "$1" in + x86_64-unknown-linux-gnu) printf 'x86_64' ;; + aarch64-unknown-linux-gnu) printf 'aarch64' ;; + riscv64gc-unknown-linux-gnu) printf 'riscv64' ;; + *) return 1 ;; + esac +} + +copy_license_readme() { + local dst="$1" + cp README.md "$dst/README.md" + if [[ -f LICENSE ]]; then + cp LICENSE "$dst/LICENSE" + elif [[ -f LICENSE.md ]]; then + cp LICENSE.md "$dst/LICENSE.md" + fi +} + +package_deb() { + local target binary deb_arch pkg_version suffix staging deb_file installed_size + target="$1" + binary="$2" + if ! deb_arch="$(deb_arch_for_target "$target")"; then + echo "warning: no Debian architecture mapping for ${target}; skipping .deb package" >&2 + return 0 + fi + if ! command -v dpkg-deb >/dev/null 2>&1; then + echo "warning: dpkg-deb is not available; skipping .deb package" >&2 + return 0 + fi + + suffix="$(package_release_suffix)" + pkg_version="${BURROW_PACKAGE_VERSION:-$(burrow_crate_version)+${suffix}}" + staging="${out_root}/linux/pkg-deb/burrow_${pkg_version}_${deb_arch}" + rm -rf "$staging" + mkdir -p \ + "$staging/DEBIAN" \ + "$staging/usr/bin" \ + "$staging/usr/lib/systemd/system" \ + "$staging/usr/share/doc/burrow" \ + "$staging/usr/share/licenses/burrow" + + install -m 0755 "$binary" "$staging/usr/bin/burrow" + install -m 0644 systemd/burrow.service "$staging/usr/lib/systemd/system/burrow.service" + install -m 0644 systemd/burrow.socket "$staging/usr/lib/systemd/system/burrow.socket" + install -m 0644 README.md "$staging/usr/share/doc/burrow/README.md" + install -m 0644 LICENSE.md "$staging/usr/share/licenses/burrow/LICENSE.md" + installed_size="$(du -sk "$staging/usr" | awk '{ print $1 }')" + + cat > "$staging/DEBIAN/control" < +Installed-Size: ${installed_size} +Depends: systemd +Description: Burrow VPN daemon and CLI + Burrow installs the daemon entrypoint and systemd socket used by the desktop UI. +EOF + + deb_file="${out_root}/linux/burrow_${pkg_version}_${deb_arch}.deb" + dpkg-deb --build --root-owner-group "$staging" "$deb_file" + sha256_file "$deb_file" +} + +package_rpm() { + local target binary rpm_arch + target="$1" + binary="$2" + if ! rpm_arch="$(rpm_arch_for_target "$target")"; then + echo "warning: no RPM architecture mapping for ${target}; skipping .rpm package" >&2 + return 0 + fi + if ! command -v cargo-generate-rpm >/dev/null 2>&1; then + echo "warning: cargo-generate-rpm is not available; skipping .rpm package" >&2 + return 0 + fi + + mkdir -p target/release + cp "$binary" target/release/burrow + if cargo generate-rpm -p burrow; then + find target/generate-rpm -type f -name '*.rpm' -exec cp {} "${out_root}/linux/" \; 2>/dev/null || true + find "${out_root}/linux" -maxdepth 1 -type f -name '*.rpm' -print | while read -r rpm; do + sha256_file "$rpm" + done + else + echo "warning: cargo-generate-rpm failed for ${rpm_arch}; skipping .rpm package" >&2 + fi +} + +package_pacman() { + local target binary pacman_arch pkg_version pkgrel work source_sum service_sum socket_sum readme_sum license_sum + target="$1" + binary="$2" + if ! pacman_arch="$(pacman_arch_for_target "$target")"; then + echo "warning: no pacman architecture mapping for ${target}; skipping Arch package" >&2 + return 0 + fi + if ! command -v makepkg >/dev/null 2>&1; then + echo "warning: makepkg is not available; skipping Arch package" >&2 + return 0 + fi + + pkg_version="${BURROW_ARCH_PKGVER:-$(burrow_crate_version)_$(arch_package_suffix)}" + pkgrel="${BURROW_ARCH_PKGREL:-1}" + work="${out_root}/linux/pkg-arch/${pacman_arch}" + rm -rf "$work" + mkdir -p "$work" + install -m 0755 "$binary" "$work/burrow" + install -m 0644 systemd/burrow.service "$work/burrow.service" + install -m 0644 systemd/burrow.socket "$work/burrow.socket" + install -m 0644 README.md "$work/README.md" + install -m 0644 LICENSE.md "$work/LICENSE.md" + + source_sum="$(sha256sum "$work/burrow" | awk '{ print $1 }')" + service_sum="$(sha256sum "$work/burrow.service" | awk '{ print $1 }')" + socket_sum="$(sha256sum "$work/burrow.socket" | awk '{ print $1 }')" + readme_sum="$(sha256sum "$work/README.md" | awk '{ print $1 }')" + license_sum="$(sha256sum "$work/LICENSE.md" | awk '{ print $1 }')" + + cat > "$work/PKGBUILD" < +pkgname=burrow +pkgver=${pkg_version} +pkgrel=${pkgrel} +pkgdesc="Burrow VPN daemon and CLI" +arch=("${pacman_arch}") +url="https://git.burrow.net/hackclub/burrow" +license=("GPL-3.0-or-later") +depends=("systemd") +source=("burrow" "burrow.service" "burrow.socket" "README.md" "LICENSE.md") +sha256sums=("${source_sum}" "${service_sum}" "${socket_sum}" "${readme_sum}" "${license_sum}") + +package() { + install -Dm755 "\${srcdir}/burrow" "\${pkgdir}/usr/bin/burrow" + install -Dm644 "\${srcdir}/burrow.service" "\${pkgdir}/usr/lib/systemd/system/burrow.service" + install -Dm644 "\${srcdir}/burrow.socket" "\${pkgdir}/usr/lib/systemd/system/burrow.socket" + install -Dm644 "\${srcdir}/README.md" "\${pkgdir}/usr/share/doc/burrow/README.md" + install -Dm644 "\${srcdir}/LICENSE.md" "\${pkgdir}/usr/share/licenses/burrow/LICENSE.md" +} +EOF + + ( + cd "$work" + makepkg --force --nodeps --noconfirm + ) + find "$work" -maxdepth 1 -type f -name '*.pkg.tar.*' -exec cp {} "${out_root}/linux/" \; + find "${out_root}/linux" -maxdepth 1 -type f -name '*.pkg.tar.*' -print | while read -r package; do + sha256_file "$package" + done +} + +package_linux() { + local target host archive staging + host="$(rustc -vV | awk '/^host:/ { print $2 }')" + target="${BURROW_LINUX_TARGET:-$host}" + if [[ "$target" != *-linux-* && -z "${BURROW_LINUX_TARGET:-}" ]]; then + mkdir -p "${out_root}/linux" + echo "warning: host target ${target} is not Linux; skipping Linux artifact on this host" >&2 + printf 'Linux build was skipped on host target %s. Run this lane on a Linux Namespace runner or set BURROW_LINUX_TARGET explicitly.\n' "$target" > "${out_root}/linux/README.txt" + return 0 + fi + staging="${out_root}/linux/burrow-${build_number}-${target}" + mkdir -p "$staging" + + cargo build --locked --release -p burrow --bin burrow --target "$target" + install -m 0755 "target/${target}/release/burrow" "$staging/burrow" + copy_license_readme "$staging" + + archive="${out_root}/linux/burrow-${build_number}-${target}.tar.gz" + tar -C "${out_root}/linux" -czf "$archive" "$(basename "$staging")" + sha256_file "$archive" + + package_deb "$target" "target/${target}/release/burrow" + package_rpm "$target" "target/${target}/release/burrow" + package_pacman "$target" "target/${target}/release/burrow" +} + +package_windows_stub_unix() { + local target exe archive staging + target="${BURROW_WINDOWS_TARGET:-x86_64-pc-windows-gnu}" + staging="${out_root}/windows/burrow-${build_number}-${target}" + mkdir -p "$staging" + + target_libdir="$(rustc --print target-libdir --target "$target" 2>/dev/null || true)" + if [[ -z "$target_libdir" || ! -d "$target_libdir" ]]; then + echo "warning: Rust target ${target} is not installed on this host" >&2 + printf 'Windows stub build for %s was skipped on this host. Use the Namespace Windows lane for the native artifact.\n' "$target" > "${out_root}/windows/README.txt" + return 0 + fi + + if cargo build --locked --release -p burrow-windows-stub --target "$target"; then + exe="target/${target}/release/burrow.exe" + else + echo "warning: unable to build the Windows release stub on this host" >&2 + printf 'Windows stub build for %s was skipped on this host. Use the Namespace Windows lane for the native artifact.\n' "$target" > "${out_root}/windows/README.txt" + return 0 + fi + + install -m 0755 "$exe" "$staging/burrow.exe" + copy_license_readme "$staging" + printf 'Burrow Windows stub build %s\n' "$build_number" > "$staging/README-Windows.txt" + + archive="${out_root}/windows/burrow-${build_number}-${target}.zip" + (cd "${out_root}/windows" && zip -qr "$archive" "$(basename "$staging")") + sha256_file "$archive" +} + +package_sparkle_unsigned() { + local macos_dir appcast channel dmg + channel="${SPARKLE_CHANNEL:-build-${build_number}}" + macos_dir="${out_root}/macos" + appcast="${out_root}/sparkle/${channel}/appcast.xml" + mkdir -p "$(dirname "$appcast")" + + dmg="$(find "$macos_dir" -maxdepth 1 -type f -name '*.dmg' -print 2>/dev/null | sort | tail -n 1 || true)" + if [[ -z "$dmg" ]]; then + echo "No macOS DMG exists yet; Sparkle appcast generation is waiting on the macOS signed artifact." > "${out_root}/sparkle/${channel}/README.txt" + return 0 + fi + + local name length pubdate url + name="$(basename "$dmg")" + length="$(wc -c < "$dmg" | tr -d ' ')" + pubdate="$(LC_ALL=C date -u '+%a, %d %b %Y %H:%M:%S +0000')" + url="${SPARKLE_DOWNLOAD_PREFIX:-https://releases.burrow.net/sparkle}/${channel}/${name}" + cat > "$appcast" < + + + Burrow ${channel} + + Burrow ${build_number} + ${pubdate} + ${build_number} + 0.1 + + + + +EOF + cp "$dmg" "${out_root}/sparkle/${channel}/" +} + +case "$platform" in + all) + package_linux + package_windows_stub_unix + if [[ "$(uname -s)" == "Darwin" ]] && command -v xcodebuild >/dev/null 2>&1; then + Scripts/ci/package-apple-artifacts.sh all + else + mkdir -p "${out_root}/apple" + printf 'Apple artifacts require a macOS runner with Xcode. The release workflow builds them in the dedicated Apple lane.\n' > "${out_root}/apple/README.txt" + fi + package_sparkle_unsigned + ;; + linux) + package_linux + ;; + windows-stub|windows) + package_windows_stub_unix + ;; + sparkle) + package_sparkle_unsigned + ;; + apple) + Scripts/ci/package-apple-artifacts.sh all + ;; + ios|macos) + Scripts/ci/package-apple-artifacts.sh "$platform" + ;; + *) + echo "unknown release platform: $platform" >&2 + exit 64 + ;; +esac + +find "$out_root" -type f -print | sort diff --git a/Scripts/ci/publish-forgejo-release.sh b/Scripts/ci/publish-forgejo-release.sh index 338f71b..5a976b8 100755 --- a/Scripts/ci/publish-forgejo-release.sh +++ b/Scripts/ci/publish-forgejo-release.sh @@ -7,7 +7,8 @@ set -euo pipefail : "${TOKEN:?TOKEN is required}" release_api="${API_URL}/repos/${REPOSITORY}/releases" -tag_api="${release_api}/tags/${RELEASE_TAG}" +encoded_release_tag="$(python3 -c 'import urllib.parse,sys; print(urllib.parse.quote(sys.argv[1], safe=""))' "${RELEASE_TAG}")" +tag_api="${release_api}/tags/${encoded_release_tag}" release_json="$(mktemp)" create_json="$(mktemp)" trap 'rm -f "${release_json}" "${create_json}"' EXIT @@ -50,6 +51,9 @@ if [[ -z "${release_id}" || "${release_id}" == "null" ]]; then fi for file in dist/*; do + if [[ ! -f "${file}" ]]; then + continue + fi name="$(basename "${file}")" asset_id="$(jq -r --arg name "${name}" '.assets[]? | select(.name == $name) | .id' "${release_json}" | head -n1)" if [[ -n "${asset_id}" ]]; then diff --git a/Scripts/ci/publish-nix-cache.sh b/Scripts/ci/publish-nix-cache.sh new file mode 100755 index 0000000..f8e55e3 --- /dev/null +++ b/Scripts/ci/publish-nix-cache.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "${repo_root}" + +cache_server_name="${BURROW_NIX_CACHE_SERVER_NAME:-burrow}" +cache_server_url="${BURROW_NIX_CACHE_SERVER_URL:-https://nix.burrow.net}" +cache_name="${BURROW_NIX_CACHE_NAME:-burrow}" +cache_ref="${cache_server_name}:${cache_name}" +token="${BURROW_NIX_CACHE_PUSH_TOKEN:-}" + +if [[ -z "$token" ]]; then + if [[ "${BURROW_NIX_CACHE_REQUIRED:-false}" == "true" ]]; then + echo "BURROW_NIX_CACHE_PUSH_TOKEN is required to publish Nix cache paths" >&2 + exit 1 + fi + echo "::notice ::BURROW_NIX_CACHE_PUSH_TOKEN is not set; skipping Nix cache publish." + exit 0 +fi + +if ! command -v attic >/dev/null 2>&1; then + echo "attic is required to publish Nix cache paths" >&2 + exit 127 +fi + +if ! command -v nix >/dev/null 2>&1; then + echo "nix is required to build paths for cache publishing" >&2 + exit 127 +fi + +attic login "$cache_server_name" "$cache_server_url" "$token" --set-default + +push_inputs=("$@") +if [[ "${#push_inputs[@]}" -eq 0 ]]; then + read -r -a attrs <<< "${BURROW_NIX_CACHE_ATTRS:-.#burrow .#forgejo-nsc-dispatcher .#forgejo-nsc-autoscaler}" + if [[ "${#attrs[@]}" -eq 0 ]]; then + echo "no Nix attrs were supplied for cache publishing" >&2 + exit 1 + fi + mapfile -t push_inputs < <(nix build --no-link --print-out-paths "${attrs[@]}") +fi + +if [[ "${#push_inputs[@]}" -eq 0 ]]; then + echo "no Nix output paths were produced for cache publishing" >&2 + exit 1 +fi + +attic push "$cache_ref" "${push_inputs[@]}" diff --git a/Scripts/ci/resolve-nix-bin.sh b/Scripts/ci/resolve-nix-bin.sh new file mode 100755 index 0000000..47f0cb0 --- /dev/null +++ b/Scripts/ci/resolve-nix-bin.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +set -euo pipefail + +find_nix_bin() { + local candidate + for candidate in \ + "${NIX_BIN:-}" \ + "$(command -v nix 2>/dev/null || true)" \ + "${HOME:-}/.nix-profile/bin/nix" \ + "${HOME:-}/.local/state/nix/profile/bin/nix" \ + "/nix/var/nix/profiles/per-user/${USER:-runner}/profile/bin/nix" \ + /nix/var/nix/profiles/default/bin/nix \ + /run/current-system/sw/bin/nix \ + /etc/profiles/per-user/runner/bin/nix \ + /Users/runner/.nix-profile/bin/nix \ + /Users/runner/.local/state/nix/profile/bin/nix \ + /home/runner/.nix-profile/bin/nix \ + /home/runner/.local/state/nix/profile/bin/nix \ + /nix/profile/bin/nix; do + if [[ -n "$candidate" && -x "$candidate" ]]; then + printf '%s\n' "$candidate" + return 0 + fi + done + + candidate="$( + find \ + "${HOME:-/nonexistent}" \ + /Users/runner \ + /home/runner \ + /nix/var/nix/profiles \ + /etc/profiles/per-user \ + -path '*/bin/nix' -type f 2>/dev/null | head -n 1 || true + )" + if [[ -n "$candidate" && -x "$candidate" ]]; then + printf '%s\n' "$candidate" + return 0 + fi + + return 1 +} + +if nix_bin="$(find_nix_bin)"; then + printf '%s\n' "$nix_bin" + exit 0 +fi + +if bash Scripts/ci/ensure-nix.sh >/dev/null 2>&1; then + if nix_bin="$(find_nix_bin)"; then + printf '%s\n' "$nix_bin" + exit 0 + fi +fi + +echo "::error ::nix is required but is not on PATH and no standard install path exists" >&2 +exit 1 diff --git a/Scripts/ci/sync-apple-provisioning-profiles.sh b/Scripts/ci/sync-apple-provisioning-profiles.sh new file mode 100755 index 0000000..72fe6d8 --- /dev/null +++ b/Scripts/ci/sync-apple-provisioning-profiles.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "$repo_root" + +platform="${1:-all}" +out_dir="${BURROW_APPLE_PROFILES_OUT_DIR:-.forgejo/actions/export}" +app_id="${BURROW_APPLE_BUNDLE_ID:-net.burrow.app}" +network_id="${BURROW_APPLE_NETWORK_EXTENSION_BUNDLE_ID:-${app_id}.network}" +replace_certificate_mismatch="${BURROW_APPLE_REPLACE_CERTIFICATE_MISMATCH:-false}" +if [[ -n "${BURROW_IOS_DISTRIBUTION_CERTIFICATE_ID:-}" || -n "${BURROW_DEVELOPER_ID_CERTIFICATE_ID:-}" ]]; then + replace_certificate_mismatch="${BURROW_APPLE_REPLACE_CERTIFICATE_MISMATCH:-true}" +fi + +key_id="${ASC_API_KEY_ID:-${APPSTORE_KEY_ID:-}}" +issuer_id="${ASC_API_ISSUER_ID:-${APPSTORE_KEY_ISSUER_ID:-}}" +key_path="${ASC_API_KEY_PATH:-${APPSTORE_KEY_PATH:-}}" +key_base64="${ASC_API_KEY_BASE64:-}" + +if [[ -z "$key_id" || -z "$issuer_id" ]]; then + echo "::notice ::App Store Connect credentials are not available; provisioning profile sync skipped." + exit 0 +fi + +temp_key="" +cleanup() { + [[ -z "$temp_key" ]] || rm -f "$temp_key" +} +trap cleanup EXIT + +if [[ -z "$key_path" ]]; then + if [[ -z "$key_base64" ]]; then + echo "::notice ::ASC_API_KEY_PATH/ASC_API_KEY_BASE64 is not available; provisioning profile sync skipped." + exit 0 + fi + temp_key="$(mktemp "${RUNNER_TEMP:-/tmp}/burrow-asc-key.XXXXXX.p8")" + printf '%s' "$key_base64" | base64 --decode > "$temp_key" + chmod 600 "$temp_key" + key_path="$temp_key" +fi + +if [[ ! -f "$key_path" ]]; then + echo "::error ::App Store Connect key path does not exist: ${key_path}" >&2 + exit 1 +fi + +mkdir -p "$out_dir" +profile_args=( + --platform "$platform" + --key-id "$key_id" + --issuer-id "$issuer_id" + --key-file "$key_path" + --out-dir "$out_dir" + --app-id "$app_id" + --network-id "$network_id" + --create-missing-bundle-ids "${BURROW_APPLE_CREATE_MISSING_BUNDLE_IDS:-false}" + --enable-capabilities "${BURROW_APPLE_ENABLE_CAPABILITIES:-false}" + --replace-certificate-mismatch "$replace_certificate_mismatch" + --bundle-platform "${BURROW_APPLE_BUNDLE_PLATFORM:-UNIVERSAL}" + --associated-domains "${BURROW_APPLE_ASSOCIATED_DOMAINS:-applinks:burrow.rs?mode=developer,webcredentials:burrow.rs?mode=developer}" +) + +if [[ -n "${BURROW_IOS_DISTRIBUTION_CERTIFICATE_ID:-}" ]]; then + profile_args+=(--ios-certificate-id "$BURROW_IOS_DISTRIBUTION_CERTIFICATE_ID") +fi + +if [[ -n "${BURROW_DEVELOPER_ID_CERTIFICATE_ID:-}" ]]; then + profile_args+=(--macos-certificate-id "$BURROW_DEVELOPER_ID_CERTIFICATE_ID") +fi + +node Scripts/apple/sync-provisioning-profiles.mjs "${profile_args[@]}" diff --git a/Scripts/ci/upload-package-garage.sh b/Scripts/ci/upload-package-garage.sh new file mode 100755 index 0000000..5dd87ba --- /dev/null +++ b/Scripts/ci/upload-package-garage.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -euo pipefail + +: "${BURROW_GARAGE_ENDPOINT:?BURROW_GARAGE_ENDPOINT is required}" +: "${AWS_ACCESS_KEY_ID:?AWS_ACCESS_KEY_ID is required for Garage upload}" +: "${AWS_SECRET_ACCESS_KEY:?AWS_SECRET_ACCESS_KEY is required for Garage upload}" + +repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "${repo_root}" + +source_dir="${BURROW_PACKAGE_REPOSITORY_DIR:-${repo_root}/publish/repositories}" + +if [[ ! -d "$source_dir" ]]; then + echo "package repository directory not found: $source_dir" >&2 + exit 1 +fi + +if ! command -v aws >/dev/null 2>&1; then + echo "aws CLI is required for Garage package repository upload" >&2 + exit 127 +fi + +bucket="${BURROW_PACKAGE_GARAGE_BUCKET:-burrow-packages}" +prefix="${BURROW_PACKAGE_GARAGE_PREFIX:-${BURROW_PACKAGE_GCS_PREFIX:-}}" +region="${BURROW_GARAGE_REGION:-garage}" +destination="s3://${bucket}" + +if [[ -n "$prefix" ]]; then + destination="${destination}/${prefix}" +fi + +export AWS_DEFAULT_REGION="$region" +export AWS_EC2_METADATA_DISABLED=true + +aws --endpoint-url "$BURROW_GARAGE_ENDPOINT" s3 sync "$source_dir" "$destination" --no-progress diff --git a/Scripts/ci/upload-package-repositories.sh b/Scripts/ci/upload-package-repositories.sh new file mode 100755 index 0000000..f6f0b8c --- /dev/null +++ b/Scripts/ci/upload-package-repositories.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "${repo_root}" + +prefix="${BURROW_PACKAGE_GCS_PREFIX:-}" +source_dir="${BURROW_PACKAGE_REPOSITORY_DIR:-${repo_root}/publish/repositories}" + +if [[ ! -d "$source_dir" ]]; then + echo "package repository directory not found: $source_dir" >&2 + exit 1 +fi + +bucket="${BURROW_PACKAGE_GCS_BUCKET:-burrow-net-packages}" +if ! command -v gcloud >/dev/null 2>&1; then + echo "gcloud is required for GCS package repository upload" >&2 + exit 127 +fi +gcloud auth list --filter=status:ACTIVE --format='value(account)' | grep -q . || { + echo "gcloud has no active account; run Scripts/ci/google-wif-auth.sh first" >&2 + exit 1 +} +destination="gs://${bucket}" +if [[ -n "$prefix" ]]; then + destination="${destination}/${prefix}" +fi +gcloud storage rsync --recursive "$source_dir" "$destination" diff --git a/Scripts/ci/upload-package-storage.sh b/Scripts/ci/upload-package-storage.sh new file mode 100755 index 0000000..7c4eb63 --- /dev/null +++ b/Scripts/ci/upload-package-storage.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "${repo_root}" + +uploaded=0 +garage_configured=0 + +if [[ -n "${BURROW_GARAGE_ENDPOINT:-}" && -n "${AWS_ACCESS_KEY_ID:-}" && -n "${AWS_SECRET_ACCESS_KEY:-}" ]]; then + garage_configured=1 +fi + +if [[ "$garage_configured" == "1" ]]; then + Scripts/ci/upload-package-garage.sh + uploaded=1 +elif [[ "${BURROW_PACKAGE_REQUIRE_GARAGE:-false}" == "true" ]]; then + echo "Garage package repository upload is required, but BURROW_GARAGE_ENDPOINT or AWS credentials are missing" >&2 + exit 1 +else + echo "::notice ::Garage package repository upload not configured; skipping primary S3-compatible target." +fi + +if [[ "${BURROW_PACKAGE_GCS_BACKUP:-true}" != "false" ]]; then + if ! command -v gcloud >/dev/null 2>&1; then + echo "gcloud is required for GCS package repository backup" >&2 + exit 127 + fi + if ! gcloud auth list --filter=status:ACTIVE --format='value(account)' | grep -q .; then + Scripts/ci/google-wif-auth.sh + fi + Scripts/ci/upload-package-repositories.sh + uploaded=1 +fi + +if [[ "$uploaded" != "1" ]]; then + echo "no package repository storage targets were enabled" >&2 + exit 1 +fi diff --git a/Scripts/ci/upload-release-garage.sh b/Scripts/ci/upload-release-garage.sh new file mode 100755 index 0000000..f5019aa --- /dev/null +++ b/Scripts/ci/upload-release-garage.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +set -euo pipefail + +: "${BUILD_NUMBER:?BUILD_NUMBER is required}" +: "${BURROW_GARAGE_ENDPOINT:?BURROW_GARAGE_ENDPOINT is required}" +: "${AWS_ACCESS_KEY_ID:?AWS_ACCESS_KEY_ID is required for Garage upload}" +: "${AWS_SECRET_ACCESS_KEY:?AWS_SECRET_ACCESS_KEY is required for Garage upload}" + +repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "${repo_root}" + +source_dir="${BURROW_RELEASE_OUT:-${repo_root}/dist/builds/${BUILD_NUMBER}}" + +if [[ ! -d "$source_dir" ]]; then + echo "release artifact directory not found: $source_dir" >&2 + exit 1 +fi + +if ! command -v aws >/dev/null 2>&1; then + echo "aws CLI is required for Garage release upload" >&2 + exit 127 +fi + +bucket="${BURROW_RELEASE_GARAGE_BUCKET:-burrow-releases}" +region="${BURROW_GARAGE_REGION:-garage}" +destination="s3://${bucket}/builds/${BUILD_NUMBER}" + +export AWS_DEFAULT_REGION="$region" +export AWS_EC2_METADATA_DISABLED=true +export AWS_REQUEST_CHECKSUM_CALCULATION="${AWS_REQUEST_CHECKSUM_CALCULATION:-when_required}" +export AWS_RESPONSE_CHECKSUM_VALIDATION="${AWS_RESPONSE_CHECKSUM_VALIDATION:-when_required}" + +aws --endpoint-url "$BURROW_GARAGE_ENDPOINT" s3 sync "$source_dir" "$destination" --no-progress diff --git a/Scripts/ci/upload-release-gcs.sh b/Scripts/ci/upload-release-gcs.sh new file mode 100755 index 0000000..14bbce4 --- /dev/null +++ b/Scripts/ci/upload-release-gcs.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail + +: "${BUILD_NUMBER:?BUILD_NUMBER is required}" + +repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "${repo_root}" + +source_dir="${BURROW_RELEASE_OUT:-${repo_root}/dist/builds/${BUILD_NUMBER}}" + +if [[ ! -d "$source_dir" ]]; then + echo "release artifact directory not found: $source_dir" >&2 + exit 1 +fi + +bucket="${BURROW_RELEASE_GCS_BUCKET:-burrow-net-releases}" +if ! command -v gcloud >/dev/null 2>&1; then + echo "gcloud is required for GCS release upload" >&2 + exit 127 +fi +gcloud auth list --filter=status:ACTIVE --format='value(account)' | grep -q . || { + echo "gcloud has no active account; run Scripts/ci/google-wif-auth.sh first" >&2 + exit 1 +} +gcloud storage rsync --recursive "$source_dir" "gs://${bucket}/builds/${BUILD_NUMBER}" diff --git a/Scripts/ci/upload-release-storage.sh b/Scripts/ci/upload-release-storage.sh new file mode 100755 index 0000000..3e6bd5f --- /dev/null +++ b/Scripts/ci/upload-release-storage.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +set -euo pipefail + +: "${BUILD_NUMBER:?BUILD_NUMBER is required}" + +repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "${repo_root}" + +uploaded=0 +garage_configured=0 + +if [[ -n "${BURROW_GARAGE_ENDPOINT:-}" && -n "${AWS_ACCESS_KEY_ID:-}" && -n "${AWS_SECRET_ACCESS_KEY:-}" ]]; then + garage_configured=1 +fi + +if [[ "$garage_configured" == "1" ]]; then + Scripts/ci/upload-release-garage.sh + uploaded=1 +elif [[ "${BURROW_RELEASE_REQUIRE_GARAGE:-false}" == "true" ]]; then + echo "Garage release upload is required, but BURROW_GARAGE_ENDPOINT or AWS credentials are missing" >&2 + exit 1 +else + echo "::notice ::Garage release upload not configured; skipping primary S3-compatible target." +fi + +if [[ "${BURROW_RELEASE_GCS_BACKUP:-true}" != "false" ]]; then + if ! command -v gcloud >/dev/null 2>&1; then + echo "gcloud is required for GCS release backup" >&2 + exit 127 + fi + if ! gcloud auth list --filter=status:ACTIVE --format='value(account)' | grep -q .; then + Scripts/ci/google-wif-auth.sh + fi + Scripts/ci/upload-release-gcs.sh + uploaded=1 +fi + +if [[ "$uploaded" != "1" ]]; then + echo "no release storage targets were enabled" >&2 + exit 1 +fi diff --git a/Scripts/forgejo-dispatch-via-host.sh b/Scripts/forgejo-dispatch-via-host.sh new file mode 100755 index 0000000..eee0c3f --- /dev/null +++ b/Scripts/forgejo-dispatch-via-host.sh @@ -0,0 +1,205 @@ +#!/usr/bin/env bash +set -euo pipefail + +usage() { + cat <<'EOF' +Usage: Scripts/forgejo-dispatch-via-host.sh [--ref ] [--inputs ] [--inputs-file ] [--return-run-info] + +Dispatch a Burrow Forgejo workflow by SSHing to the live forge host and using +the managed dispatcher token from the host runtime. + +Environment: + FORGEJO_BASE_URL Default: https://git.burrow.net + FORGEJO_REPO Default: hackclub/burrow + BURROW_FORGE_HOST Default: root@git.burrow.net + BURROW_FORGE_HOST_ADDRESS Optional SSH HostName override + BURROW_FORGE_SSH_KEY Optional explicit SSH private key + AGE_FORGE_SSH_KEY Optional injected SSH private key material + BURROW_FORGE_DISPATCHER_CONFIG_FILE Default: /run/agenix/burrowForgejoNscDispatcherConfig +EOF +} + +base_url="${FORGEJO_BASE_URL:-https://git.burrow.net}" +repo_slug="${FORGEJO_REPO:-hackclub/burrow}" +forge_host="${BURROW_FORGE_HOST:-root@git.burrow.net}" +forge_host_address="${BURROW_FORGE_HOST_ADDRESS:-}" +dispatcher_config_file="${BURROW_FORGE_DISPATCHER_CONFIG_FILE:-/run/agenix/burrowForgejoNscDispatcherConfig}" +workflow="" +ref="main" +inputs_json="" +return_run_info="false" + +while [[ $# -gt 0 ]]; do + case "$1" in + -h|--help) + usage + exit 0 + ;; + --ref) + ref="${2:-}" + shift 2 + ;; + --inputs) + inputs_json="${2:-}" + shift 2 + ;; + --inputs-file) + inputs_json="$(cat "${2:-}")" + shift 2 + ;; + --return-run-info) + return_run_info="true" + shift + ;; + *) + if [[ -z "$workflow" ]]; then + workflow="$1" + shift + else + echo "Unexpected argument: $1" >&2 + usage >&2 + exit 64 + fi + ;; + esac +done + +if [[ -z "$workflow" ]]; then + echo "Missing workflow name or file, for example build-release.yml." >&2 + usage >&2 + exit 64 +fi + +script_dir="$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +resolved_forge_ssh_key="$("${script_dir}/resolve-forge-ssh-key.sh")" +eval "$resolved_forge_ssh_key" +ssh_key="${BURROW_FORGE_SSH_KEY}" + +if [[ -n "$inputs_json" ]]; then + if ! python3 - "$inputs_json" <<'PY' >/dev/null +import json +import sys + +value = json.loads(sys.argv[1]) +if not isinstance(value, dict): + raise SystemExit(1) +PY + then + echo "--inputs must be a JSON object." >&2 + exit 64 + fi +fi + +workflow_path="$(python3 - "$workflow" <<'PY' +import sys +import urllib.parse + +print(urllib.parse.quote(sys.argv[1], safe="")) +PY +)" + +payload="$(python3 - "$ref" "$inputs_json" "$return_run_info" <<'PY' +import json +import sys + +ref = sys.argv[1] +inputs_arg = sys.argv[2] +return_run_info = sys.argv[3] == "true" + +payload = {"ref": ref} +if inputs_arg: + inputs = json.loads(inputs_arg) + payload["inputs"] = {key: str(value) for key, value in inputs.items()} +if return_run_info: + payload["return_run_info"] = True +print(json.dumps(payload)) +PY +)" + +payload_b64="$(python3 - "$payload" <<'PY' +import base64 +import sys + +print(base64.b64encode(sys.argv[1].encode()).decode()) +PY +)" + +ssh_opts=( + -i "$ssh_key" + -o IdentitiesOnly=yes + -o UserKnownHostsFile=/dev/null + -o GlobalKnownHostsFile=/dev/null + -o StrictHostKeyChecking=accept-new +) +if [[ -n "$forge_host_address" ]]; then + ssh_opts+=(-o "HostName=$forge_host_address") +fi + +response="$( + ssh "${ssh_opts[@]}" "$forge_host" bash -s -- \ + "$base_url" "$repo_slug" "$workflow_path" "$dispatcher_config_file" "$payload_b64" <<'EOF' +set -euo pipefail + +base_url="$1" +repo_slug="$2" +workflow_path="$3" +dispatcher_config_file="$4" +payload_b64="$5" + +payload="$(python3 - "$payload_b64" <<'PY' +import base64 +import sys + +print(base64.b64decode(sys.argv[1]).decode()) +PY +)" + +if [[ ! -s "$dispatcher_config_file" ]]; then + echo "Forge dispatcher config is missing or empty: $dispatcher_config_file" >&2 + exit 1 +fi + +runtime_token="$( + awk ' + /^[A-Za-z0-9_-]+:/ { in_forgejo = ($0 ~ /^forgejo:/); next } + in_forgejo && /^[[:space:]]+token:/ { + sub(/^[[:space:]]+token:[[:space:]]*/, "") + gsub(/^"/, "") + gsub(/"$/, "") + gsub(/^\047/, "") + gsub(/\047$/, "") + print + exit + } + ' "$dispatcher_config_file" | tr -d "\r\n" +)" + +if [[ -z "$runtime_token" ]]; then + echo "Forge dispatcher token not found in $dispatcher_config_file" >&2 + exit 1 +fi + +url="${base_url%/}/api/v1/repos/${repo_slug}/actions/workflows/${workflow_path}/dispatches" +response_file="$(mktemp)" +http_code="$( + curl -sS -o "$response_file" -w '%{http_code}' -X POST \ + -H "Authorization: token ${runtime_token}" \ + -H "Content-Type: application/json" \ + --data-binary "$payload" \ + "$url" +)" +if [[ "$http_code" != 2* ]]; then + cat "$response_file" >&2 + rm -f "$response_file" + exit 22 +fi +cat "$response_file" +rm -f "$response_file" +EOF +)" + +if [[ "$return_run_info" == "true" ]]; then + printf '%s\n' "$response" +else + echo "Dispatched ${workflow} on ${ref} via ${forge_host}." +fi diff --git a/Scripts/forgejo-dispatch.sh b/Scripts/forgejo-dispatch.sh new file mode 100755 index 0000000..a9a7090 --- /dev/null +++ b/Scripts/forgejo-dispatch.sh @@ -0,0 +1,240 @@ +#!/usr/bin/env bash +set -euo pipefail + +usage() { + cat <<'EOF' +Usage: Scripts/forgejo-dispatch.sh [--ref ] [--inputs ] [--inputs-file ] [--return-run-info] + +Dispatch a Burrow Forgejo workflow through the Forgejo API. + +Environment: + FORGEJO_BASE_URL Default: https://git.burrow.net + FORGEJO_REPO Default: hackclub/burrow + FORGEJO_PAT Token string + FORGEJO_PAT_FILE Path to plaintext token + FORGEJO_DISPATCH_HOST_FALLBACK auto, always, or never. Default: auto +EOF +} + +repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +base_url="${FORGEJO_BASE_URL:-https://git.burrow.net}" +repo_slug="${FORGEJO_REPO:-hackclub/burrow}" +host_fallback="${FORGEJO_DISPATCH_HOST_FALLBACK:-auto}" +original_args=("$@") +workflow="" +ref="main" +inputs_json="" +return_run_info="false" + +case "$host_fallback" in + auto|always|never) ;; + *) + echo "FORGEJO_DISPATCH_HOST_FALLBACK must be auto, always, or never." >&2 + exit 64 + ;; +esac + +host_dispatch() { + local reason="$1" + local fallback="${repo_root}/Scripts/forgejo-dispatch-via-host.sh" + + if [[ ! -x "$fallback" ]]; then + return 1 + fi + + echo "Forgejo API dispatch ${reason}; retrying through the forge host." >&2 + exec "$fallback" "${original_args[@]}" +} + +if [[ "$host_fallback" == "always" ]]; then + if ! host_dispatch "forced by FORGEJO_DISPATCH_HOST_FALLBACK=always"; then + echo "Forge host dispatcher is not available." >&2 + exit 1 + fi +fi + +while [[ $# -gt 0 ]]; do + case "$1" in + -h|--help) + usage + exit 0 + ;; + --ref) + ref="${2:-}" + shift 2 + ;; + --inputs) + inputs_json="${2:-}" + shift 2 + ;; + --inputs-file) + inputs_json="$(cat "${2:-}")" + shift 2 + ;; + --return-run-info) + return_run_info="true" + shift + ;; + *) + if [[ -z "$workflow" ]]; then + workflow="$1" + shift + else + echo "Unexpected argument: $1" >&2 + usage >&2 + exit 64 + fi + ;; + esac +done + +if [[ -z "$workflow" ]]; then + echo "Missing workflow name or file, for example build-release.yml." >&2 + usage >&2 + exit 64 +fi + +extract_dispatcher_token() { + python3 - "$1" <<'PY' +import re +import sys +from pathlib import Path + +path = Path(sys.argv[1]) +in_forgejo = False +for line in path.read_text(encoding="utf-8").splitlines(): + if re.match(r"^[A-Za-z0-9_-]+:", line): + in_forgejo = line.startswith("forgejo:") + continue + if not in_forgejo: + continue + match = re.match(r"\s+token:\s*['\"]?([^'\"]+)['\"]?\s*$", line) + if match: + print(match.group(1)) + break +PY +} + +decrypt_age_secret() { + local path="$1" + + if [[ ! -f "$path" ]]; then + return 1 + fi + + if command -v nix >/dev/null 2>&1; then + nix run "${repo_root}#agenix" -- -d "$path" 2>/dev/null && return 0 + fi + + if command -v agenix >/dev/null 2>&1; then + agenix -d "$path" 2>/dev/null && return 0 + fi + + return 1 +} + +pat="${FORGEJO_PAT:-}" +pat_source="none" +if [[ -n "$pat" ]]; then + pat_source="FORGEJO_PAT" +fi + +if [[ -z "$pat" && -n "${FORGEJO_PAT_FILE:-}" && -f "$FORGEJO_PAT_FILE" ]]; then + pat="$(tr -d '\r\n' < "$FORGEJO_PAT_FILE")" + if [[ -n "$pat" ]]; then + pat_source="FORGEJO_PAT_FILE" + fi +fi + +if [[ -z "$pat" ]]; then + for default_file in \ + "${repo_root}/intake/forgejo_dispatch_pat.txt" \ + "${repo_root}/intake/forgejo_nsc_dispatcher.yaml" + do + if [[ -s "$default_file" ]]; then + if [[ "$default_file" == *.yaml ]]; then + pat="$(extract_dispatcher_token "$default_file" | tr -d '\r\n')" + else + pat="$(tr -d '\r\n' < "$default_file")" + fi + fi + if [[ -n "$pat" ]]; then + pat_source="$default_file" + break + fi + done +fi + +if [[ -z "$pat" ]]; then + decrypted_config="$(mktemp)" + trap 'rm -f "$decrypted_config"' EXIT + if decrypt_age_secret "${repo_root}/secrets/infra/forgejo-nsc-dispatcher-config.age" > "$decrypted_config"; then + pat="$(extract_dispatcher_token "$decrypted_config" | tr -d '\r\n')" + if [[ -n "$pat" ]]; then + pat_source="secrets/infra/forgejo-nsc-dispatcher-config.age" + fi + fi +fi + +if [[ -z "$pat" ]]; then + if [[ "$host_fallback" == "auto" ]]; then + if host_dispatch "has no local token"; then + exit 0 + fi + fi + echo "Forgejo token not found. Set FORGEJO_PAT or FORGEJO_PAT_FILE." >&2 + exit 1 +fi + +if [[ -n "$inputs_json" ]]; then + if ! printf '%s\n' "$inputs_json" | jq -e 'type == "object"' >/dev/null 2>&1; then + echo "--inputs must be a JSON object." >&2 + exit 64 + fi + inputs_json="$(printf '%s\n' "$inputs_json" | jq -c 'with_entries(.value |= tostring)')" + payload="$(jq -n --arg ref "$ref" --argjson inputs "$inputs_json" --argjson return_run_info "$return_run_info" \ + '{ref:$ref, inputs:$inputs} + (if $return_run_info then {return_run_info:true} else {} end)')" +else + payload="$(jq -n --arg ref "$ref" --argjson return_run_info "$return_run_info" \ + '{ref:$ref} + (if $return_run_info then {return_run_info:true} else {} end)')" +fi + +workflow_path="$(python3 - "$workflow" <<'PY' +import sys +import urllib.parse + +print(urllib.parse.quote(sys.argv[1], safe="")) +PY +)" + +url="${base_url%/}/api/v1/repos/${repo_slug}/actions/workflows/${workflow_path}/dispatches" +response_file="$(mktemp)" +trap 'rm -f "$response_file" "${decrypted_config:-}"' EXIT + +curl_status=0 +http_code="$( + curl -sS -o "$response_file" -w '%{http_code}' -X POST \ + -H "Authorization: token ${pat}" \ + -H "Content-Type: application/json" \ + --data-binary "$payload" \ + "$url" +)" || curl_status="$?" + +if [[ "$curl_status" != "0" || "$http_code" != 2* ]]; then + if [[ "$host_fallback" == "auto" && "$pat_source" != "FORGEJO_PAT" && ( "$http_code" == "401" || "$http_code" == "403" ) ]]; then + if host_dispatch "returned HTTP ${http_code} with ${pat_source}"; then + exit 0 + fi + fi + + cat "$response_file" >&2 || true + if [[ "$curl_status" != "0" ]]; then + exit "$curl_status" + fi + exit 22 +fi + +cat "$response_file" +if [[ "$return_run_info" != "true" ]]; then + echo "Dispatched ${workflow} on ${ref}." +fi diff --git a/Scripts/generate-brand-icons.py b/Scripts/generate-brand-icons.py new file mode 100755 index 0000000..02dd15d --- /dev/null +++ b/Scripts/generate-brand-icons.py @@ -0,0 +1,450 @@ +#!/usr/bin/env python3 +"""Generate Burrow app icons from locked raster panel masters.""" + +from __future__ import annotations + +import json +import shutil +import subprocess +import sys +from pathlib import Path + + +ROOT = Path(__file__).resolve().parents[1] +BRAND = ROOT / "design" / "brand" +PANEL_DIR = BRAND / "panel-variants" +APPLE_ASSETS = ROOT / "Apple" / "UI" / "Assets.xcassets" +APPICON_SET = APPLE_ASSETS / "AppIcon.appiconset" +WATCHOS_BRAND_APPICON_SET = BRAND / "watchos" / "AppIcon.appiconset" +ANDROID_RES = ROOT / "Android" / "app" / "src" / "main" / "res" +GTK_ICONS = ROOT / "burrow-gtk" / "data" / "icons" / "hicolor" + +VARIANTS = [ + ("panel-01-guardian", "BurrowPanel01", "Guardian", "top-left panel"), + ("panel-02-field", "BurrowPanel02", "Field", "top-middle panel"), + ("panel-03-burrow", "BurrowPanel03", "Burrow", "top-right panel"), + ("panel-04-sentinel", "BurrowPanel04", "Sentinel", "bottom-left panel"), + ("panel-05-stride", "BurrowPanel05", "Stride", "bottom-middle panel"), + ("panel-06-post", "BurrowPanel06", "Post", "bottom-right panel"), +] + +PRIMARY_IOS = "panel-01-guardian" +PRIMARY_MACOS = "panel-05-stride" +PRIMARY_WATCHOS = "panel-03-burrow" +PRIMARY_ANDROID = PRIMARY_IOS +PRIMARY_LINUX = PRIMARY_IOS + +# Rough cells in the supplied 2928x1896 panel screenshot. Extraction trims the +# white sheet background, makes the crop square with transparent padding, then +# normalizes to 1024px. +EXTRACTION_CELLS = { + "panel-01-guardian": (40, 40, 900, 900), + "panel-02-field": (940, 40, 900, 900), + "panel-03-burrow": (1840, 40, 900, 900), + "panel-04-sentinel": (40, 980, 900, 900), + "panel-05-stride": (940, 980, 900, 900), + "panel-06-post": (1840, 980, 900, 900), +} + +IOS_ROWS = [ + ("iphone", "20x20", "2x", 40, {}), + ("iphone", "20x20", "3x", 60, {}), + ("iphone", "29x29", "1x", 29, {}), + ("iphone", "29x29", "2x", 58, {}), + ("iphone", "29x29", "3x", 87, {}), + ("iphone", "40x40", "2x", 80, {}), + ("iphone", "40x40", "3x", 120, {}), + ("iphone", "57x57", "1x", 57, {}), + ("iphone", "57x57", "2x", 114, {}), + ("iphone", "60x60", "2x", 120, {}), + ("iphone", "60x60", "3x", 180, {}), + ("ipad", "20x20", "1x", 20, {}), + ("ipad", "20x20", "2x", 40, {}), + ("ipad", "29x29", "1x", 29, {}), + ("ipad", "29x29", "2x", 58, {}), + ("ipad", "40x40", "1x", 40, {}), + ("ipad", "40x40", "2x", 80, {}), + ("ipad", "50x50", "1x", 50, {}), + ("ipad", "50x50", "2x", 100, {}), + ("ipad", "72x72", "1x", 72, {}), + ("ipad", "72x72", "2x", 144, {}), + ("ipad", "76x76", "1x", 76, {}), + ("ipad", "76x76", "2x", 152, {}), + ("ipad", "83.5x83.5", "2x", 167, {}), + ("ios-marketing", "1024x1024", "1x", 1024, {}), +] + +MAC_ROWS = [ + ("mac", "16x16", "1x", 16, {}), + ("mac", "16x16", "2x", 32, {}), + ("mac", "32x32", "1x", 32, {}), + ("mac", "32x32", "2x", 64, {}), + ("mac", "128x128", "1x", 128, {}), + ("mac", "128x128", "2x", 256, {}), + ("mac", "256x256", "1x", 256, {}), + ("mac", "256x256", "2x", 512, {}), + ("mac", "512x512", "1x", 512, {}), + ("mac", "512x512", "2x", 1024, {}), +] + +WATCH_ROWS = [ + ("watch", "24x24", "2x", 48, {"role": "notificationCenter", "subtype": "38mm"}), + ("watch", "27.5x27.5", "2x", 55, {"role": "notificationCenter", "subtype": "42mm"}), + ("watch", "33x33", "2x", 66, {"role": "notificationCenter", "subtype": "45mm"}), + ("watch", "29x29", "2x", 58, {"role": "companionSettings"}), + ("watch", "29x29", "3x", 87, {"role": "companionSettings"}), + ("watch", "40x40", "2x", 80, {"role": "appLauncher", "subtype": "38mm"}), + ("watch", "44x44", "2x", 88, {"role": "appLauncher", "subtype": "40mm"}), + ("watch", "46x46", "2x", 92, {"role": "appLauncher", "subtype": "41mm"}), + ("watch", "50x50", "2x", 100, {"role": "appLauncher", "subtype": "44mm"}), + ("watch", "51x51", "2x", 102, {"role": "appLauncher", "subtype": "45mm"}), + ("watch", "54x54", "2x", 108, {"role": "appLauncher", "subtype": "49mm"}), + ("watch", "86x86", "2x", 172, {"role": "quickLook", "subtype": "38mm"}), + ("watch", "98x98", "2x", 196, {"role": "quickLook", "subtype": "42mm"}), + ("watch", "108x108", "2x", 216, {"role": "quickLook", "subtype": "44mm"}), + ("watch", "117x117", "2x", 234, {"role": "quickLook", "subtype": "45mm"}), + ("watch", "129x129", "2x", 258, {"role": "quickLook", "subtype": "49mm"}), + ("watch-marketing", "1024x1024", "1x", 1024, {}), +] + +ANDROID_MIPMAPS = { + "mipmap-mdpi": 48, + "mipmap-hdpi": 72, + "mipmap-xhdpi": 96, + "mipmap-xxhdpi": 144, + "mipmap-xxxhdpi": 192, +} + +LINUX_SIZES = [16, 24, 32, 48, 64, 128, 256, 512] + + +def run(args: list[str]) -> None: + subprocess.run(args, cwd=ROOT, check=True) + + +def output(args: list[str]) -> str: + return subprocess.check_output(args, cwd=ROOT, text=True).strip() + + +def write_text(path: Path, text: str) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(text, encoding="utf-8") + + +def write_json(path: Path, value: object) -> None: + write_text(path, json.dumps(value, indent=2) + "\n") + + +def variant(asset_id: str) -> tuple[str, str, str, str]: + for item in VARIANTS: + if item[0] == asset_id: + return item + raise KeyError(asset_id) + + +def master_path(asset_id: str) -> Path: + return PANEL_DIR / f"{asset_id}.png" + + +def extract_masters(sheet: Path) -> None: + PANEL_DIR.mkdir(parents=True, exist_ok=True) + shutil.copyfile(sheet, PANEL_DIR / "source-sheet.png") + for asset_id, (x, y, w, h) in EXTRACTION_CELLS.items(): + tmp = PANEL_DIR / f".{asset_id}-trim.png" + dest = master_path(asset_id) + run( + [ + "magick", + str(sheet), + "-crop", + f"{w}x{h}+{x}+{y}", + "-fuzz", + "8%", + "-trim", + "+repage", + str(tmp), + ] + ) + geometry = output(["magick", str(tmp), "-format", "%w %h", "info:"]) + width, height = [int(part) for part in geometry.split()] + extent = max(width, height) + run( + [ + "magick", + str(tmp), + "-alpha", + "set", + "-fuzz", + "6%", + "-fill", + "none", + "-draw", + "color 0,0 floodfill", + "-draw", + f"color {width - 1},0 floodfill", + "-draw", + f"color 0,{height - 1} floodfill", + "-draw", + f"color {width - 1},{height - 1} floodfill", + "-background", + "none", + "-gravity", + "center", + "-extent", + f"{extent}x{extent}", + "-resize", + "1024x1024!", + "(", + "-size", + "1024x1024", + "xc:none", + "-fill", + "white", + "-draw", + "roundrectangle 10,10 1013,1013 166,166", + ")", + "-compose", + "DstIn", + "-composite", + "-strip", + f"PNG32:{dest}", + ] + ) + tmp.unlink() + + +def ensure_masters() -> None: + missing = [asset_id for asset_id, *_ in VARIANTS if not master_path(asset_id).exists()] + if missing: + raise SystemExit(f"missing panel masters: {', '.join(missing)}") + + +def clean_generated() -> None: + APPICON_SET.mkdir(parents=True, exist_ok=True) + for path in APPICON_SET.glob("*.png"): + path.unlink() + for path in APPLE_ASSETS.glob("BurrowPanel*.appiconset"): + shutil.rmtree(path) + for path in APPLE_ASSETS.glob("BurrowPanel*Preview.imageset"): + shutil.rmtree(path) + shutil.rmtree(WATCHOS_BRAND_APPICON_SET, ignore_errors=True) + + low_res = BRAND / "low-res" + low_res.mkdir(parents=True, exist_ok=True) + for path in low_res.glob("*.png"): + path.unlink() + report = low_res / "report.csv" + if report.exists(): + report.unlink() + + for folder in ANDROID_MIPMAPS: + shutil.rmtree(ANDROID_RES / folder, ignore_errors=True) + + for size in LINUX_SIZES: + shutil.rmtree(GTK_ICONS / str(size), ignore_errors=True) + + for path in PANEL_DIR.glob("*-preview.png"): + path.unlink() + preview = PANEL_DIR / "preview-strip.png" + if preview.exists(): + preview.unlink() + + +def render_png(source: Path, dest: Path, size: int, *, png32: bool = True) -> None: + dest.parent.mkdir(parents=True, exist_ok=True) + prefix = "PNG32:" if png32 else "PNG24:" + run( + [ + "magick", + str(source), + "-resize", + f"{size}x{size}!", + "-strip", + f"{prefix}{dest}", + ] + ) + + +def image_entry(idiom: str, size: str, scale: str, filename: str, extra: dict[str, str]) -> dict[str, str]: + row = {"filename": filename, "idiom": idiom, "scale": scale, "size": size} + row.update(extra) + return row + + +def write_appicon_contents(path: Path, rows: list[dict[str, str]]) -> None: + write_json(path / "Contents.json", {"images": rows, "info": {"author": "xcode", "version": 1}}) + + +def generate_appicon_set( + path: Path, + source: Path, + prefix: str, + rows_def: list[tuple[str, str, str, int, dict[str, str]]], +) -> list[dict[str, str]]: + path.mkdir(parents=True, exist_ok=True) + rows = [] + rendered: set[tuple[str, int]] = set() + for idiom, size_label, scale, pixels, extra in rows_def: + filename = f"{prefix}-{pixels}.png" + rows.append(image_entry(idiom, size_label, scale, filename, extra)) + key = (filename, pixels) + if key not in rendered: + render_png(source, path / filename, pixels) + rendered.add(key) + return rows + + +def generate_apple_assets() -> None: + primary_rows = [] + primary_rows.extend(generate_appicon_set(APPICON_SET, master_path(PRIMARY_IOS), "ios-panel-01", IOS_ROWS)) + primary_rows.extend(generate_appicon_set(APPICON_SET, master_path(PRIMARY_MACOS), "mac-panel-05", MAC_ROWS)) + write_appicon_contents(APPICON_SET, primary_rows) + + watch_rows = generate_appicon_set( + WATCHOS_BRAND_APPICON_SET, + master_path(PRIMARY_WATCHOS), + "watch-panel-03", + WATCH_ROWS, + ) + write_appicon_contents(WATCHOS_BRAND_APPICON_SET, watch_rows) + + for asset_id, asset_name, _, _ in VARIANTS[1:]: + set_path = APPLE_ASSETS / f"{asset_name}.appiconset" + rows = generate_appicon_set(set_path, master_path(asset_id), asset_name, IOS_ROWS) + write_appicon_contents(set_path, rows) + + for asset_id, asset_name, _, _ in VARIANTS: + preview_dir = APPLE_ASSETS / f"{asset_name}Preview.imageset" + preview_dir.mkdir(parents=True, exist_ok=True) + render_png(master_path(asset_id), preview_dir / "preview.png", 256) + write_json( + preview_dir / "Contents.json", + { + "images": [{"filename": "preview.png", "idiom": "universal", "scale": "1x"}], + "info": {"author": "xcode", "version": 1}, + }, + ) + + +def generate_brand_outputs() -> None: + primary = master_path(PRIMARY_IOS) + render_png(primary, BRAND / "burrow-owl-icon-master.png", 1024) + render_png(primary, BRAND / "burrowing-owl-icon-flat.png", 1024) + render_png(primary, BRAND / "Burrow.icon" / "Assets" / "owl-figure.png", 1024) + render_png(primary, BRAND / "Burrow.icon" / "Assets" / "owl-body.png", 1024) + transparent = BRAND / "Burrow.icon" / "Assets" / "transparent.png" + run(["magick", "-size", "1024x1024", "xc:none", f"PNG32:{transparent}"]) + for name in ["burrow-ground", "owl-face", "owl-legs", "owl-spots"]: + shutil.copyfile(transparent, BRAND / "Burrow.icon" / "Assets" / f"{name}.png") + transparent.unlink() + write_json( + BRAND / "Burrow.icon" / "icon.json", + { + "fill": {"type": "solid", "color": "#00000000"}, + "layers": [ + { + "blend-mode": "normal", + "image-name": "owl-figure.png", + "name": "panel-raster", + "position": {"scale": 1, "translation-in-points": [0, 0]}, + } + ], + }, + ) + + low_res = BRAND / "low-res" + report_rows = ["size,colors,gray_stddev,status"] + preview_inputs = [] + pixel_inputs = [] + for size in [16, 20, 24, 29, 32, 40, 48, 64, 80, 128, 256, 1024]: + icon = low_res / f"burrow-icon-{size}.png" + render_png(primary, icon, size) + if size <= 256: + colors = output(["magick", str(icon), "-format", "%k", "info:"]) + stddev = output(["magick", str(icon), "-colorspace", "Gray", "-format", "%[fx:standard_deviation]", "info:"]) + status = "ok" if int(colors) >= 8 and float(stddev) >= 0.025 else "check" + report_rows.append(f"{size},{colors},{stddev},{status}") + preview = low_res / f"preview-{size}.png" + filter_name = "Point" if size <= 32 else "Lanczos" + run(["magick", str(icon), "-filter", filter_name, "-resize", "128x128", str(preview)]) + preview_inputs.append(preview) + if size <= 32: + pixel = low_res / f"pixel-preview-{size}.png" + run(["magick", str(icon), "-filter", "Point", "-resize", "128x128", str(pixel)]) + pixel_inputs.append(pixel) + + write_text(low_res / "report.csv", "\n".join(report_rows) + "\n") + preview_inputs.reverse() + pixel_inputs.reverse() + run(["magick", "-background", "#202020", "-gravity", "center", *map(str, preview_inputs), "+append", str(low_res / "preview-strip.png")]) + run(["magick", "-background", "#202020", "-gravity", "center", *map(str, pixel_inputs), "+append", str(low_res / "pixel-preview-strip.png")]) + + variant_previews = [] + for asset_id, _, _, _ in VARIANTS: + preview = PANEL_DIR / f"{asset_id}-preview.png" + render_png(master_path(asset_id), preview, 256) + variant_previews.append(preview) + run(["magick", "-background", "#fbfaf6", "-gravity", "center", *map(str, variant_previews), "+append", str(PANEL_DIR / "preview-strip.png")]) + + lines = [ + "# Burrow Raster Panel Icon Variants", + "", + "The six PNG masters here are cropped from `source-sheet.png` and are the", + "locked app icon source. Do not redraw them; regenerate package assets from", + "these rasters.", + "", + "| Variant | Use | Source |", + "| --- | --- | --- |", + ] + for asset_id, _, title, source in VARIANTS: + uses = [] + if asset_id == PRIMARY_IOS: + uses.append("iOS primary") + else: + uses.append("iOS alternate") + if asset_id == PRIMARY_MACOS: + uses.append("macOS primary") + if asset_id == PRIMARY_WATCHOS: + uses.append("watchOS primary") + if asset_id == PRIMARY_ANDROID: + uses.append("Android primary") + if asset_id == PRIMARY_LINUX: + uses.append("Linux primary") + use_text = ", ".join(uses) + lines.append(f"| `{asset_id}` | {use_text} | {title}, {source} |") + lines.append("") + lines.append("`preview-strip.png` shows the six raster masters side by side.") + write_text(PANEL_DIR / "README.md", "\n".join(lines) + "\n") + + +def generate_android_assets() -> None: + primary = master_path(PRIMARY_ANDROID) + for folder, size in ANDROID_MIPMAPS.items(): + out_dir = ANDROID_RES / folder + render_png(primary, out_dir / "ic_launcher.png", size) + render_png(primary, out_dir / "ic_launcher_round.png", size) + render_png(primary, ROOT / "store-metadata" / "android" / "icon.png", 512) + + +def generate_linux_assets() -> None: + primary = master_path(PRIMARY_LINUX) + for size in LINUX_SIZES: + render_png(primary, GTK_ICONS / str(size) / "apps" / "burrow-gtk.png", size) + + +def main(argv: list[str]) -> None: + if len(argv) == 3 and argv[1] == "--extract-from": + extract_masters(Path(argv[2])) + elif len(argv) != 1: + raise SystemExit("usage: generate-brand-icons.py [--extract-from /path/to/panel-sheet.png]") + + ensure_masters() + clean_generated() + generate_apple_assets() + generate_brand_outputs() + generate_android_assets() + generate_linux_assets() + + +if __name__ == "__main__": + main(sys.argv) diff --git a/Scripts/grafana-tofu.sh b/Scripts/grafana-tofu.sh new file mode 100755 index 0000000..d1f6a91 --- /dev/null +++ b/Scripts/grafana-tofu.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="$( + git rev-parse --show-toplevel 2>/dev/null || { + cd "$(dirname "${BASH_SOURCE[0]}")/.." + pwd + } +)" + +work_dir="${BURROW_GRAFANA_TOFU_DIR:-$ROOT/infra/grafana}" +plugin_cache_dir="${BURROW_TOFU_PLUGIN_CACHE_DIR:-$ROOT/.cache/opentofu/plugins}" + +usage() { + cat <<'EOF' +Usage: Scripts/grafana-tofu.sh [tofu args...] + +Runs OpenTofu for Burrow Grafana API configuration. This stack creates folders +and dashboards only; Nix owns the Grafana service, authentication, data sources, +and boot-time provisioning files. + +Examples: + Scripts/grafana-tofu.sh init -backend-config=backend.hcl + Scripts/grafana-tofu.sh plan -var-file=terraform.tfvars + +Local syntax check: + Scripts/grafana-tofu.sh init -backend=false + Scripts/grafana-tofu.sh validate +EOF +} + +if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then + usage + exit 0 +fi + +mkdir -p "$plugin_cache_dir" +export TF_PLUGIN_CACHE_DIR="$plugin_cache_dir" +export TF_IN_AUTOMATION="${TF_IN_AUTOMATION:-true}" + +exec nix shell --inputs-from "$ROOT" nixpkgs#opentofu -c tofu -chdir="$work_dir" "$@" diff --git a/Scripts/identity-tofu.sh b/Scripts/identity-tofu.sh new file mode 100755 index 0000000..882717c --- /dev/null +++ b/Scripts/identity-tofu.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="$( + git rev-parse --show-toplevel 2>/dev/null || { + cd "$(dirname "${BASH_SOURCE[0]}")/.." + pwd + } +)" + +work_dir="${BURROW_IDENTITY_TOFU_DIR:-$ROOT/infra/identity}" +plugin_cache_dir="${BURROW_TOFU_PLUGIN_CACHE_DIR:-$ROOT/.cache/opentofu/plugins}" + +usage() { + cat <<'EOF' +Usage: Scripts/identity-tofu.sh [tofu args...] + +Runs OpenTofu for Burrow Google KMS and Workload Identity Federation resources. +Cloud provider credentials must come from the normal provider environment or a +WIF flow; do not put credentials in backend config. + +Examples: + Scripts/identity-tofu.sh init -backend-config=backend.hcl + Scripts/identity-tofu.sh plan -var-file=terraform.tfvars + +Local syntax check: + Scripts/identity-tofu.sh init -backend=false + Scripts/identity-tofu.sh validate +EOF +} + +if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then + usage + exit 0 +fi + +mkdir -p "$plugin_cache_dir" +export TF_PLUGIN_CACHE_DIR="$plugin_cache_dir" +export TF_IN_AUTOMATION="${TF_IN_AUTOMATION:-true}" + +exec nix shell --inputs-from "$ROOT" nixpkgs#opentofu -c tofu -chdir="$work_dir" "$@" diff --git a/Scripts/openbao-tofu.sh b/Scripts/openbao-tofu.sh new file mode 100755 index 0000000..96f8d87 --- /dev/null +++ b/Scripts/openbao-tofu.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="$( + git rev-parse --show-toplevel 2>/dev/null || { + cd "$(dirname "${BASH_SOURCE[0]}")/.." + pwd + } +)" + +work_dir="${BURROW_OPENBAO_TOFU_DIR:-$ROOT/infra/openbao}" +plugin_cache_dir="${BURROW_TOFU_PLUGIN_CACHE_DIR:-$ROOT/.cache/opentofu/plugins}" + +usage() { + cat <<'EOF' +Usage: Scripts/openbao-tofu.sh [tofu args...] + +Runs OpenTofu for Burrow OpenBao cloud seal and OpenBao API configuration. The +Vault/OpenBao provider reads VAULT_TOKEN from the environment when managing +OpenBao mounts, policies, or auth backends. + +Examples: + Scripts/openbao-tofu.sh init -backend-config=backend.hcl + Scripts/openbao-tofu.sh plan -var-file=terraform.tfvars + +Local syntax check: + Scripts/openbao-tofu.sh init -backend=false + Scripts/openbao-tofu.sh validate +EOF +} + +if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then + usage + exit 0 +fi + +mkdir -p "$plugin_cache_dir" +export TF_PLUGIN_CACHE_DIR="$plugin_cache_dir" +export TF_IN_AUTOMATION="${TF_IN_AUTOMATION:-true}" + +exec nix shell --inputs-from "$ROOT" nixpkgs#opentofu -c tofu -chdir="$work_dir" "$@" diff --git a/Scripts/package/bootstrap-native-daemon.sh b/Scripts/package/bootstrap-native-daemon.sh new file mode 100755 index 0000000..2188e20 --- /dev/null +++ b/Scripts/package/bootstrap-native-daemon.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +set -euo pipefail + +apply=0 +prefer_packagekit=1 + +usage() { + cat <<'EOF' +Usage: Scripts/package/bootstrap-native-daemon.sh [--apply] [--no-packagekit] + +Detects the host package manager and prints, or with --apply runs, the native +install command for the Burrow daemon package. This is the host-side bootstrap +equivalent the Flatpak GUI can point users at when PackageKit is unavailable. + +This assumes the Burrow native repository for the detected package manager is +already configured. Repository setup should be explicit because it establishes +package trust roots. +EOF +} + +while [[ "$#" -gt 0 ]]; do + case "$1" in + --apply) + apply=1 + ;; + --no-packagekit) + prefer_packagekit=0 + ;; + -h|--help) + usage + exit 0 + ;; + *) + echo "unknown argument: $1" >&2 + exit 64 + ;; + esac + shift +done + +run_or_print() { + if [[ "$apply" == "1" ]]; then + "$@" + else + printf '%q ' "$@" + printf '\n' + fi +} + +if [[ "$prefer_packagekit" == "1" ]] && command -v pkcon >/dev/null 2>&1; then + run_or_print pkcon install burrow + exit 0 +fi + +if command -v apt-get >/dev/null 2>&1; then + run_or_print sudo apt-get install burrow +elif command -v dnf >/dev/null 2>&1; then + run_or_print sudo dnf install burrow +elif command -v zypper >/dev/null 2>&1; then + run_or_print sudo zypper install burrow +elif command -v pacman >/dev/null 2>&1; then + run_or_print sudo pacman -S burrow +elif command -v apk >/dev/null 2>&1; then + run_or_print sudo apk add burrow +elif command -v xbps-install >/dev/null 2>&1; then + run_or_print sudo xbps-install -S burrow +elif command -v eopkg >/dev/null 2>&1; then + run_or_print sudo eopkg install burrow +elif command -v emerge >/dev/null 2>&1; then + run_or_print sudo emerge --ask net-vpn/burrow +elif command -v swupd >/dev/null 2>&1; then + run_or_print sudo swupd bundle-add burrow +elif command -v nix >/dev/null 2>&1; then + run_or_print nix profile install git+https://git.burrow.net/hackclub/burrow +else + echo "No supported native package manager found. Install Burrow through DEB, RPM, pacman, AUR, Flatpak GUI plus daemon package, or the NixOS flake." >&2 + exit 69 +fi diff --git a/Scripts/package/build-repositories.sh b/Scripts/package/build-repositories.sh new file mode 100755 index 0000000..05f5656 --- /dev/null +++ b/Scripts/package/build-repositories.sh @@ -0,0 +1,248 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root="$( + git rev-parse --show-toplevel 2>/dev/null || { + cd "$(dirname "${BASH_SOURCE[0]}")/../.." + pwd + } +)" + +input_dir="${BURROW_PACKAGE_INPUT_DIR:-${repo_root}/dist/packages}" +output_dir="${BURROW_PACKAGE_REPOSITORY_DIR:-${repo_root}/publish/repositories}" +channel="${BURROW_PACKAGE_CHANNEL:-stable}" +suite="${BURROW_APT_SUITE:-stable}" +component="${BURROW_APT_COMPONENT:-main}" +apt_arch="${BURROW_APT_ARCH:-${BURROW_PACKAGE_ARCH:-amd64}}" +rpm_arch="${BURROW_RPM_ARCH:-x86_64}" +pacman_arch="${BURROW_PACMAN_ARCH:-x86_64}" +repo_name="${BURROW_ARCH_REPO_NAME:-burrow}" +generic_kms_public_key_pem="${BURROW_PACKAGE_REPO_KMS_PUBLIC_KEY_PEM:-}" +generic_kms_key="${BURROW_PACKAGE_REPO_KMS_KEY:-}" +apt_kms_public_key_pem="${BURROW_APT_REPO_KMS_PUBLIC_KEY_PEM:-$generic_kms_public_key_pem}" +apt_kms_key="${BURROW_APT_REPO_KMS_KEY:-${generic_kms_key:-package-apt-repository}}" +rpm_kms_public_key_pem="${BURROW_RPM_REPO_KMS_PUBLIC_KEY_PEM:-$generic_kms_public_key_pem}" +rpm_kms_key="${BURROW_RPM_REPO_KMS_KEY:-${generic_kms_key:-package-rpm-repository}}" +pacman_kms_public_key_pem="${BURROW_PACMAN_REPO_KMS_PUBLIC_KEY_PEM:-$generic_kms_public_key_pem}" +pacman_kms_key="${BURROW_PACMAN_REPO_KMS_KEY:-${generic_kms_key:-package-pacman-repository}}" + +usage() { + cat <<'EOF' +Usage: Scripts/package/build-repositories.sh [apt|rpm|arch|keys|all] + +Builds native Linux package repositories from existing package artifacts. + +Inputs: + BURROW_PACKAGE_INPUT_DIR directory containing .deb, .rpm, and .pkg.tar.* files + BURROW_PACKAGE_REPOSITORY_DIR output directory, default publish/repositories + BURROW_APT_REPO_KMS_PUBLIC_KEY_PEM Google KMS public key PEM for APT OpenPGP signatures + BURROW_APT_REPO_KMS_KEY Google KMS key name for APT signatures + BURROW_RPM_REPO_KMS_PUBLIC_KEY_PEM Google KMS public key PEM for RPM repository signatures + BURROW_RPM_REPO_KMS_KEY Google KMS key name for RPM repository signatures + BURROW_PACMAN_REPO_KMS_PUBLIC_KEY_PEM Google KMS public key PEM for pacman signatures + BURROW_PACMAN_REPO_KMS_KEY Google KMS key name for pacman signatures + BURROW_PACKAGE_REPO_KMS_PUBLIC_KEY_PEM fallback public key PEM for all formats + BURROW_PACKAGE_REPO_KMS_KEY fallback KMS key name for all formats + BURROW_KMS_KEYRING/BURROW_KMS_LOCATION/BURROW_KMS_VERSION/GOOGLE_CLOUD_PROJECT + +The repository metadata is signed with Google KMS-backed OpenPGP detached +signatures when each format's KMS public key and key name are configured. +EOF +} + +if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then + usage + exit 0 +fi + +mode="${1:-all}" + +sha256_file() { + local file="$1" + if command -v shasum >/dev/null 2>&1; then + shasum -a 256 "$file" > "${file}.sha256" + else + sha256sum "$file" > "${file}.sha256" + fi +} + +sign_file() { + local file="$1" + local output="${2:-${file}.sig}" + local armor="${3:-0}" + local kms_key="$4" + local kms_public_key_pem="$5" + if [[ -z "$kms_public_key_pem" || -z "$kms_key" ]]; then + echo "warning: KMS OpenPGP signing disabled for ${file}; set the ${file} repository KMS public key and key name" >&2 + return 0 + fi + args=( + "${repo_root}/Scripts/package/google-kms-openpgp.py" + detach-sign + --public-key-pem "$kms_public_key_pem" + --kms-key "$kms_key" + --input "$file" + --output "$output" + ) + if [[ "$armor" == "1" ]]; then + args+=(--armor) + fi + "${args[@]}" +} + +write_public_key() { + local name="$1" + local kms_key="$2" + local kms_public_key_pem="$3" + local user_id="$4" + local output="${output_dir}/keys/${name}.asc" + + if [[ -z "$kms_public_key_pem" || -z "$kms_key" ]]; then + echo "warning: KMS OpenPGP public key export disabled for ${name}; set the repository KMS public key and key name" >&2 + return 0 + fi + + mkdir -p "$(dirname "$output")" + "${repo_root}/Scripts/package/google-kms-openpgp.py" \ + public-key \ + --public-key-pem "$kms_public_key_pem" \ + --kms-key "$kms_key" \ + --user-id "$user_id" \ + --output "$output" \ + --armor +} + +write_release_file() { + local release_path="$1" + local dist_dir="$2" + local now + now="$(LC_ALL=C date -u '+%a, %d %b %Y %H:%M:%S +0000')" + { + printf 'Origin: Burrow\n' + printf 'Label: Burrow\n' + printf 'Suite: %s\n' "$suite" + printf 'Codename: %s\n' "$suite" + printf 'Date: %s\n' "$now" + printf 'Architectures: %s\n' "$apt_arch" + printf 'Components: %s\n' "$component" + printf 'Description: Burrow native package repository\n' + printf 'SHA256:\n' + ( + cd "$dist_dir" + find . -type f ! -name Release -print | LC_ALL=C sort | while read -r file; do + clean="${file#./}" + sum="$(sha256sum "$clean" | awk '{print $1}')" + size="$(wc -c < "$clean" | tr -d ' ')" + printf ' %s %s %s\n' "$sum" "$size" "$clean" + done + ) + } > "$release_path" +} + +build_apt() { + local root binary_dir pool_dir release_dir release_file + root="${output_dir}/apt" + pool_dir="${root}/pool/${component}/b/burrow" + binary_dir="${root}/dists/${suite}/${component}/binary-${apt_arch}" + release_dir="${root}/dists/${suite}" + mkdir -p "$pool_dir" "$binary_dir" "$release_dir" + + find "$input_dir" -type f -name '*.deb' -exec cp {} "$pool_dir/" \; 2>/dev/null || true + if ! find "$pool_dir" -type f -name '*.deb' -print -quit | grep -q .; then + echo "warning: no .deb packages found under ${input_dir}; apt repository contains README only" >&2 + printf 'Place Burrow .deb artifacts in this repository pool before publishing.\n' > "${root}/README.txt" + return 0 + fi + if ! command -v dpkg-scanpackages >/dev/null 2>&1; then + echo "error: dpkg-scanpackages is required to build the apt repository" >&2 + exit 127 + fi + + ( + cd "$root" + dpkg-scanpackages --arch "$apt_arch" "pool/${component}" /dev/null > "dists/${suite}/${component}/binary-${apt_arch}/Packages" + gzip -9cn "dists/${suite}/${component}/binary-${apt_arch}/Packages" > "dists/${suite}/${component}/binary-${apt_arch}/Packages.gz" + ) + release_file="${release_dir}/Release" + write_release_file "$release_file" "$release_dir" + sign_file "$release_file" "${release_file}.gpg" 1 "$apt_kms_key" "$apt_kms_public_key_pem" + sha256_file "$release_file" +} + +build_rpm() { + local root repomd + root="${output_dir}/rpm/${channel}/${rpm_arch}" + mkdir -p "$root" + find "$input_dir" -type f -name '*.rpm' -exec cp {} "$root/" \; 2>/dev/null || true + if ! find "$root" -maxdepth 1 -type f -name '*.rpm' -print -quit | grep -q .; then + echo "warning: no .rpm packages found under ${input_dir}; rpm repository contains README only" >&2 + printf 'Place Burrow .rpm artifacts in this directory before publishing.\n' > "${root}/README.txt" + return 0 + fi + if ! command -v createrepo_c >/dev/null 2>&1; then + echo "error: createrepo_c is required to build the rpm repository" >&2 + exit 127 + fi + createrepo_c "$root" + repomd="${root}/repodata/repomd.xml" + sign_file "$repomd" "${repomd}.asc" 1 "$rpm_kms_key" "$rpm_kms_public_key_pem" + sha256_file "$repomd" +} + +build_arch() { + local root db + root="${output_dir}/arch/${repo_name}/${pacman_arch}" + mkdir -p "$root" + find "$input_dir" -type f \( -name '*.pkg.tar.zst' -o -name '*.pkg.tar.xz' -o -name '*.pkg.tar.gz' \) -exec cp {} "$root/" \; 2>/dev/null || true + if ! find "$root" -maxdepth 1 -type f -name '*.pkg.tar.*' -print -quit | grep -q .; then + echo "warning: no Arch packages found under ${input_dir}; pacman repository contains README only" >&2 + printf 'Place Burrow .pkg.tar.* artifacts in this directory before publishing.\n' > "${root}/README.txt" + return 0 + fi + if ! command -v repo-add >/dev/null 2>&1; then + echo "error: repo-add is required to build the Arch repository" >&2 + exit 127 + fi + ( + cd "$root" + repo-add "${repo_name}.db.tar.gz" ./*.pkg.tar.* + ) + db="${root}/${repo_name}.db.tar.gz" + sign_file "$db" "${db}.sig" 0 "$pacman_kms_key" "$pacman_kms_public_key_pem" + find "$root" -maxdepth 1 -type f -name '*.pkg.tar.*' ! -name '*.sig' -print | while read -r package; do + sign_file "$package" "${package}.sig" 0 "$pacman_kms_key" "$pacman_kms_public_key_pem" + done + sha256_file "$db" +} + +build_keys() { + write_public_key "burrow-package-apt-repository" "$apt_kms_key" "$apt_kms_public_key_pem" "Burrow APT Package Repository " + write_public_key "burrow-package-rpm-repository" "$rpm_kms_key" "$rpm_kms_public_key_pem" "Burrow RPM Package Repository " + write_public_key "burrow-package-pacman-repository" "$pacman_kms_key" "$pacman_kms_public_key_pem" "Burrow pacman Package Repository " +} + +mkdir -p "$output_dir" +case "$mode" in + apt) + build_apt + ;; + rpm) + build_rpm + ;; + arch) + build_arch + ;; + keys) + build_keys + ;; + all) + build_keys + build_apt + build_rpm + build_arch + ;; + *) + echo "unknown repository mode: ${mode}" >&2 + exit 64 + ;; +esac diff --git a/Scripts/package/google-kms-openpgp.py b/Scripts/package/google-kms-openpgp.py new file mode 100755 index 0000000..c349069 --- /dev/null +++ b/Scripts/package/google-kms-openpgp.py @@ -0,0 +1,313 @@ +#!/usr/bin/env python3 +"""Create OpenPGP public keys and detached signatures backed by Google KMS. + +This intentionally implements only the narrow RSA/SHA-256 subset Burrow needs +for Linux package repository metadata. The private key lives in Google Cloud KMS; +this script builds OpenPGP packets locally and asks KMS to produce the RSA +signature value. +""" + +from __future__ import annotations + +import argparse +import base64 +import binascii +import hashlib +import os +import struct +import subprocess +import sys +import tempfile +import time +from pathlib import Path + + +RSA_PUBLIC_KEY_ALGO = 1 +SHA256_HASH_ALGO = 8 + + +def parse_der_length(data: bytes, offset: int) -> tuple[int, int]: + first = data[offset] + offset += 1 + if first < 0x80: + return first, offset + count = first & 0x7F + if count == 0 or count > 4: + raise ValueError("unsupported DER length") + value = int.from_bytes(data[offset : offset + count], "big") + return value, offset + count + + +def parse_der_tlv(data: bytes, offset: int, expected_tag: int | None = None) -> tuple[int, bytes, int]: + tag = data[offset] + offset += 1 + length, offset = parse_der_length(data, offset) + value = data[offset : offset + length] + if len(value) != length: + raise ValueError("truncated DER value") + if expected_tag is not None and tag != expected_tag: + raise ValueError(f"expected DER tag {expected_tag:#x}, got {tag:#x}") + return tag, value, offset + length + + +def pem_to_der(pem: bytes) -> bytes: + lines = [ + line.strip() + for line in pem.splitlines() + if line and not line.startswith(b"-----") + ] + return base64.b64decode(b"".join(lines)) + + +def parse_rsa_public_key_from_pem(path: Path) -> tuple[int, int]: + der = pem_to_der(path.read_bytes()) + _, spki, end = parse_der_tlv(der, 0, 0x30) + if end != len(der): + raise ValueError("trailing data after SubjectPublicKeyInfo") + _, _alg, offset = parse_der_tlv(spki, 0, 0x30) + _, bit_string, offset = parse_der_tlv(spki, offset, 0x03) + if offset != len(spki): + raise ValueError("trailing data after SPKI bit string") + if not bit_string or bit_string[0] != 0: + raise ValueError("unsupported SPKI bit string") + rsa_der = bit_string[1:] + _, rsa_seq, end = parse_der_tlv(rsa_der, 0, 0x30) + if end != len(rsa_der): + raise ValueError("trailing data after RSA public key") + _, n_bytes, offset = parse_der_tlv(rsa_seq, 0, 0x02) + _, e_bytes, offset = parse_der_tlv(rsa_seq, offset, 0x02) + if offset != len(rsa_seq): + raise ValueError("trailing data after RSA integers") + return int.from_bytes(n_bytes, "big"), int.from_bytes(e_bytes, "big") + + +def packet_header(tag: int, length: int) -> bytes: + if length < 192: + return bytes([0xC0 | tag, length]) + if length < 8384: + length -= 192 + return bytes([0xC0 | tag, (length >> 8) + 192, length & 0xFF]) + return bytes([0xC0 | tag, 0xFF]) + struct.pack(">I", length) + + +def old_packet_header(tag: int, length: int) -> bytes: + if length > 0xFFFF: + raise ValueError("old-format two-octet packet length exceeded") + return bytes([(tag << 2) | 1]) + struct.pack(">H", length) + + +def mpi(value: int) -> bytes: + if value < 0: + raise ValueError("MPI value must be non-negative") + raw = value.to_bytes(max(1, (value.bit_length() + 7) // 8), "big") + return struct.pack(">H", value.bit_length()) + raw.lstrip(b"\x00") + + +def subpacket(kind: int, body: bytes) -> bytes: + payload = bytes([kind]) + body + length = len(payload) + if length < 192: + return bytes([length]) + payload + if length < 8384: + length -= 192 + return bytes([(length >> 8) + 192, length & 0xFF]) + payload + return b"\xff" + struct.pack(">I", length) + payload + + +def public_key_body(n: int, e: int, created_at: int) -> bytes: + return ( + b"\x04" + + struct.pack(">I", created_at) + + bytes([RSA_PUBLIC_KEY_ALGO]) + + mpi(n) + + mpi(e) + ) + + +def fingerprint(public_body: bytes) -> bytes: + return hashlib.sha1(old_packet_header(6, len(public_body)) + public_body).digest() + + +def armor(kind: str, body: bytes) -> str: + b64 = base64.b64encode(body).decode("ascii") + crc = crc24(body) + checksum = base64.b64encode(crc.to_bytes(3, "big")).decode("ascii") + lines = [f"-----BEGIN PGP {kind}-----", ""] + lines.extend(b64[i : i + 64] for i in range(0, len(b64), 64)) + lines.append(f"={checksum}") + lines.append(f"-----END PGP {kind}-----") + return "\n".join(lines) + "\n" + + +def crc24(data: bytes) -> int: + crc = 0xB704CE + for octet in data: + crc ^= octet << 16 + for _ in range(8): + crc <<= 1 + if crc & 0x1000000: + crc ^= 0x1864CFB + return crc & 0xFFFFFF + + +def kms_sign(payload: bytes, args: argparse.Namespace) -> bytes: + with tempfile.TemporaryDirectory(prefix="burrow-kms-openpgp.") as tmp: + input_path = Path(tmp) / "payload" + signature_path = Path(tmp) / "signature.b64" + input_path.write_bytes(payload) + command = [ + "gcloud", + "kms", + "asymmetric-sign", + "--location", + args.kms_location, + "--keyring", + args.kms_keyring, + "--key", + args.kms_key, + "--version", + args.kms_version, + "--digest-algorithm", + "sha256", + "--input-file", + str(input_path), + "--signature-file", + str(signature_path), + ] + if args.gcloud_project: + command.extend(["--project", args.gcloud_project]) + subprocess.run(command, check=True) + return base64.b64decode(signature_path.read_text(encoding="utf-8").strip()) + + +def signature_packet( + signed_payload: bytes, + public_body: bytes, + sig_type: int, + created_at: int, + args: argparse.Namespace, +) -> bytes: + fpr = fingerprint(public_body) + key_id = fpr[-8:] + hashed = b"".join( + [ + subpacket(2, struct.pack(">I", created_at)), + subpacket(33, b"\x04" + fpr), + ] + ) + unhashed = subpacket(16, key_id) + sig_data = ( + b"\x04" + + bytes([sig_type, RSA_PUBLIC_KEY_ALGO, SHA256_HASH_ALGO]) + + struct.pack(">H", len(hashed)) + + hashed + ) + trailer = b"\x04\xff" + struct.pack(">I", len(sig_data)) + to_hash = signed_payload + sig_data + trailer + digest = hashlib.sha256(to_hash).digest() + signature = kms_sign(to_hash, args) + body = ( + sig_data + + struct.pack(">H", len(unhashed)) + + unhashed + + digest[:2] + + mpi(int.from_bytes(signature, "big")) + ) + return packet_header(2, len(body)) + body + + +def public_key_command(args: argparse.Namespace) -> int: + created_at = args.created_at or int(time.time()) + n, e = parse_rsa_public_key_from_pem(Path(args.public_key_pem)) + public_body = public_key_body(n, e, created_at) + public_packet = packet_header(6, len(public_body)) + public_body + uid = args.user_id.encode("utf-8") + uid_packet = packet_header(13, len(uid)) + uid + uid_signed_payload = ( + old_packet_header(6, len(public_body)) + + public_body + + b"\xb4" + + struct.pack(">I", len(uid)) + + uid + ) + cert_packet = signature_packet( + uid_signed_payload, + public_body, + sig_type=0x13, + created_at=created_at, + args=args, + ) + key = public_packet + uid_packet + cert_packet + output = Path(args.output) + if args.armor: + output.write_text(armor("PUBLIC KEY BLOCK", key), encoding="utf-8") + else: + output.write_bytes(key) + return 0 + + +def detach_sign_command(args: argparse.Namespace) -> int: + created_at = args.created_at or int(time.time()) + n, e = parse_rsa_public_key_from_pem(Path(args.public_key_pem)) + public_body = public_key_body(n, e, args.key_created_at) + payload = Path(args.input).read_bytes() + sig_type = 0x01 if args.text else 0x00 + packet = signature_packet(payload, public_body, sig_type, created_at, args) + output = Path(args.output) + if args.armor: + output.write_text(armor("SIGNATURE", packet), encoding="utf-8") + else: + output.write_bytes(packet) + return 0 + + +def add_kms_args(parser: argparse.ArgumentParser) -> None: + parser.add_argument("--kms-location", default=os.environ.get("BURROW_KMS_LOCATION", "global")) + parser.add_argument("--kms-keyring", default=os.environ.get("BURROW_KMS_KEYRING", "burrow-identity")) + parser.add_argument("--kms-key", required=not os.environ.get("BURROW_KMS_KEY"), default=os.environ.get("BURROW_KMS_KEY")) + parser.add_argument("--kms-version", default=os.environ.get("BURROW_KMS_VERSION", "1")) + parser.add_argument("--gcloud-project", default=os.environ.get("GOOGLE_CLOUD_PROJECT")) + + +def build_parser() -> argparse.ArgumentParser: + parser = argparse.ArgumentParser(description=__doc__) + subcommands = parser.add_subparsers(dest="command", required=True) + + public_key = subcommands.add_parser("public-key") + public_key.add_argument("--public-key-pem", required=True) + public_key.add_argument("--user-id", default="Burrow Package Repository ") + public_key.add_argument("--output", required=True) + public_key.add_argument("--armor", action="store_true") + public_key.add_argument("--created-at", type=int) + add_kms_args(public_key) + public_key.set_defaults(func=public_key_command) + + detach = subcommands.add_parser("detach-sign") + detach.add_argument("--public-key-pem", required=True) + detach.add_argument("--key-created-at", type=int, default=1704067200) + detach.add_argument("--input", required=True) + detach.add_argument("--output", required=True) + detach.add_argument("--armor", action="store_true") + detach.add_argument("--text", action="store_true") + detach.add_argument("--created-at", type=int) + add_kms_args(detach) + detach.set_defaults(func=detach_sign_command) + + return parser + + +def main() -> int: + parser = build_parser() + args = parser.parse_args() + try: + return args.func(args) + except subprocess.CalledProcessError as exc: + print(f"gcloud signing failed: {exc}", file=sys.stderr) + return exc.returncode or 1 + except Exception as exc: + print(f"error: {exc}", file=sys.stderr) + return 1 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/Scripts/provision-forgejo-nsc.sh b/Scripts/provision-forgejo-nsc.sh index b31de21..b82757c 100755 --- a/Scripts/provision-forgejo-nsc.sh +++ b/Scripts/provision-forgejo-nsc.sh @@ -23,7 +23,7 @@ Options: --no-refresh-token Reuse intake/forgejo_nsc_token.txt if it already exists. --token-name Forgejo PAT name prefix (default: forgejo-nsc) --contact-user Forgejo username used for PAT creation (default: contact) - --scope-owner Forgejo org/user owner for the default NSC scope (default: burrow) + --scope-owner Forgejo org/user owner for the default NSC scope (default: hackclub) --scope-name Forgejo repository name for the default NSC scope (default: burrow) -h, --help Show this help text. EOF @@ -36,7 +36,7 @@ KNOWN_HOSTS_FILE="${BURROW_FORGE_KNOWN_HOSTS_FILE:-${HOME}/.cache/burrow/forge-k REFRESH_TOKEN=1 TOKEN_NAME_PREFIX="${FORGEJO_PAT_NAME:-forgejo-nsc}" CONTACT_USER="${FORGEJO_CONTACT_USER:-contact}" -SCOPE_OWNER="${FORGEJO_SCOPE_OWNER:-burrow}" +SCOPE_OWNER="${FORGEJO_SCOPE_OWNER:-hackclub}" SCOPE_NAME="${FORGEJO_SCOPE_NAME:-burrow}" BURROW_FLAKE_TMPDIRS=() @@ -136,7 +136,20 @@ autoscaler_src="${REPO_ROOT}/services/forgejo-nsc/deploy/autoscaler.yaml" if [[ "${REFRESH_TOKEN}" -eq 1 || ! -s "${token_file}" ]]; then "${NSC_BIN}" auth check-login --duration 20m >/dev/null - "${NSC_BIN}" auth generate-dev-token --output_to "${token_file}" >/dev/null + token_name="${TOKEN_NAME_PREFIX}-namespace-$(date -u +%Y%m%dT%H%M%SZ)" + "${NSC_BIN}" token create \ + --name "${token_name}" \ + --description "Burrow Forgejo Namespace runner dispatcher" \ + --expires_in "${NSC_TOKEN_EXPIRES_IN:-30d}" \ + --grant '{"resource_type":"instance","resource_id":"*","actions":["create","destroy","dial_host","exec","get","list","refresh","ssh","wait"]}' \ + --grant '{"resource_type":"instance/ingress","resource_id":"*","actions":["list","register"]}' \ + --grant '{"resource_type":"instance/notification","resource_id":"*","actions":["list"]}' \ + --grant '{"resource_type":"instance/o11y/logs","resource_id":"*","actions":["get"]}' \ + --grant '{"resource_type":"cache/httpcache","resource_id":"*","actions":["ensure","read","write"]}' \ + --grant '{"resource_type":"bazel/cache","resource_id":"*","actions":["ensure"]}' \ + --grant '{"resource_type":"artifact","resource_id":"*","actions":["create","resolve","list"]}' \ + --token_file "${token_file}" \ + --output json >/dev/null chmod 600 "${token_file}" fi @@ -155,6 +168,7 @@ forgejo_pat="$( -o StrictHostKeyChecking=accept-new \ "${HOST}" \ "set -euo pipefail; forgejo_bin=\$(systemctl show -p ExecStart forgejo.service --value | sed -E 's/^\\{ path=([^ ;]+).*/\\1/'); sudo -u forgejo \"\${forgejo_bin}\" --config /var/lib/forgejo/custom/conf/app.ini --custom-path /var/lib/forgejo/custom --work-path /var/lib/forgejo admin user generate-access-token --username '${CONTACT_USER}' --scopes all --raw --token-name '${token_name}'" \ + | awk 'NF { line = $0 } END { print line }' \ | tr -d '\r\n' )" diff --git a/Scripts/release/google-kms-openssl-dgst-shim.sh b/Scripts/release/google-kms-openssl-dgst-shim.sh new file mode 100755 index 0000000..4925386 --- /dev/null +++ b/Scripts/release/google-kms-openssl-dgst-shim.sh @@ -0,0 +1,196 @@ +#!/usr/bin/env bash +set -euo pipefail + +real_openssl="${BURROW_REAL_OPENSSL:-openssl}" +gcloud_bin="${BURROW_GCLOUD_BIN:-gcloud}" +original_args=("$@") + +exec_real_openssl() { + exec "$real_openssl" "$@" +} + +truthy() { + case "${1:-}" in + 1|true|TRUE|True|yes|YES|Yes|y|Y|on|ON|On) return 0 ;; + *) return 1 ;; + esac +} + +parse_pkcs11_key_name() { + local uri="$1" + local value + value="${uri#*;object=}" + if [[ "$value" != "$uri" ]]; then + printf '%s\n' "${value%%;*}" + return 0 + fi + value="${uri#*;id=}" + if [[ "$value" != "$uri" ]]; then + printf '%s\n' "${value%%;*}" + return 0 + fi + return 1 +} + +select_single_enabled_version() { + local project_id="$1" + local kms_location="$2" + local kms_keyring_name="$3" + local crypto_key_name="$4" + local versions=() + local version + + while IFS= read -r version; do + [[ -n "$version" ]] && versions+=("$version") + done < <( + "$gcloud_bin" kms keys versions list \ + --project="$project_id" \ + --location="$kms_location" \ + --keyring="$kms_keyring_name" \ + --key="$crypto_key_name" \ + --filter=state=ENABLED \ + --format='value(name)' + ) + if [[ "${#versions[@]}" -ne 1 || -z "${versions[0]:-}" ]]; then + echo "error: Google KMS crypto key ${crypto_key_name} has ${#versions[@]} ENABLED versions; set BURROW_GCP_KMS_ACTIVE_CRYPTO_KEY_VERSION" >&2 + return 1 + fi + printf '%s\n' "${versions[0]##*/}" +} + +if [[ "${1:-}" != "dgst" ]]; then + exec_real_openssl "${original_args[@]}" +fi + +if ! truthy "${BURROW_APPLE_PKCS11_SIGN_WITH_GCLOUD:-true}"; then + exec_real_openssl "${original_args[@]}" +fi + +shift +digest_algorithm="" +signature_file="" +input_file="" +sign_uri="" + +while [[ $# -gt 0 ]]; do + case "$1" in + -sha256) + digest_algorithm="sha256" + shift + ;; + -sign) + [[ $# -ge 2 ]] || { + echo "error: openssl dgst shim received -sign without a key URI" >&2 + exit 2 + } + sign_uri="$2" + shift 2 + ;; + -out) + [[ $# -ge 2 ]] || { + echo "error: openssl dgst shim received -out without a path" >&2 + exit 2 + } + signature_file="$2" + shift 2 + ;; + -provider|-passin) + [[ $# -ge 2 ]] || { + echo "error: openssl dgst shim received $1 without a value" >&2 + exit 2 + } + shift 2 + ;; + -*) + exec_real_openssl "${original_args[@]}" + ;; + *) + input_file="$1" + shift + ;; + esac +done + +if [[ "$digest_algorithm" != "sha256" || "$sign_uri" != pkcs11:* ]]; then + exec_real_openssl "${original_args[@]}" +fi +if [[ -z "$signature_file" || -z "$input_file" ]]; then + echo "error: openssl dgst shim requires -out and an input file" >&2 + exit 2 +fi +if [[ ! -f "$input_file" ]]; then + echo "error: openssl dgst shim input file does not exist: $input_file" >&2 + exit 1 +fi +command -v "$gcloud_bin" >/dev/null 2>&1 || { + echo "error: gcloud is required for Google KMS direct signing; set BURROW_GCLOUD_BIN" >&2 + exit 1 +} +command -v python3 >/dev/null 2>&1 || { + echo "error: python3 is required to decode Google KMS signatures" >&2 + exit 1 +} + +crypto_key="${BURROW_GCP_KMS_ACTIVE_CRYPTO_KEY:-}" +if [[ -z "$crypto_key" ]]; then + crypto_key="$(parse_pkcs11_key_name "$sign_uri" || true)" +fi +if [[ -z "$crypto_key" ]]; then + echo "error: BURROW_GCP_KMS_ACTIVE_CRYPTO_KEY or a pkcs11 object selector is required" >&2 + exit 1 +fi + +key_version="${BURROW_GCP_KMS_ACTIVE_CRYPTO_KEY_VERSION:-}" +key_ring="${BURROW_GCP_KMS_KEY_RING:-${GOOGLE_KMS_KEY_RING:-projects/${GOOGLE_CLOUD_PROJECT:-project-88c23ce9-918a-470a-b33}/locations/${BURROW_KMS_LOCATION:-global}/keyRings/${BURROW_KMS_KEYRING:-burrow-identity}}}" +project_id="${GOOGLE_CLOUD_PROJECT:-project-88c23ce9-918a-470a-b33}" +kms_location="" +kms_keyring_name="" +crypto_key_name="" + +if [[ "$crypto_key" =~ ^projects/([^/]+)/locations/([^/]+)/keyRings/([^/]+)/cryptoKeys/([^/]+)/cryptoKeyVersions/([^/]+)$ ]]; then + project_id="${BASH_REMATCH[1]}" + kms_location="${BASH_REMATCH[2]}" + kms_keyring_name="${BASH_REMATCH[3]}" + crypto_key_name="${BASH_REMATCH[4]}" + key_version="${BASH_REMATCH[5]}" +elif [[ "$crypto_key" =~ ^projects/([^/]+)/locations/([^/]+)/keyRings/([^/]+)/cryptoKeys/([^/]+)$ ]]; then + project_id="${BASH_REMATCH[1]}" + kms_location="${BASH_REMATCH[2]}" + kms_keyring_name="${BASH_REMATCH[3]}" + crypto_key_name="${BASH_REMATCH[4]}" +else + if [[ ! "$key_ring" =~ ^projects/([^/]+)/locations/([^/]+)/keyRings/([^/]+)$ ]]; then + echo "error: BURROW_GCP_KMS_KEY_RING must be projects//locations//keyRings/, got: ${key_ring}" >&2 + exit 1 + fi + project_id="${BASH_REMATCH[1]}" + kms_location="${BASH_REMATCH[2]}" + kms_keyring_name="${BASH_REMATCH[3]}" + crypto_key_name="$crypto_key" +fi + +if [[ -z "$key_version" ]]; then + key_version="$(select_single_enabled_version "$project_id" "$kms_location" "$kms_keyring_name" "$crypto_key_name")" +fi + +encoded_signature_file="$(mktemp "${TMPDIR:-/tmp}/burrow-google-kms-signature.XXXXXX")" +trap 'rm -f "$encoded_signature_file"' EXIT +"$gcloud_bin" kms asymmetric-sign \ + --project="$project_id" \ + --location="$kms_location" \ + --keyring="$kms_keyring_name" \ + --key="$crypto_key_name" \ + --version="$key_version" \ + --digest-algorithm="$digest_algorithm" \ + --input-file="$input_file" \ + --signature-file="$encoded_signature_file" \ + --quiet >/dev/null + +python3 - "$encoded_signature_file" "$signature_file" <<'PY' +import pathlib +import sys + +encoded_path = pathlib.Path(sys.argv[1]) +signature_path = pathlib.Path(sys.argv[2]) +signature_path.write_bytes(encoded_path.read_bytes()) +PY diff --git a/Scripts/release/google-kms-pkcs11-materialize.sh b/Scripts/release/google-kms-pkcs11-materialize.sh new file mode 100755 index 0000000..2e0dde8 --- /dev/null +++ b/Scripts/release/google-kms-pkcs11-materialize.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +set -euo pipefail + +emit_env=false +ROOT="$( + git rev-parse --show-toplevel 2>/dev/null || { + cd "$(dirname "${BASH_SOURCE[0]}")/../.." + pwd + } +)" +runtime_dir="${BURROW_GCP_KMS_PKCS11_RUNTIME_DIR:-${RUNNER_TEMP:-${TMPDIR:-/tmp}}/burrow-google-kms-pkcs11-runtime}" +config_file="${BURROW_GCP_KMS_PKCS11_CONFIG:-${KMS_PKCS11_CONFIG:-}}" +config_yaml="${BURROW_GCP_KMS_PKCS11_CONFIG_YAML:-}" +key_ring="${BURROW_GCP_KMS_KEY_RING:-${GOOGLE_KMS_KEY_RING:-projects/${GOOGLE_CLOUD_PROJECT:-project-88c23ce9-918a-470a-b33}/locations/${BURROW_KMS_LOCATION:-global}/keyRings/${BURROW_KMS_KEYRING:-burrow-identity}}}" +token_label="${BURROW_GCP_KMS_PKCS11_TOKEN_LABEL:-${BURROW_PKCS11_TOKEN_LABEL:-burrow-release}}" + +usage() { + cat <<'EOF' +Usage: Scripts/release/google-kms-pkcs11-materialize.sh [--emit-env] + +Materializes optional Google KMS PKCS#11 config YAML into a runner-local file +and emits environment variables consumed by the Apple release signer. +EOF +} + +while [[ $# -gt 0 ]]; do + case "$1" in + --emit-env) + emit_env=true + shift + ;; + -h|--help) + usage + exit 0 + ;; + *) + echo "error: unknown argument $1" >&2 + usage >&2 + exit 2 + ;; + esac +done + +write_config_file() { + local path="$1" + local value="$2" + mkdir -p "$(dirname "$path")" + printf '%s\n' "$value" >"$path" + chmod 600 "$path" +} + +resolve_config_path() { + local path="$1" + if [[ -z "$path" ]]; then + return 1 + fi + if [[ "$path" != /* ]]; then + path="$ROOT/$path" + fi + printf '%s\n' "$path" +} + +env_lines=() +if [[ -z "$config_file" && -n "$config_yaml" ]]; then + config_file="$runtime_dir/pkcs11-config.yaml" + write_config_file "$config_file" "$config_yaml" +fi + +if [[ -z "$config_file" && -n "$key_ring" ]]; then + config_file="$runtime_dir/pkcs11-config.yaml" + write_config_file "$config_file" "--- +tokens: + - key_ring: \"${key_ring}\" + label: \"${token_label}\"" +fi + +if [[ -n "$config_file" ]]; then + config_file="$(resolve_config_path "$config_file")" + if [[ ! -s "$config_file" ]]; then + echo "error: Google KMS PKCS#11 config is missing or empty: $config_file" >&2 + exit 1 + fi + env_lines+=("BURROW_GCP_KMS_PKCS11_CONFIG=$config_file") + env_lines+=("KMS_PKCS11_CONFIG=$config_file") +fi + +if [[ "${#env_lines[@]}" -gt 0 && -n "${GITHUB_ENV:-}" ]]; then + printf '%s\n' "${env_lines[@]}" >>"$GITHUB_ENV" +fi + +if [[ "$emit_env" == "true" && "${#env_lines[@]}" -gt 0 ]]; then + printf 'export %q\n' "${env_lines[@]}" +fi diff --git a/Scripts/releases-tofu.sh b/Scripts/releases-tofu.sh new file mode 100755 index 0000000..0168c5b --- /dev/null +++ b/Scripts/releases-tofu.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="$( + git rev-parse --show-toplevel 2>/dev/null || { + cd "$(dirname "${BASH_SOURCE[0]}")/.." + pwd + } +)" + +work_dir="${BURROW_RELEASES_TOFU_DIR:-$ROOT/infra/releases}" +plugin_cache_dir="${BURROW_TOFU_PLUGIN_CACHE_DIR:-$ROOT/.cache/opentofu/plugins}" + +usage() { + cat <<'EOF' +Usage: Scripts/releases-tofu.sh [tofu args...] + +Runs OpenTofu for Burrow Google Cloud Storage release and package repository +buckets. Cloud provider credentials must come from ADC or Workload Identity +Federation; do not put service-account JSON in this repository. + +Examples: + Scripts/releases-tofu.sh init -backend-config=backend.hcl + Scripts/releases-tofu.sh plan -var-file=terraform.tfvars + +Local syntax check: + Scripts/releases-tofu.sh init -backend=false + Scripts/releases-tofu.sh validate +EOF +} + +if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then + usage + exit 0 +fi + +mkdir -p "$plugin_cache_dir" +export TF_PLUGIN_CACHE_DIR="$plugin_cache_dir" +export TF_IN_AUTOMATION="${TF_IN_AUTOMATION:-true}" + +exec nix shell --inputs-from "$ROOT" nixpkgs#opentofu -c tofu -chdir="$work_dir" "$@" diff --git a/Scripts/resolve-age-identity.sh b/Scripts/resolve-age-identity.sh new file mode 100755 index 0000000..321a0a1 --- /dev/null +++ b/Scripts/resolve-age-identity.sh @@ -0,0 +1,172 @@ +#!/usr/bin/env bash +set -euo pipefail + +identity_is_valid() { + local path="$1" + if [[ -z "$path" || ! -f "$path" || ! -s "$path" ]]; then + return 1 + fi + + chmod 600 "$path" 2>/dev/null || true + if command -v age-keygen >/dev/null 2>&1 && age-keygen -y "$path" >/dev/null 2>&1; then + return 0 + fi + if openssh_private_identity_has_markers "$path"; then + return 0 + fi + if command -v ssh-keygen >/dev/null 2>&1 && ssh-keygen -y -f "$path" >/dev/null 2>&1; then + return 0 + fi + + local header + header="$(LC_ALL=C head -c 80 "$path" 2>/dev/null || true)" + case "$header" in + AGE-SECRET-KEY-*) return 0 ;; + esac + + echo "::warning ::Ignoring invalid age identity candidate at ${path}" >&2 + return 1 +} + +openssh_private_identity_has_markers() { + local path="$1" + local first_line + first_line="$(LC_ALL=C sed -n '1p' "$path" 2>/dev/null || true)" + if [[ "$first_line" != "-----BEGIN OPENSSH PRIVATE KEY-----" ]]; then + return 1 + fi + if LC_ALL=C grep -Fq '\n' "$path" 2>/dev/null; then + return 1 + fi + LC_ALL=C grep -q '^-----END OPENSSH PRIVATE KEY-----$' "$path" 2>/dev/null +} + +candidate_path() { + local path="$1" + if identity_is_valid "$path"; then + printf '%s\n' "$path" + return 0 + fi + return 1 +} + +preferred_home() { + if [[ -n "${RUNNER_HOME:-}" ]]; then + printf '%s\n' "$RUNNER_HOME" + elif [[ -n "${FORGEJO_RUNNER_HOME:-}" ]]; then + printf '%s\n' "$FORGEJO_RUNNER_HOME" + elif [[ -n "${HOME:-}" ]]; then + printf '%s\n' "$HOME" + elif [[ -n "${FORGEJO_RUNNER_WORKDIR:-}" ]]; then + printf '%s\n' "${FORGEJO_RUNNER_WORKDIR}/home" + else + printf '%s\n' "/tmp/forgejo-runner/home" + fi +} + +decode_base64() { + local value="$1" + local path="$2" + if command -v base64 >/dev/null 2>&1; then + if printf '%s' "$value" | base64 -d > "$path" 2>/dev/null; then + return 0 + fi + if printf '%s' "$value" | base64 -D > "$path" 2>/dev/null; then + return 0 + fi + fi + return 1 +} + +materialize_secret() { + local raw="$1" + local home="$2" + local path="${home}/.ssh/age_keystore" + install -d -m 700 "${home}/.ssh" + printf '%s\n' "$raw" > "$path" + perl -0pi -e 's/\r\n?/\n/g' "$path" 2>/dev/null || true + chmod 600 "$path" + if identity_is_valid "$path"; then + printf '%s\n' "$path" + return 0 + fi + + if [[ "$raw" == *"\\n"* ]]; then + printf '%b' "$raw" > "$path" + perl -0pi -e 's/\r\n?/\n/g' "$path" 2>/dev/null || true + chmod 600 "$path" + if identity_is_valid "$path"; then + printf '%s\n' "$path" + return 0 + fi + fi + + if decode_base64 "$raw" "$path"; then + perl -0pi -e 's/\r\n?/\n/g' "$path" 2>/dev/null || true + chmod 600 "$path" + if identity_is_valid "$path"; then + printf '%s\n' "$path" + return 0 + fi + fi + + rm -f "$path" + echo "::warning ::Injected age identity was present but not parseable; trying other candidates" >&2 + return 1 +} + +resolve_from_existing_files() { + local home + home="$(preferred_home)" + + local candidate + while IFS= read -r candidate; do + candidate_path "$candidate" && return 0 + done <&2 +exit 1 diff --git a/Scripts/resolve-forge-ssh-key.sh b/Scripts/resolve-forge-ssh-key.sh new file mode 100755 index 0000000..0ea566b --- /dev/null +++ b/Scripts/resolve-forge-ssh-key.sh @@ -0,0 +1,121 @@ +#!/usr/bin/env bash +set -euo pipefail + +preferred_home() { + if [[ -n "${RUNNER_HOME:-}" ]]; then + printf '%s\n' "$RUNNER_HOME" + elif [[ -n "${FORGEJO_RUNNER_HOME:-}" ]]; then + printf '%s\n' "$FORGEJO_RUNNER_HOME" + elif [[ -n "${HOME:-}" ]]; then + printf '%s\n' "$HOME" + elif [[ -n "${FORGEJO_RUNNER_WORKDIR:-}" ]]; then + printf '%s\n' "${FORGEJO_RUNNER_WORKDIR}/home" + else + printf '%s\n' "/tmp/forgejo-runner/home" + fi +} + +is_ssh_private_key() { + local candidate="$1" + [[ -n "$candidate" && -f "$candidate" && -s "$candidate" ]] || return 1 + chmod 600 "$candidate" 2>/dev/null || true + ssh-keygen -y -f "$candidate" >/dev/null 2>&1 +} + +candidate_path() { + local path="$1" + if is_ssh_private_key "$path"; then + printf '%s\n' "$path" + return 0 + fi + return 1 +} + +decode_base64() { + local value="$1" + local path="$2" + if command -v base64 >/dev/null 2>&1; then + if printf '%s' "$value" | base64 -d > "$path" 2>/dev/null; then + return 0 + fi + if printf '%s' "$value" | base64 -D > "$path" 2>/dev/null; then + return 0 + fi + fi + return 1 +} + +materialize_secret() { + local raw="$1" + local home="$2" + local path="${home}/.ssh/burrow_forge_ed25519" + install -d -m 700 "${home}/.ssh" + + printf '%s\n' "$raw" > "$path" + if candidate_path "$path"; then + return 0 + fi + + if [[ "$raw" == *"\\n"* ]]; then + printf '%b' "$raw" > "$path" + if candidate_path "$path"; then + return 0 + fi + fi + + if decode_base64 "$raw" "$path" && candidate_path "$path"; then + return 0 + fi + + rm -f "$path" + echo "::warning ::Injected Forge SSH key was present but not parseable; trying file candidates" >&2 + return 1 +} + +resolve_key() { + local home + home="$(preferred_home)" + + if [[ -n "${BURROW_FORGE_SSH_KEY:-}" ]]; then + if candidate_path "$BURROW_FORGE_SSH_KEY"; then + return 0 + fi + echo "::error ::BURROW_FORGE_SSH_KEY is set but is not an SSH private key: ${BURROW_FORGE_SSH_KEY}" >&2 + return 1 + fi + + if [[ -n "${AGE_FORGE_SSH_KEY:-}" ]]; then + materialize_secret "$AGE_FORGE_SSH_KEY" "$home" && return 0 + fi + + local candidate + while IFS= read -r candidate; do + candidate_path "$candidate" && return 0 + done <&2 +exit 1 diff --git a/Scripts/run-ios-tailnet-ui-tests.sh b/Scripts/run-ios-tailnet-ui-tests.sh index 5170a1e..2638c39 100755 --- a/Scripts/run-ios-tailnet-ui-tests.sh +++ b/Scripts/run-ios-tailnet-ui-tests.sh @@ -2,7 +2,7 @@ set -euo pipefail repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -bundle_id="${BURROW_UI_TEST_APP_BUNDLE_ID:-com.hackclub.burrow}" +bundle_id="${BURROW_UI_TEST_APP_BUNDLE_ID:-net.burrow.app}" simulator_name="${BURROW_UI_TEST_SIMULATOR_NAME:-iPhone 17 Pro}" simulator_os="${BURROW_UI_TEST_SIMULATOR_OS:-26.4}" simulator_id="${BURROW_UI_TEST_SIMULATOR_ID:-}" diff --git a/Scripts/run-tailnet-connectivity-smoke.sh b/Scripts/run-tailnet-connectivity-smoke.sh index f3053d3..dea2f68 100755 --- a/Scripts/run-tailnet-connectivity-smoke.sh +++ b/Scripts/run-tailnet-connectivity-smoke.sh @@ -2,7 +2,7 @@ set -euo pipefail repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -bundle_id="${BURROW_UI_TEST_APP_BUNDLE_ID:-com.hackclub.burrow}" +bundle_id="${BURROW_UI_TEST_APP_BUNDLE_ID:-net.burrow.app}" smoke_root="${BURROW_TAILNET_SMOKE_ROOT:-/tmp/burrow-tailnet-connectivity}" socket_path="${smoke_root}/burrow.sock" db_path="${smoke_root}/burrow.db" diff --git a/Scripts/seal-release-secrets.sh b/Scripts/seal-release-secrets.sh new file mode 100755 index 0000000..86281ee --- /dev/null +++ b/Scripts/seal-release-secrets.sh @@ -0,0 +1,261 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" + +usage() { + cat <<'EOF' +Usage: Scripts/seal-release-secrets.sh [--source-dir ] [--only ] + +Encrypt Burrow release inputs into the agenix secrets consumed by CI. + +Expected files in --source-dir (default: intake/release): + appstore-key-id.txt + appstore-key-issuer-id.txt + appstore-key.p8 + distribution-cert.p12 + distribution-cert-password.txt + sparkle-eddsa.key + +Pre-composed appstore-connect.env, distribution-signing.env, and sparkle.env +files are also accepted. + +Provisioning profiles are synced from App Store Connect credentials in CI. +The temporary keychain password is always the distribution certificate password. + +Secrets: + all + appstore-connect + distribution-signing + sparkle +EOF +} + +SOURCE_DIR="${BURROW_RELEASE_SECRET_SOURCE_DIR:-${REPO_ROOT}/intake/release}" +ONLY="all" + +while [[ $# -gt 0 ]]; do + case "$1" in + --source-dir) + SOURCE_DIR="${2:?missing value for --source-dir}" + shift 2 + ;; + --only) + ONLY="${2:?missing value for --only}" + shift 2 + ;; + -h|--help) + usage + exit 0 + ;; + *) + echo "unknown option: $1" >&2 + usage >&2 + exit 64 + ;; + esac +done + +case "$ONLY" in + all|appstore-connect|app-store|appstore|distribution-signing|apple-signing|sparkle) ;; + *) + echo "unknown release secret selector: $ONLY" >&2 + usage >&2 + exit 64 + ;; +esac + +require_cmd() { + if ! command -v "$1" >/dev/null 2>&1; then + echo "missing required command: $1" >&2 + exit 1 + fi +} + +require_cmd age +require_cmd nix +require_cmd python3 + +if [[ ! -d "$SOURCE_DIR" ]]; then + echo "release secret source directory does not exist: $SOURCE_DIR" >&2 + exit 1 +fi + +tmpdir="$(mktemp -d)" +cleanup() { + rm -rf "$tmpdir" +} +trap cleanup EXIT + +seal_secret() { + local target="$1" + local source_path="$2" + local required="${3:-required}" + local recipients_file="${tmpdir}/$(basename "${target}").recipients" + + if [[ ! -s "$source_path" ]]; then + if [[ "$required" == "optional" ]]; then + return 0 + fi + echo "required release secret source missing or empty: $source_path" >&2 + exit 1 + fi + + mkdir -p "${REPO_ROOT}/$(dirname "$target")" + nix eval --impure --json --expr "let s = import ${REPO_ROOT}/secrets.nix; in s.\"${target}\".publicKeys" \ + | python3 -c 'import json, sys; [print(item) for item in json.load(sys.stdin)]' \ + > "$recipients_file" + + age -R "$recipients_file" -o "${REPO_ROOT}/${target}" "$source_path" + chmod 600 "${REPO_ROOT}/${target}" + echo "Sealed ${target}" +} + +base64_file() { + python3 -c 'import base64, pathlib, sys; print(base64.b64encode(pathlib.Path(sys.argv[1]).read_bytes()).decode())' "$1" +} + +read_secret_text() { + python3 -c 'import pathlib, sys; sys.stdout.write(pathlib.Path(sys.argv[1]).read_text().strip())' "$1" +} + +base64_text() { + python3 -c 'import base64, sys; print(base64.b64encode(sys.stdin.buffer.read()).decode())' +} + +reject_placeholder() { + local path="$1" + if grep -Eq '^(TODO|PASTE_|REPLACE_|#)' "$path"; then + echo "intake file still contains placeholder text: $path" >&2 + exit 1 + fi +} + +reject_placeholder_text() { + local path="$1" + if grep -Iq . "$path"; then + reject_placeholder "$path" + fi +} + +first_existing() { + local path + for path in "$@"; do + if [[ -s "$path" ]]; then + printf '%s\n' "$path" + return 0 + fi + done + return 1 +} + +compose_appstore_connect_env() { + local direct="${SOURCE_DIR}/appstore-connect.env" + if [[ -s "$direct" ]]; then + printf '%s\n' "$direct" + return 0 + fi + + local key_id_file="${SOURCE_DIR}/appstore-key-id.txt" + local issuer_id_file="${SOURCE_DIR}/appstore-key-issuer-id.txt" + local key_file="${SOURCE_DIR}/appstore-key.p8" + if [[ ! -s "$key_file" ]]; then + echo "required App Store Connect source missing or empty: appstore-key.p8" >&2 + exit 1 + fi + for path in "$key_id_file" "$issuer_id_file" "$key_file"; do + if [[ ! -s "$path" ]]; then + echo "required App Store Connect source missing or empty: $path" >&2 + exit 1 + fi + reject_placeholder_text "$path" + done + + local out="${tmpdir}/appstore-connect.env" + { + printf 'ASC_API_KEY_ID=%s\n' "$(read_secret_text "$key_id_file")" + printf 'ASC_API_ISSUER_ID=%s\n' "$(read_secret_text "$issuer_id_file")" + printf 'ASC_API_KEY_BASE64=%s\n' "$(base64_file "$key_file")" + } > "$out" + printf '%s\n' "$out" +} + +compose_distribution_signing_env() { + local direct="${SOURCE_DIR}/distribution-signing.env" + if [[ -s "$direct" ]]; then + printf '%s\n' "$direct" + return 0 + fi + + local cert_file + cert_file="${SOURCE_DIR}/distribution-cert.p12" + local password_file="${SOURCE_DIR}/distribution-cert-password.txt" + if [[ ! -s "$cert_file" ]]; then + echo "required distribution signing source missing or empty: distribution-cert.p12" >&2 + exit 1 + fi + for path in "$password_file"; do + if [[ ! -s "$path" ]]; then + echo "required distribution signing source missing or empty: $path" >&2 + exit 1 + fi + reject_placeholder_text "$path" + done + + local out="${tmpdir}/distribution-signing.env" + { + printf 'APPLE_SIGNING_CERTIFICATE_BASE64=%s\n' "$(base64_file "$cert_file")" + printf 'APPLE_SIGNING_CERTIFICATE_PASSWORD_BASE64=%s\n' "$(read_secret_text "$password_file" | base64_text)" + } > "$out" + printf '%s\n' "$out" +} + +compose_sparkle_env() { + local direct="${SOURCE_DIR}/sparkle.env" + if [[ -s "$direct" ]]; then + printf '%s\n' "$direct" + return 0 + fi + + local key_file + key_file="${SOURCE_DIR}/sparkle-eddsa.key" + if [[ ! -s "$key_file" ]]; then + return 1 + fi + reject_placeholder_text "$key_file" + + local out="${tmpdir}/sparkle.env" + printf 'SPARKLE_EDDSA_KEY_BASE64=%s\n' "$(base64_file "$key_file")" > "$out" + printf '%s\n' "$out" +} + +case "$ONLY" in + all) + appstore_env="$(compose_appstore_connect_env)" + seal_secret "secrets/apple/appstore-connect.env.age" "$appstore_env" + distribution_env="$(compose_distribution_signing_env)" + seal_secret "secrets/apple/distribution-signing.env.age" "$distribution_env" + if sparkle_env="$(compose_sparkle_env)"; then + seal_secret "secrets/apple/sparkle.env.age" "$sparkle_env" + fi + ;; + appstore-connect|app-store|appstore) + appstore_env="$(compose_appstore_connect_env)" + seal_secret "secrets/apple/appstore-connect.env.age" "$appstore_env" + ;; + distribution-signing|apple-signing) + distribution_env="$(compose_distribution_signing_env)" + seal_secret "secrets/apple/distribution-signing.env.age" "$distribution_env" + ;; + sparkle) + if sparkle_env="$(compose_sparkle_env)"; then + seal_secret "secrets/apple/sparkle.env.age" "$sparkle_env" + else + echo "required Sparkle source missing or empty: sparkle-eddsa.key" >&2 + exit 1 + fi + ;; +esac + +echo "Release secrets are sealed. Commit the .age files and deploy/use CI with an authorized age identity." diff --git a/Scripts/sparkle/sign-appcast-kms.py b/Scripts/sparkle/sign-appcast-kms.py new file mode 100755 index 0000000..0e22c7c --- /dev/null +++ b/Scripts/sparkle/sign-appcast-kms.py @@ -0,0 +1,149 @@ +#!/usr/bin/env python3 +"""Sign Sparkle appcast enclosures. + +Google Cloud KMS Ed25519 signing can only sign small payloads directly. Sparkle +requires a standard EdDSA signature over the full update archive, so normal +release artifacts sign directly from the decrypted release seed. +""" + +from __future__ import annotations + +import argparse +import base64 +import os +import subprocess +import sys +import tempfile +import urllib.parse +import xml.etree.ElementTree as ET +from pathlib import Path + + +SPARKLE_NS = "http://www.andymatuschak.org/xml-namespaces/sparkle" +DEFAULT_PROJECT = "project-88c23ce9-918a-470a-b33" +DEFAULT_LOCATION = "global" +DEFAULT_KEYRING = "burrow-identity" +DEFAULT_KEY = "sparkle-ed25519" +DEFAULT_VERSION = "1" +DEFAULT_KMS_MAX_INPUT_BYTES = 65536 + + +def run(command: list[str]) -> subprocess.CompletedProcess[str]: + return subprocess.run(command, check=True, text=True, stdout=subprocess.PIPE) + + +def kms_sign(args: argparse.Namespace, payload: Path) -> str: + with tempfile.TemporaryDirectory(prefix="burrow-sparkle-kms.") as tmp: + signature_path = Path(tmp) / "signature.bin" + command = [ + args.gcloud, + "kms", + "asymmetric-sign", + "--location", + args.kms_location, + "--keyring", + args.kms_keyring, + "--key", + args.kms_key, + "--version", + args.kms_version, + "--input-file", + str(payload), + "--signature-file", + str(signature_path), + ] + if args.gcloud_project: + command.extend(["--project", args.gcloud_project]) + run(command) + return base64.b64encode(signature_path.read_bytes()).decode("ascii") + + +def read_sparkle_seed(key_path: Path) -> bytes: + key_data = key_path.read_bytes().strip() + if len(key_data) == 32: + return key_data + try: + decoded = base64.b64decode(key_data, validate=True) + except ValueError as exc: + raise ValueError(f"Sparkle key is not raw or base64 Ed25519 seed data: {key_path}") from exc + if len(decoded) != 32: + raise ValueError(f"Sparkle key must decode to a 32-byte Ed25519 seed: {key_path}") + return decoded + + +def sign_with_release_seed(args: argparse.Namespace, payload: Path) -> str: + key_path = Path(args.ed_key_path) if args.ed_key_path else None + if key_path is None or not key_path.is_file(): + raise FileNotFoundError( + "Sparkle artifact is too large for direct Google KMS Ed25519 signing " + "and SPARKLE_EDDSA_KEY_PATH does not point to a key file" + ) + from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey + + seed = read_sparkle_seed(key_path) + signature = Ed25519PrivateKey.from_private_bytes(seed).sign(payload.read_bytes()) + return base64.b64encode(signature).decode("ascii") + + +def sparkle_signature(args: argparse.Namespace, payload: Path) -> str: + if args.ed_key_path: + return sign_with_release_seed(args, payload) + if payload.stat().st_size <= args.kms_max_input_bytes: + return kms_sign(args, payload) + return sign_with_release_seed(args, payload) + + +def enclosure_path(enclosure: ET.Element, artifact_dir: Path) -> Path: + url = enclosure.attrib.get("url") + if not url: + raise ValueError("Sparkle enclosure is missing a url attribute") + parsed = urllib.parse.urlparse(url) + name = Path(parsed.path).name + if not name: + raise ValueError(f"Sparkle enclosure URL has no file name: {url}") + path = artifact_dir / name + if not path.is_file(): + raise FileNotFoundError(f"Sparkle enclosure artifact not found: {path}") + return path + + +def sign_appcast(args: argparse.Namespace) -> None: + appcast = Path(args.appcast) + artifact_dir = Path(args.artifact_dir) if args.artifact_dir else appcast.parent + ET.register_namespace("sparkle", SPARKLE_NS) + tree = ET.parse(appcast) + root = tree.getroot() + enclosures = root.findall(".//enclosure") + if not enclosures: + raise ValueError(f"no Sparkle enclosures found in {appcast}") + + for enclosure in enclosures: + artifact = enclosure_path(enclosure, artifact_dir) + enclosure.attrib[f"{{{SPARKLE_NS}}}edSignature"] = sparkle_signature(args, artifact) + + tree.write(appcast, encoding="utf-8", xml_declaration=True) + print(f"signed {len(enclosures)} enclosure(s) in {appcast}") + + +def parse_args(argv: list[str]) -> argparse.Namespace: + parser = argparse.ArgumentParser(description="Sign Sparkle appcast enclosures with Google Cloud KMS.") + parser.add_argument("--appcast", required=True) + parser.add_argument("--artifact-dir") + parser.add_argument("--gcloud-project", default=os.environ.get("GOOGLE_CLOUD_PROJECT") or os.environ.get("BURROW_GOOGLE_PROJECT_ID") or DEFAULT_PROJECT) + parser.add_argument("--kms-location", default=os.environ.get("BURROW_KMS_LOCATION", DEFAULT_LOCATION)) + parser.add_argument("--kms-keyring", default=os.environ.get("BURROW_KMS_KEYRING", DEFAULT_KEYRING)) + parser.add_argument("--kms-key", default=os.environ.get("BURROW_SPARKLE_KMS_KEY", DEFAULT_KEY)) + parser.add_argument("--kms-version", default=os.environ.get("BURROW_SPARKLE_KMS_VERSION", DEFAULT_VERSION)) + parser.add_argument("--kms-max-input-bytes", type=int, default=DEFAULT_KMS_MAX_INPUT_BYTES) + parser.add_argument("--gcloud", default=os.environ.get("GCLOUD", "gcloud")) + parser.add_argument("--ed-key-path", default=os.environ.get("SPARKLE_EDDSA_KEY_PATH")) + return parser.parse_args(argv) + + +def main(argv: list[str]) -> int: + sign_appcast(parse_args(argv)) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main(sys.argv[1:])) diff --git a/Scripts/version.sh b/Scripts/version.sh new file mode 100755 index 0000000..60b8544 --- /dev/null +++ b/Scripts/version.sh @@ -0,0 +1,147 @@ +#!/usr/bin/env bash +set -euo pipefail + +burrow_user="${USER:-${LOGNAME:-runner}}" +export PATH="$PATH:/opt/homebrew/bin:/usr/local/bin:/etc/profiles/per-user/${burrow_user}/bin" + +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +TAG_PREFIX="builds/" +DEFAULT_VERSION_REMOTE="origin" +if git remote get-url forgejo >/dev/null 2>&1; then + DEFAULT_VERSION_REMOTE="forgejo" +fi +VERSION_REMOTE="${BURROW_VERSION_REMOTE:-$DEFAULT_VERSION_REMOTE}" +VERSION_REQUIRE_REMOTE="${BURROW_VERSION_REQUIRE_REMOTE:-false}" +COMMAND="${1:-}" + +truthy() { + case "$1" in + 1|true|TRUE|True|yes|YES|Yes|y|Y|on|ON|On) return 0 ;; + *) return 1 ;; + esac +} + +list_local_build_tags() { + git tag -l "${TAG_PREFIX}[0-9]*" +} + +latest_local_build_tag() { + list_local_build_tags | sort -n -t'/' -k2 | tail -n 1 +} + +latest_remote_build_record() { + local raw rc=0 + raw="$(git ls-remote --tags --refs "$VERSION_REMOTE" "refs/tags/${TAG_PREFIX}[0-9]*" 2>/dev/null)" || rc=$? + if [[ $rc -ne 0 ]]; then + return $rc + fi + if [[ -z "$raw" ]]; then + return 0 + fi + printf '%s\n' "$raw" | awk -F'\t' -v prefix="refs/tags/${TAG_PREFIX}" ' + $2 ~ ("^" prefix "[0-9]+$") { + build = $2 + sub("^refs/tags/", "", build) + print build "\t" $1 + } + ' | sort -n -t'/' -k2 | tail -n 1 +} + +resolve_build_state() { + local remote_record local_latest remote_status=0 + BUILD_STATE_SOURCE="local" + LATEST_BUILD="" + LATEST_BUILD_COMMIT="" + + remote_record="$(latest_remote_build_record)" || remote_status=$? + if [[ $remote_status -eq 0 ]]; then + BUILD_STATE_SOURCE="remote" + if [[ -n "$remote_record" ]]; then + LATEST_BUILD="$(printf '%s\n' "$remote_record" | cut -f1)" + LATEST_BUILD_COMMIT="$(printf '%s\n' "$remote_record" | cut -f2)" + fi + else + if truthy "$VERSION_REQUIRE_REMOTE"; then + echo "error: unable to resolve authoritative build tags from ${VERSION_REMOTE}" >&2 + exit "$remote_status" + fi + echo "warning: unable to resolve authoritative build tags from ${VERSION_REMOTE}; falling back to local tags" >&2 + local_latest="$(latest_local_build_tag)" + if [[ -n "$local_latest" ]]; then + LATEST_BUILD="$local_latest" + LATEST_BUILD_COMMIT="$(git rev-parse -q --verify "refs/tags/${LATEST_BUILD}^{commit}" 2>/dev/null || true)" + fi + fi + + if [[ -z "$LATEST_BUILD" ]]; then + LATEST_BUILD_NUMBER="0" + else + LATEST_BUILD_NUMBER="${LATEST_BUILD#$TAG_PREFIX}" + fi +} + +resolve_build_state + +HEAD_COMMIT="$(git rev-parse HEAD)" + +ANCESTRY_STATE="ok" +if [[ -n "${LATEST_BUILD_NUMBER}" && "${LATEST_BUILD_NUMBER}" != "0" ]]; then + if [[ -n "${LATEST_BUILD_COMMIT}" ]] && git cat-file -e "${LATEST_BUILD_COMMIT}^{commit}" 2>/dev/null; then + if ! git merge-base --is-ancestor "${LATEST_BUILD_COMMIT}" HEAD; then + ANCESTRY_STATE="not-descended" + if [[ "$COMMAND" != "status" ]]; then + echo "error: HEAD is not descended from build ${LATEST_BUILD_NUMBER}" >&2 + exit 1 + fi + fi + else + ANCESTRY_STATE="missing-tag-commit" + echo "notice: skipping build ancestry check (missing ${LATEST_BUILD} commit, likely shallow checkout)" >&2 + fi +fi + +BUILD_NUMBER="$LATEST_BUILD_NUMBER" + +if [[ "$COMMAND" == "increment" || "$COMMAND" == "pre-increment" ]]; then + if [[ -n "${BURROW_BUILD_NUMBER_OVERRIDE:-}" ]]; then + if [[ ! "${BURROW_BUILD_NUMBER_OVERRIDE}" =~ ^[0-9]+$ ]]; then + echo "error: BURROW_BUILD_NUMBER_OVERRIDE must be an integer" >&2 + exit 1 + fi + if (( BURROW_BUILD_NUMBER_OVERRIDE <= LATEST_BUILD_NUMBER )); then + echo "error: BURROW_BUILD_NUMBER_OVERRIDE must be greater than ${LATEST_BUILD_NUMBER}" >&2 + exit 1 + fi + NEW_BUILD_NUMBER="${BURROW_BUILD_NUMBER_OVERRIDE}" + else + NEW_BUILD_NUMBER=$((LATEST_BUILD_NUMBER + 1)) + fi + NEW_TAG="$TAG_PREFIX$NEW_BUILD_NUMBER" + BUILD_NUMBER="$NEW_BUILD_NUMBER" +fi + +if [[ "$COMMAND" == "increment" ]]; then + git tag "$NEW_TAG" + git push --quiet "$VERSION_REMOTE" "$NEW_TAG" +fi + +CONFIG_PATH="Apple/Configuration/Version.xcconfig" +if [[ "$COMMAND" != "status" && -f "$CONFIG_PATH" ]]; then + current_config_version="$(sed -n 's/^[[:space:]]*CURRENT_PROJECT_VERSION[[:space:]]*=[[:space:]]*//p' "$CONFIG_PATH" 2>/dev/null | tail -n 1 || true)" + if [[ "$current_config_version" != "$BUILD_NUMBER" ]]; then + echo "CURRENT_PROJECT_VERSION = $BUILD_NUMBER" > "$CONFIG_PATH" + fi + git update-index --assume-unchanged "$CONFIG_PATH" 2>/dev/null || true +fi + +if [[ "$COMMAND" == "status" ]]; then + if [[ "${ANCESTRY_STATE}" == "ok" && "${LATEST_BUILD_NUMBER}" != "0" && -n "${LATEST_BUILD_COMMIT}" && "${HEAD_COMMIT}" == "${LATEST_BUILD_COMMIT}" ]]; then + echo "clean" + else + echo "dirty" + fi + exit 0 +fi + +echo "$BUILD_NUMBER" diff --git a/bazel/android/BUILD.bazel b/bazel/android/BUILD.bazel new file mode 100644 index 0000000..64b7cff --- /dev/null +++ b/bazel/android/BUILD.bazel @@ -0,0 +1,14 @@ +load("@rules_shell//shell:sh_binary.bzl", "sh_binary") +load(":android_targets.bzl", "android_stub_stamp") + +package(default_visibility = ["//visibility:public"]) + +sh_binary( + name = "runner", + srcs = ["runner.sh"], +) + +android_stub_stamp( + name = "check_stub_stamp", + command = "check-stub", +) diff --git a/bazel/android/android_targets.bzl b/bazel/android/android_targets.bzl new file mode 100644 index 0000000..c6c67bd --- /dev/null +++ b/bazel/android/android_targets.bzl @@ -0,0 +1,12 @@ +def android_stub_stamp(name, command): + native.genrule( + name = name, + outs = [name + ".stamp"], + cmd = "$(location :runner) %s && : > \"$@\"" % command, + srcs = [ + "//:android_project_files", + "//:mobile_rust_core_files", + ], + tools = [":runner"], + tags = ["no-sandbox"], + ) diff --git a/bazel/android/runner.sh b/bazel/android/runner.sh new file mode 100755 index 0000000..c273218 --- /dev/null +++ b/bazel/android/runner.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +set -euo pipefail + +command="${1:-}" + +resolve_repo_root() { + if [[ -n "${BUILD_WORKSPACE_DIRECTORY:-}" && -f "${BUILD_WORKSPACE_DIRECTORY}/MODULE.bazel" ]]; then + printf '%s\n' "$BUILD_WORKSPACE_DIRECTORY" + return 0 + fi + + local dir="$PWD" + while [[ "$dir" != "/" ]]; do + if [[ -f "$dir/MODULE.bazel" && -d "$dir/Android" ]]; then + printf '%s\n' "$dir" + return 0 + fi + dir="$(dirname "$dir")" + done + + echo "unable to resolve Burrow repository root" >&2 + return 1 +} + +repo_root="$(resolve_repo_root)" +cd "$repo_root" + +cargo_check_locked() { + local -a cargo_path_prefixes + local home_dir user_name + cargo_path_prefixes=() + home_dir="${HOME:-}" + if [[ -n "$home_dir" ]]; then + cargo_path_prefixes+=("$home_dir/.cargo/bin") + fi + user_name="$(id -un 2>/dev/null || true)" + if [[ -n "$user_name" ]]; then + cargo_path_prefixes+=( + "/Users/${user_name}/.cargo/bin" + "/home/${user_name}/.cargo/bin" + "/etc/profiles/per-user/${user_name}/bin" + ) + fi + cargo_path_prefixes+=("/opt/homebrew/bin" "/usr/local/bin" "/nix/var/nix/profiles/default/bin" "/run/current-system/sw/bin") + export PATH="$(IFS=:; printf '%s' "${cargo_path_prefixes[*]}"):$PATH" + + if command -v cargo >/dev/null 2>&1; then + cargo check --locked -p burrow-mobile-ffi + return + fi + + if [[ "${BURROW_ANDROID_BAZEL_USE_NIX:-0}" == "1" ]] && command -v nix >/dev/null 2>&1; then + nix develop .#ci -c cargo check --locked -p burrow-mobile-ffi + return + fi + + echo "cargo or nix is required to check the Android Rust core stub" >&2 + exit 127 +} + +case "$command" in + check-stub) + test -f Android/settings.gradle.kts + test -f Android/app/src/main/java/net/burrow/android/MainActivity.kt + test -f crates/burrow-core/src/lib.rs + test -f crates/burrow-mobile-ffi/src/lib.rs + cargo_check_locked + ;; + *) + echo "unknown Android runner command: ${command}" >&2 + exit 64 + ;; +esac diff --git a/bazel/apple/BUILD.bazel b/bazel/apple/BUILD.bazel new file mode 100644 index 0000000..f35ec71 --- /dev/null +++ b/bazel/apple/BUILD.bazel @@ -0,0 +1,25 @@ +load("@rules_shell//shell:sh_binary.bzl", "sh_binary") +load(":apple_targets.bzl", "apple_bazel_stamp") + +package(default_visibility = ["//visibility:public"]) + +sh_binary( + name = "runner", + srcs = ["runner.sh"], + target_compatible_with = ["@platforms//os:macos"], +) + +apple_bazel_stamp( + name = "release_ios_stamp", + command = "release-ios", +) + +apple_bazel_stamp( + name = "release_macos_stamp", + command = "release-macos", +) + +apple_bazel_stamp( + name = "release_all_stamp", + command = "release-all", +) diff --git a/bazel/apple/apple_targets.bzl b/bazel/apple/apple_targets.bzl new file mode 100644 index 0000000..cedaf47 --- /dev/null +++ b/bazel/apple/apple_targets.bzl @@ -0,0 +1,13 @@ +def apple_bazel_stamp(name, command): + native.genrule( + name = name, + outs = [name + ".stamp"], + cmd = "$(location :runner) %s && : > \"$@\"" % command, + srcs = ["//:apple_project_files"], + tools = [":runner"], + # The Xcode script stages release artifacts under dist/builds as a + # deliberate CI side effect; keep the wrapper uncached so the staging + # step always runs in fresh and reused workspaces. + tags = ["no-cache", "no-remote-cache", "no-sandbox"], + target_compatible_with = ["@platforms//os:macos"], + ) diff --git a/bazel/apple/runner.sh b/bazel/apple/runner.sh new file mode 100755 index 0000000..cdf272a --- /dev/null +++ b/bazel/apple/runner.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +set -euo pipefail + +command="${1:-}" + +resolve_repo_root() { + if [[ -n "${BUILD_WORKSPACE_DIRECTORY:-}" && -f "${BUILD_WORKSPACE_DIRECTORY}/MODULE.bazel" ]]; then + printf '%s\n' "$BUILD_WORKSPACE_DIRECTORY" + return 0 + fi + + local dir="$PWD" + while [[ "$dir" != "/" ]]; do + if [[ -f "$dir/MODULE.bazel" && -d "$dir/Apple" ]]; then + printf '%s\n' "$dir" + return 0 + fi + dir="$(dirname "$dir")" + done + + echo "unable to resolve Burrow repository root" >&2 + return 1 +} + +repo_root="$(resolve_repo_root)" +cd "$repo_root" + +case "$command" in + release-ios) + Scripts/ci/package-apple-artifacts.sh ios + ;; + release-macos) + Scripts/ci/package-apple-artifacts.sh macos + ;; + release-all) + Scripts/ci/package-apple-artifacts.sh all + ;; + *) + echo "unknown apple runner command: ${command}" >&2 + exit 64 + ;; +esac diff --git a/burrow-gtk/data/icons/hicolor/128/apps/burrow-gtk.png b/burrow-gtk/data/icons/hicolor/128/apps/burrow-gtk.png new file mode 100644 index 0000000..54b67da Binary files /dev/null and b/burrow-gtk/data/icons/hicolor/128/apps/burrow-gtk.png differ diff --git a/burrow-gtk/data/icons/hicolor/16/apps/burrow-gtk.png b/burrow-gtk/data/icons/hicolor/16/apps/burrow-gtk.png new file mode 100644 index 0000000..cf418ae Binary files /dev/null and b/burrow-gtk/data/icons/hicolor/16/apps/burrow-gtk.png differ diff --git a/burrow-gtk/data/icons/hicolor/24/apps/burrow-gtk.png b/burrow-gtk/data/icons/hicolor/24/apps/burrow-gtk.png new file mode 100644 index 0000000..cfe8e33 Binary files /dev/null and b/burrow-gtk/data/icons/hicolor/24/apps/burrow-gtk.png differ diff --git a/burrow-gtk/data/icons/hicolor/256/apps/burrow-gtk.png b/burrow-gtk/data/icons/hicolor/256/apps/burrow-gtk.png new file mode 100644 index 0000000..561abcb Binary files /dev/null and b/burrow-gtk/data/icons/hicolor/256/apps/burrow-gtk.png differ diff --git a/burrow-gtk/data/icons/hicolor/32/apps/burrow-gtk.png b/burrow-gtk/data/icons/hicolor/32/apps/burrow-gtk.png new file mode 100644 index 0000000..52e7a25 Binary files /dev/null and b/burrow-gtk/data/icons/hicolor/32/apps/burrow-gtk.png differ diff --git a/burrow-gtk/data/icons/hicolor/48/apps/burrow-gtk.png b/burrow-gtk/data/icons/hicolor/48/apps/burrow-gtk.png new file mode 100644 index 0000000..68cf88b Binary files /dev/null and b/burrow-gtk/data/icons/hicolor/48/apps/burrow-gtk.png differ diff --git a/burrow-gtk/data/icons/hicolor/512/apps/burrow-gtk.png b/burrow-gtk/data/icons/hicolor/512/apps/burrow-gtk.png new file mode 100644 index 0000000..c5997ae Binary files /dev/null and b/burrow-gtk/data/icons/hicolor/512/apps/burrow-gtk.png differ diff --git a/burrow-gtk/data/icons/hicolor/64/apps/burrow-gtk.png b/burrow-gtk/data/icons/hicolor/64/apps/burrow-gtk.png new file mode 100644 index 0000000..46872b4 Binary files /dev/null and b/burrow-gtk/data/icons/hicolor/64/apps/burrow-gtk.png differ diff --git a/burrow-gtk/data/icons/hicolor/scalable/apps/burrow-gtk.svg b/burrow-gtk/data/icons/hicolor/scalable/apps/burrow-gtk.svg deleted file mode 100644 index a74c4df..0000000 --- a/burrow-gtk/data/icons/hicolor/scalable/apps/burrow-gtk.svg +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - - - - - - - - - image/svg+xml - - - - - - - - application-x-executable - - - - - - - - - - - - - - - - diff --git a/burrow-gtk/data/icons/hicolor/symbolic/apps/burrow-gtk-symbolic.svg b/burrow-gtk/data/icons/hicolor/symbolic/apps/burrow-gtk-symbolic.svg index 5352e0a..66ca58d 100644 --- a/burrow-gtk/data/icons/hicolor/symbolic/apps/burrow-gtk-symbolic.svg +++ b/burrow-gtk/data/icons/hicolor/symbolic/apps/burrow-gtk-symbolic.svg @@ -1 +1,11 @@ - + + + + + + + + + + + diff --git a/burrow-gtk/data/meson.build b/burrow-gtk/data/meson.build index 2c3ffd8..4abb3c5 100644 --- a/burrow-gtk/data/meson.build +++ b/burrow-gtk/data/meson.build @@ -77,11 +77,14 @@ if appstream_util.found() ) endif -install_data( - 'icons/hicolor/scalable/apps/' + app_name + '.svg', - install_dir: datadir / 'icons' / 'hicolor' / 'scalable' / 'apps', - rename: app_id + '.svg', -) +foreach size : ['16', '24', '32', '48', '64', '128', '256', '512'] + size_dir = size + 'x' + size + install_data( + 'icons/hicolor/' + size + '/apps/' + app_name + '.png', + install_dir: datadir / 'icons' / 'hicolor' / size_dir / 'apps', + rename: app_id + '.png', + ) +endforeach install_data( 'icons/hicolor/symbolic/apps/' + app_name + '-symbolic.svg', diff --git a/burrow-gtk/src/components/networks_screen.rs b/burrow-gtk/src/components/networks_screen.rs new file mode 100644 index 0000000..21df982 --- /dev/null +++ b/burrow-gtk/src/components/networks_screen.rs @@ -0,0 +1,515 @@ +use super::*; +use anyhow::{Context, Result}; +use tokio::time::Duration; + +pub struct NetworksScreen { + list_box: gtk::ListBox, + network_status: gtk::Label, + wireguard_text: gtk::TextView, + tailnet_email_entry: gtk::Entry, + tailnet_authority_entry: gtk::Entry, + tailnet_account_entry: gtk::Entry, + tailnet_identity_entry: gtk::Entry, + tailnet_hostname_entry: gtk::Entry, + tailnet_name_entry: gtk::Entry, + custom_authority_switch: gtk::Switch, + tailnet_status: gtk::Label, + tailnet_session_id: Option, + tailnet_running: bool, +} + +#[derive(Debug)] +pub enum NetworksScreenMsg { + Refresh, + AddWireGuard, + DiscoverTailnet, + ProbeTailnet, + StartTailnetLogin, + PollTailnetLogin, + CancelTailnetLogin, + AddTailnet, +} + +#[relm4::component(pub, async)] +impl AsyncComponent for NetworksScreen { + type Init = (); + type Input = NetworksScreenMsg; + type Output = (); + type CommandOutput = (); + + view! { + gtk::ScrolledWindow { + set_vexpand: true, + + adw::Clamp { + gtk::Box { + set_orientation: gtk::Orientation::Vertical, + set_spacing: 12, + set_margin_all: 12, + + adw::PreferencesGroup { + set_title: "Stored Networks", + set_description: Some("Networks saved in the Burrow daemon"), + + #[name(network_status)] + gtk::Label { + set_xalign: 0.0, + set_wrap: true, + set_label: "Loading networks", + }, + + #[name(list_box)] + gtk::ListBox { + add_css_class: "boxed-list", + }, + + gtk::Button { + set_label: "Refresh", + connect_clicked => NetworksScreenMsg::Refresh + }, + }, + + adw::PreferencesGroup { + set_title: "Add WireGuard", + set_description: Some("Import a WireGuard configuration into the daemon"), + + gtk::ScrolledWindow { + set_min_content_height: 150, + set_vexpand: false, + + #[name(wireguard_text)] + gtk::TextView { + set_monospace: true, + set_wrap_mode: gtk::WrapMode::WordChar, + } + }, + + gtk::Button { + set_label: "Add WireGuard Network", + connect_clicked => NetworksScreenMsg::AddWireGuard + }, + }, + + adw::PreferencesGroup { + set_title: "Tailnet", + set_description: Some("Discover, probe, sign in, and save Tailnet authorities through the daemon"), + + #[name(tailnet_email_entry)] + gtk::Entry { + set_placeholder_text: Some("Email address"), + }, + + #[name(custom_authority_switch)] + gtk::Switch { + set_halign: Align::Start, + set_active: false, + }, + + #[name(tailnet_authority_entry)] + gtk::Entry { + set_placeholder_text: Some("Tailnet server URL"), + }, + + #[name(tailnet_account_entry)] + gtk::Entry { + set_placeholder_text: Some("Account name"), + }, + + #[name(tailnet_identity_entry)] + gtk::Entry { + set_placeholder_text: Some("Identity name"), + }, + + #[name(tailnet_hostname_entry)] + gtk::Entry { + set_placeholder_text: Some("Device hostname"), + }, + + #[name(tailnet_name_entry)] + gtk::Entry { + set_placeholder_text: Some("Tailnet name"), + }, + + #[name(tailnet_status)] + gtk::Label { + set_xalign: 0.0, + set_wrap: true, + set_selectable: true, + set_label: "Use discovery for the managed Tailscale authority or enter a custom Tailnet server.", + }, + + gtk::Box { + set_orientation: gtk::Orientation::Horizontal, + set_spacing: 8, + + gtk::Button { + set_label: "Discover", + connect_clicked => NetworksScreenMsg::DiscoverTailnet + }, + + gtk::Button { + set_label: "Probe", + connect_clicked => NetworksScreenMsg::ProbeTailnet + }, + + gtk::Button { + set_label: "Sign In", + connect_clicked => NetworksScreenMsg::StartTailnetLogin + }, + + gtk::Button { + set_label: "Cancel", + connect_clicked => NetworksScreenMsg::CancelTailnetLogin + }, + }, + + gtk::Button { + set_label: "Save Tailnet Network", + connect_clicked => NetworksScreenMsg::AddTailnet + }, + }, + } + } + } + } + + async fn init( + _: Self::Init, + root: Self::Root, + sender: AsyncComponentSender, + ) -> AsyncComponentParts { + let widgets = view_output!(); + widgets + .tailnet_authority_entry + .set_text(daemon_api::default_tailnet_authority()); + widgets.tailnet_account_entry.set_text("default"); + widgets.tailnet_identity_entry.set_text("linux"); + + let mut model = NetworksScreen { + list_box: widgets.list_box.clone(), + network_status: widgets.network_status.clone(), + wireguard_text: widgets.wireguard_text.clone(), + tailnet_email_entry: widgets.tailnet_email_entry.clone(), + tailnet_authority_entry: widgets.tailnet_authority_entry.clone(), + tailnet_account_entry: widgets.tailnet_account_entry.clone(), + tailnet_identity_entry: widgets.tailnet_identity_entry.clone(), + tailnet_hostname_entry: widgets.tailnet_hostname_entry.clone(), + tailnet_name_entry: widgets.tailnet_name_entry.clone(), + custom_authority_switch: widgets.custom_authority_switch.clone(), + tailnet_status: widgets.tailnet_status.clone(), + tailnet_session_id: None, + tailnet_running: false, + }; + + model.refresh_networks().await; + + AsyncComponentParts { model, widgets } + } + + async fn update( + &mut self, + msg: Self::Input, + sender: AsyncComponentSender, + _root: &Self::Root, + ) { + match msg { + NetworksScreenMsg::Refresh => self.refresh_networks().await, + NetworksScreenMsg::AddWireGuard => self.add_wireguard().await, + NetworksScreenMsg::DiscoverTailnet => self.discover_tailnet().await, + NetworksScreenMsg::ProbeTailnet => self.probe_tailnet().await, + NetworksScreenMsg::StartTailnetLogin => self.start_tailnet_login(sender).await, + NetworksScreenMsg::PollTailnetLogin => self.poll_tailnet_login(sender).await, + NetworksScreenMsg::CancelTailnetLogin => self.cancel_tailnet_login().await, + NetworksScreenMsg::AddTailnet => self.add_tailnet().await, + } + } +} + +impl NetworksScreen { + async fn refresh_networks(&mut self) { + match daemon_api::list_networks().await { + Ok(networks) => { + self.render_networks(&networks); + self.network_status.set_label(if networks.is_empty() { + "No daemon networks saved yet" + } else { + "Daemon networks are up to date" + }); + } + Err(error) => { + self.clear_networks(); + self.network_status + .set_label(&format!("Unable to read daemon networks: {error}")); + } + } + } + + async fn add_wireguard(&mut self) { + let config = text_view_text(&self.wireguard_text); + if config.trim().is_empty() { + self.network_status + .set_label("Paste a WireGuard configuration before adding a network"); + return; + } + + match daemon_api::add_wireguard(config).await { + Ok(id) => { + self.network_status + .set_label(&format!("Added WireGuard network #{id}")); + self.wireguard_text.buffer().set_text(""); + self.refresh_networks().await; + } + Err(error) => self + .network_status + .set_label(&format!("Unable to add WireGuard network: {error}")), + } + } + + async fn discover_tailnet(&mut self) { + let email = self.tailnet_email_entry.text().to_string(); + let Ok(email) = daemon_api::require_value(&email, "Email address") else { + self.tailnet_status + .set_label("Enter an email address before discovery"); + return; + }; + + self.tailnet_status.set_label("Discovering Tailnet server"); + match daemon_api::discover_tailnet(email).await { + Ok(discovery) => { + self.tailnet_authority_entry.set_text(&discovery.authority); + self.custom_authority_switch.set_active(!discovery.managed); + let issuer = discovery + .oidc_issuer + .map(|issuer| format!(" OIDC issuer: {issuer}.")) + .unwrap_or_default(); + let kind = if discovery.managed { + "managed authority" + } else { + "custom authority" + }; + self.tailnet_status.set_label(&format!( + "Discovered {kind}: {}.{issuer}", + discovery.authority + )); + } + Err(error) => self + .tailnet_status + .set_label(&format!("Tailnet discovery failed: {error}")), + } + } + + async fn probe_tailnet(&mut self) { + let authority = self.tailnet_authority(); + let Ok(authority) = daemon_api::require_value(&authority, "Tailnet server URL") else { + self.tailnet_status + .set_label("Enter a Tailnet server URL before probing"); + return; + }; + + self.tailnet_status.set_label("Checking Tailnet server"); + match daemon_api::probe_tailnet(authority).await { + Ok(probe) => { + let detail = probe + .detail + .unwrap_or_else(|| format!("HTTP {}", probe.status_code)); + self.tailnet_status + .set_label(&format!("{}: {detail}", probe.summary)); + } + Err(error) => self + .tailnet_status + .set_label(&format!("Tailnet probe failed: {error}")), + } + } + + async fn start_tailnet_login(&mut self, sender: AsyncComponentSender) { + let authority = self.tailnet_authority(); + let Ok(authority) = daemon_api::require_value(&authority, "Tailnet server URL") else { + self.tailnet_status + .set_label("Enter a Tailnet server URL before sign-in"); + return; + }; + let account = daemon_api::normalized(&self.tailnet_account_entry.text(), "default"); + let identity = daemon_api::normalized(&self.tailnet_identity_entry.text(), "linux"); + let hostname = daemon_api::normalized_optional(&self.tailnet_hostname_entry.text()); + + self.tailnet_status.set_label("Starting Tailnet sign-in"); + match daemon_api::start_tailnet_login(authority, account, identity, hostname).await { + Ok(status) => { + self.apply_login_status(&status); + if let Some(auth_url) = status.auth_url.as_deref() { + if let Err(error) = open_auth_url(auth_url) { + self.tailnet_status.set_label(&format!( + "{} Open this URL manually: {auth_url}. Browser launch failed: {error}", + self.tailnet_status.text() + )); + } + } + if !status.running { + sender.input(NetworksScreenMsg::PollTailnetLogin); + } + } + Err(error) => self + .tailnet_status + .set_label(&format!("Tailnet sign-in failed: {error}")), + } + } + + async fn poll_tailnet_login(&mut self, sender: AsyncComponentSender) { + let Some(session_id) = self.tailnet_session_id.clone() else { + return; + }; + if self.tailnet_running { + return; + } + + tokio::time::sleep(Duration::from_secs(1)).await; + match daemon_api::tailnet_login_status(session_id).await { + Ok(status) => { + self.apply_login_status(&status); + if !status.running { + sender.input(NetworksScreenMsg::PollTailnetLogin); + } + } + Err(error) => { + self.tailnet_status + .set_label(&format!("Tailnet sign-in status failed: {error}")); + self.tailnet_session_id = None; + } + } + } + + async fn cancel_tailnet_login(&mut self) { + let Some(session_id) = self.tailnet_session_id.clone() else { + self.tailnet_status + .set_label("No Tailnet sign-in is active"); + return; + }; + + match daemon_api::cancel_tailnet_login(session_id).await { + Ok(()) => { + self.tailnet_session_id = None; + self.tailnet_running = false; + self.tailnet_status.set_label("Tailnet sign-in cancelled"); + } + Err(error) => self + .tailnet_status + .set_label(&format!("Unable to cancel Tailnet sign-in: {error}")), + } + } + + async fn add_tailnet(&mut self) { + let authority = self.tailnet_authority(); + let Ok(authority) = daemon_api::require_value(&authority, "Tailnet server URL") else { + self.tailnet_status + .set_label("Enter a Tailnet server URL before saving"); + return; + }; + if self.tailnet_session_id.is_some() && !self.tailnet_running { + self.tailnet_status + .set_label("Finish browser sign-in before saving this Tailnet network"); + return; + } + + let account = daemon_api::normalized(&self.tailnet_account_entry.text(), "default"); + let identity = daemon_api::normalized(&self.tailnet_identity_entry.text(), "linux"); + let hostname = daemon_api::normalized_optional(&self.tailnet_hostname_entry.text()); + let tailnet = daemon_api::normalized_optional(&self.tailnet_name_entry.text()); + + match daemon_api::add_tailnet(authority, account, identity, hostname, tailnet).await { + Ok(id) => { + self.tailnet_status + .set_label(&format!("Saved Tailnet network #{id}")); + self.refresh_networks().await; + } + Err(error) => self + .tailnet_status + .set_label(&format!("Unable to save Tailnet network: {error}")), + } + } + + fn apply_login_status(&mut self, status: &daemon_api::TailnetLoginStatus) { + self.tailnet_session_id = Some(status.session_id.clone()); + self.tailnet_running = status.running; + + let mut parts = Vec::new(); + if status.running { + parts.push("Signed in".to_owned()); + } else if status.needs_login { + parts.push("Browser sign-in required".to_owned()); + } else { + parts.push("Checking sign-in".to_owned()); + } + if !status.backend_state.is_empty() { + parts.push(format!("State: {}", status.backend_state)); + } + if let Some(tailnet_name) = &status.tailnet_name { + parts.push(format!("Tailnet: {tailnet_name}")); + } + if let Some(self_dns_name) = &status.self_dns_name { + parts.push(self_dns_name.clone()); + } + if !status.tailnet_ips.is_empty() { + parts.push(status.tailnet_ips.join(", ")); + } + if !status.health.is_empty() { + parts.push(status.health.join(" / ")); + } + if let Some(auth_url) = &status.auth_url { + parts.push(format!("Auth URL: {auth_url}")); + } + + self.tailnet_status.set_label(&parts.join("\n")); + } + + fn tailnet_authority(&self) -> String { + if self.custom_authority_switch.is_active() { + self.tailnet_authority_entry.text().to_string() + } else { + let authority = self.tailnet_authority_entry.text(); + if authority.trim().is_empty() { + daemon_api::default_tailnet_authority().to_owned() + } else { + authority.to_string() + } + } + } + + fn clear_networks(&self) { + while let Some(child) = self.list_box.first_child() { + self.list_box.remove(&child); + } + } + + fn render_networks(&self, networks: &[daemon_api::NetworkSummary]) { + self.clear_networks(); + if networks.is_empty() { + let row = adw::ActionRow::builder() + .title("No networks") + .subtitle("Save a WireGuard or Tailnet network to use it here.") + .build(); + self.list_box.append(&row); + return; + } + + for network in networks { + let title = format!("{} (#{})", network.title, network.id); + let row = adw::ActionRow::builder() + .title(&title) + .subtitle(&network.detail) + .build(); + self.list_box.append(&row); + } + } +} + +fn text_view_text(text_view: >k::TextView) -> String { + let buffer = text_view.buffer(); + buffer + .text(&buffer.start_iter(), &buffer.end_iter(), true) + .to_string() +} + +fn open_auth_url(url: &str) -> Result<()> { + gtk::gio::AppInfo::launch_default_for_uri(url, None::<>k::gio::AppLaunchContext>) + .with_context(|| format!("failed to open {url}")) +} diff --git a/burrow-gtk/src/components/settings/daemon_group.rs b/burrow-gtk/src/components/settings/daemon_group.rs index 3817ca6..d04e30f 100644 --- a/burrow-gtk/src/components/settings/daemon_group.rs +++ b/burrow-gtk/src/components/settings/daemon_group.rs @@ -4,12 +4,10 @@ use std::process::Command; #[derive(Debug)] pub struct DaemonGroup { system_setup: SystemSetup, - daemon_client: Arc>>, already_running: bool, } pub struct DaemonGroupInit { - pub daemon_client: Arc>>, pub system_setup: SystemSetup, } @@ -30,8 +28,8 @@ impl AsyncComponent for DaemonGroup { #[name(group)] adw::PreferencesGroup { #[watch] - set_sensitive: - (model.system_setup == SystemSetup::AppImage || model.system_setup == SystemSetup::Other) && + set_sensitive: + (model.system_setup == SystemSetup::AppImage || model.system_setup == SystemSetup::Other) && !model.already_running, set_title: "Local Daemon", set_description: Some("Run Local Daemon"), @@ -51,8 +49,7 @@ impl AsyncComponent for DaemonGroup { // Should be impossible to panic here let model = DaemonGroup { system_setup: init.system_setup, - daemon_client: init.daemon_client.clone(), - already_running: init.daemon_client.lock().await.is_some(), + already_running: daemon_api::daemon_available().await, }; let widgets = view_output!(); @@ -104,7 +101,7 @@ mv $TEMP /tmp/burrow-detached-daemon"#, .unwrap(); } DaemonGroupMsg::DaemonStateChange => { - self.already_running = self.daemon_client.lock().await.is_some(); + self.already_running = daemon_api::daemon_available().await; } } } diff --git a/burrow-gtk/src/components/settings/diag_group.rs b/burrow-gtk/src/components/settings/diag_group.rs index a15e0ea..e1e9b78 100644 --- a/burrow-gtk/src/components/settings/diag_group.rs +++ b/burrow-gtk/src/components/settings/diag_group.rs @@ -2,8 +2,6 @@ use super::*; #[derive(Debug)] pub struct DiagGroup { - daemon_client: Arc>>, - system_setup: SystemSetup, service_installed: StatusTernary, socket_installed: StatusTernary, @@ -12,14 +10,13 @@ pub struct DiagGroup { } pub struct DiagGroupInit { - pub daemon_client: Arc>>, pub system_setup: SystemSetup, } impl DiagGroup { - async fn new(daemon_client: Arc>>) -> Result { + async fn new() -> Result { let system_setup = SystemSetup::new(); - let daemon_running = daemon_client.lock().await.is_some(); + let daemon_running = daemon_api::daemon_available().await; Ok(Self { service_installed: system_setup.is_service_installed()?, @@ -27,7 +24,6 @@ impl DiagGroup { socket_enabled: system_setup.is_socket_enabled()?, daemon_running, system_setup, - daemon_client, }) } } @@ -95,7 +91,8 @@ impl AsyncComponent for DiagGroup { sender: AsyncComponentSender, ) -> AsyncComponentParts { // Should be impossible to panic here - let model = DiagGroup::new(init.daemon_client).await.unwrap(); + let mut model = DiagGroup::new().await.unwrap(); + model.system_setup = init.system_setup; let widgets = view_output!(); @@ -111,7 +108,7 @@ impl AsyncComponent for DiagGroup { match msg { DiagGroupMsg::Refresh => { // Should be impossible to panic here - *self = Self::new(Arc::clone(&self.daemon_client)).await.unwrap(); + *self = Self::new().await.unwrap(); } } } diff --git a/burrow-gtk/src/components/settings_screen.rs b/burrow-gtk/src/components/settings_screen.rs index 971f262..9828c31 100644 --- a/burrow-gtk/src/components/settings_screen.rs +++ b/burrow-gtk/src/components/settings_screen.rs @@ -6,10 +6,6 @@ pub struct SettingsScreen { daemon_group: AsyncController, } -pub struct SettingsScreenInit { - pub daemon_client: Arc>>, -} - #[derive(Debug, PartialEq, Eq)] pub enum SettingsScreenMsg { DaemonStateChange, @@ -17,7 +13,7 @@ pub enum SettingsScreenMsg { #[relm4::component(pub)] impl SimpleComponent for SettingsScreen { - type Init = SettingsScreenInit; + type Init = (); type Input = SettingsScreenMsg; type Output = (); @@ -27,26 +23,20 @@ impl SimpleComponent for SettingsScreen { } fn init( - init: Self::Init, + _init: Self::Init, root: &Self::Root, sender: ComponentSender, ) -> ComponentParts { let system_setup = SystemSetup::new(); let diag_group = settings::DiagGroup::builder() - .launch(settings::DiagGroupInit { - system_setup, - daemon_client: Arc::clone(&init.daemon_client), - }) + .launch(settings::DiagGroupInit { system_setup }) .forward(sender.input_sender(), |_| { SettingsScreenMsg::DaemonStateChange }); let daemon_group = settings::DaemonGroup::builder() - .launch(settings::DaemonGroupInit { - system_setup, - daemon_client: Arc::clone(&init.daemon_client), - }) + .launch(settings::DaemonGroupInit { system_setup }) .forward(sender.input_sender(), |_| { SettingsScreenMsg::DaemonStateChange }); diff --git a/burrow-gtk/src/components/switch_screen.rs b/burrow-gtk/src/components/switch_screen.rs index f660536..bbc5f82 100644 --- a/burrow-gtk/src/components/switch_screen.rs +++ b/burrow-gtk/src/components/switch_screen.rs @@ -1,27 +1,22 @@ use super::*; pub struct SwitchScreen { - daemon_client: Arc>>, switch: gtk::Switch, switch_screen: gtk::Box, disconnected_banner: adw::Banner, -} - -pub struct SwitchScreenInit { - pub daemon_client: Arc>>, + status_label: gtk::Label, } #[derive(Debug, PartialEq, Eq)] pub enum SwitchScreenMsg { - DaemonReconnect, - DaemonDisconnect, + Refresh, Start, Stop, } #[relm4::component(pub, async)] impl AsyncComponent for SwitchScreen { - type Init = SwitchScreenInit; + type Init = (); type Input = SwitchScreenMsg; type Output = (); type CommandOutput = (); @@ -39,7 +34,7 @@ impl AsyncComponent for SwitchScreen { #[name(setup_banner)] adw::Banner { - set_title: "Burrow is not running!", + set_title: "Burrow daemon is not reachable", }, }, @@ -52,7 +47,12 @@ impl AsyncComponent for SwitchScreen { set_vexpand: true, gtk::Label { - set_label: "Burrow Switch", + set_label: "Burrow Tunnel", + }, + + #[name(status_label)] + gtk::Label { + set_label: "Checking daemon status", }, #[name(switch)] @@ -68,91 +68,76 @@ impl AsyncComponent for SwitchScreen { } async fn init( - init: Self::Init, + _: Self::Init, root: Self::Root, sender: AsyncComponentSender, ) -> AsyncComponentParts { - let mut initial_switch_status = false; - let mut initial_daemon_server_down = false; - - if let Some(daemon_client) = init.daemon_client.lock().await.as_mut() { - if let Ok(res) = daemon_client - .send_command(DaemonCommand::ServerInfo) - .await - .as_ref() - { - initial_switch_status = match res.result.as_ref() { - Ok(DaemonResponseData::None) => false, - Ok(DaemonResponseData::ServerInfo(_)) => true, - _ => false, - }; - } else { - initial_daemon_server_down = true; - } - } else { - initial_daemon_server_down = true; - } - let widgets = view_output!(); - widgets.switch.set_active(initial_switch_status); - - if initial_daemon_server_down { - *init.daemon_client.lock().await = None; - widgets.switch.set_active(false); - widgets.switch_screen.set_sensitive(false); - widgets.setup_banner.set_revealed(true); - } - - let model = SwitchScreen { - daemon_client: init.daemon_client, + let mut model = SwitchScreen { switch: widgets.switch.clone(), switch_screen: widgets.switch_screen.clone(), disconnected_banner: widgets.setup_banner.clone(), + status_label: widgets.status_label.clone(), }; + model.refresh().await; + AsyncComponentParts { model, widgets } } async fn update( &mut self, msg: Self::Input, - _: AsyncComponentSender, + _sender: AsyncComponentSender, _root: &Self::Root, ) { - let mut disconnected_daemon_client = false; - - if let Some(daemon_client) = self.daemon_client.lock().await.as_mut() { - match msg { - Self::Input::Start => { - if let Err(_e) = daemon_client - .send_command(DaemonCommand::Start(Default::default())) - .await - { - disconnected_daemon_client = true; - } + match msg { + SwitchScreenMsg::Refresh => self.refresh().await, + SwitchScreenMsg::Start => { + match daemon_api::start_tunnel().await { + Ok(()) => self.status_label.set_label("Tunnel running"), + Err(error) => self + .status_label + .set_label(&format!("Start failed: {error}")), } - Self::Input::Stop => { - if let Err(_e) = daemon_client.send_command(DaemonCommand::Stop).await { - disconnected_daemon_client = true; - } - } - _ => {} + self.refresh().await; + } + SwitchScreenMsg::Stop => { + match daemon_api::stop_tunnel().await { + Ok(()) => self.status_label.set_label("Tunnel stopped"), + Err(error) => self + .status_label + .set_label(&format!("Stop failed: {error}")), + } + self.refresh().await; + } + } + } +} + +impl SwitchScreen { + async fn refresh(&mut self) { + match daemon_api::tunnel_state().await { + Ok(daemon_api::TunnelState::Running) => { + self.disconnected_banner.set_revealed(false); + self.switch_screen.set_sensitive(true); + self.status_label.set_label("Tunnel running"); + self.switch.set_active(true); + } + Ok(daemon_api::TunnelState::Stopped) => { + self.disconnected_banner.set_revealed(false); + self.switch_screen.set_sensitive(true); + self.status_label.set_label("Tunnel stopped"); + self.switch.set_active(false); + } + Err(error) => { + self.disconnected_banner.set_revealed(true); + self.switch_screen.set_sensitive(false); + self.status_label + .set_label(&format!("Daemon unavailable: {error}")); + self.switch.set_active(false); } - } else { - disconnected_daemon_client = true; - } - - if msg == Self::Input::DaemonReconnect { - self.disconnected_banner.set_revealed(false); - self.switch_screen.set_sensitive(true); - } - - if disconnected_daemon_client || msg == Self::Input::DaemonDisconnect { - *self.daemon_client.lock().await = None; - self.switch.set_active(false); - self.switch_screen.set_sensitive(false); - self.disconnected_banner.set_revealed(true); } } } diff --git a/burrow/src/main.rs b/burrow/src/main.rs index cfa2085..30c5960 100644 --- a/burrow/src/main.rs +++ b/burrow/src/main.rs @@ -35,8 +35,8 @@ use crate::daemon::rpc::{grpc_defs::Empty, BurrowClient}; #[command( about = "Burrow is a tool for burrowing through firewalls, built by teenagers at Hack Club.", long_about = "Burrow is a 🚀 blazingly fast 🚀 tool designed to penetrate unnecessarily restrictive firewalls, providing teenagers worldwide with secure, less-filtered, and safe access to the internet! -It's being built by teenagers from Hack Club, in public! Check it out: https://github.com/hackclub/burrow -Spotted a bug? Please open an issue! https://github.com/hackclub/burrow/issues/new" +It's being built by teenagers from Hack Club, in public! Check it out: https://git.burrow.net/hackclub/burrow +Spotted a bug? Please open an issue on the Burrow forge." )] struct Cli { diff --git a/contributors.nix b/contributors.nix index 60501d1..e13da91 100644 --- a/contributors.nix +++ b/contributors.nix @@ -2,6 +2,7 @@ groups = { users = "burrow-users"; admins = "burrow-admins"; + automation = "burrow-automation"; linear = { owners = "linear-owners"; admins = "linear-admins"; @@ -75,6 +76,30 @@ ]; }; + release = { + displayName = "Burrow Release"; + canonicalEmail = "release@burrow.net"; + isAdmin = false; + forgeAuthorized = false; + bootstrapAuthentik = false; + roles = [ + "automation" + "release" + ]; + }; + + namespace = { + displayName = "Burrow Namespace"; + canonicalEmail = "namespace@burrow.net"; + isAdmin = false; + forgeAuthorized = false; + bootstrapAuthentik = false; + roles = [ + "automation" + "namespace-runners" + ]; + }; + ui-test = { displayName = "Burrow UI Test"; canonicalEmail = "ui-test@burrow.net"; diff --git a/crates/burrow-core/Cargo.toml b/crates/burrow-core/Cargo.toml new file mode 100644 index 0000000..b6bc9fd --- /dev/null +++ b/crates/burrow-core/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "burrow-core" +version = "0.1.0" +edition = "2021" +description = "Cross-platform Burrow protocol and application core." +license = "GPL-3.0-or-later" + +[lib] +crate-type = ["lib", "staticlib"] diff --git a/crates/burrow-core/src/lib.rs b/crates/burrow-core/src/lib.rs new file mode 100644 index 0000000..6cf84dd --- /dev/null +++ b/crates/burrow-core/src/lib.rs @@ -0,0 +1,61 @@ +#![deny(missing_debug_implementations)] + +/// Version of the Rust core linked into platform shells. +pub fn version() -> &'static str { + env!("CARGO_PKG_VERSION") +} + +/// Platform family reported by the current Rust target. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum PlatformFamily { + Android, + Apple, + Linux, + Windows, + Other, +} + +impl PlatformFamily { + pub fn current() -> Self { + if cfg!(target_os = "android") { + Self::Android + } else if cfg!(target_vendor = "apple") { + Self::Apple + } else if cfg!(target_os = "linux") { + Self::Linux + } else if cfg!(target_os = "windows") { + Self::Windows + } else { + Self::Other + } + } + + pub fn as_str(self) -> &'static str { + match self { + Self::Android => "android", + Self::Apple => "apple", + Self::Linux => "linux", + Self::Windows => "windows", + Self::Other => "other", + } + } +} + +/// Human-readable core identity for stubs and smoke tests. +pub fn identity() -> String { + format!( + "burrow-core/{} ({})", + version(), + PlatformFamily::current().as_str() + ) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn identity_includes_project_name() { + assert!(identity().starts_with("burrow-core/")); + } +} diff --git a/crates/burrow-mobile-ffi/Cargo.toml b/crates/burrow-mobile-ffi/Cargo.toml new file mode 100644 index 0000000..701c2b4 --- /dev/null +++ b/crates/burrow-mobile-ffi/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "burrow-mobile-ffi" +version = "0.1.0" +edition = "2021" +description = "Mobile FFI boundary for the Burrow Rust core." +license = "GPL-3.0-or-later" + +[lib] +crate-type = ["cdylib", "staticlib"] + +[dependencies] +burrow-core = { path = "../burrow-core" } +jni = "0.21" diff --git a/crates/burrow-mobile-ffi/src/lib.rs b/crates/burrow-mobile-ffi/src/lib.rs new file mode 100644 index 0000000..ff75ad8 --- /dev/null +++ b/crates/burrow-mobile-ffi/src/lib.rs @@ -0,0 +1,27 @@ +#![deny(missing_debug_implementations)] + +use std::ffi::c_char; + +use jni::objects::JClass; +use jni::sys::jstring; +use jni::JNIEnv; + +static CORE_VERSION: &[u8] = concat!(env!("CARGO_PKG_VERSION"), "\0").as_bytes(); + +/// C ABI entrypoint for platform shells that do not use JNI. +#[no_mangle] +pub extern "C" fn burrow_core_version() -> *const c_char { + CORE_VERSION.as_ptr().cast() +} + +/// JNI entrypoint used by the Android Kotlin stub. +#[no_mangle] +pub extern "system" fn Java_net_burrow_android_BurrowCore_version( + env: JNIEnv<'_>, + _class: JClass<'_>, +) -> jstring { + match env.new_string(burrow_core::identity()) { + Ok(value) => value.into_raw(), + Err(_) => std::ptr::null_mut(), + } +} diff --git a/crates/burrow-windows-stub/Cargo.toml b/crates/burrow-windows-stub/Cargo.toml new file mode 100644 index 0000000..4ef859a --- /dev/null +++ b/crates/burrow-windows-stub/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "burrow-windows-stub" +version = "0.1.0" +edition = "2021" +description = "Windows release placeholder for Burrow" +license = "GPL-3.0-or-later" + +[[bin]] +name = "burrow" +path = "src/main.rs" diff --git a/crates/burrow-windows-stub/src/main.rs b/crates/burrow-windows-stub/src/main.rs new file mode 100644 index 0000000..fddc637 --- /dev/null +++ b/crates/burrow-windows-stub/src/main.rs @@ -0,0 +1,8 @@ +use std::process::ExitCode; + +fn main() -> ExitCode { + println!("Burrow for Windows is not ready yet."); + println!("This release stub exists so the Windows lane can exercise signing, packaging, and upload plumbing before the native client lands."); + println!("Install a Linux or Apple build for a functional Burrow client today."); + ExitCode::from(64) +} diff --git a/design/brand/Burrow.icon/Assets/burrow-ground.png b/design/brand/Burrow.icon/Assets/burrow-ground.png new file mode 100644 index 0000000..a39c507 Binary files /dev/null and b/design/brand/Burrow.icon/Assets/burrow-ground.png differ diff --git a/design/brand/Burrow.icon/Assets/owl-body.png b/design/brand/Burrow.icon/Assets/owl-body.png new file mode 100644 index 0000000..e335771 Binary files /dev/null and b/design/brand/Burrow.icon/Assets/owl-body.png differ diff --git a/design/brand/Burrow.icon/Assets/owl-face.png b/design/brand/Burrow.icon/Assets/owl-face.png new file mode 100644 index 0000000..a39c507 Binary files /dev/null and b/design/brand/Burrow.icon/Assets/owl-face.png differ diff --git a/design/brand/Burrow.icon/Assets/owl-figure.png b/design/brand/Burrow.icon/Assets/owl-figure.png new file mode 100644 index 0000000..e335771 Binary files /dev/null and b/design/brand/Burrow.icon/Assets/owl-figure.png differ diff --git a/design/brand/Burrow.icon/Assets/owl-legs.png b/design/brand/Burrow.icon/Assets/owl-legs.png new file mode 100644 index 0000000..a39c507 Binary files /dev/null and b/design/brand/Burrow.icon/Assets/owl-legs.png differ diff --git a/design/brand/Burrow.icon/Assets/owl-spots.png b/design/brand/Burrow.icon/Assets/owl-spots.png new file mode 100644 index 0000000..a39c507 Binary files /dev/null and b/design/brand/Burrow.icon/Assets/owl-spots.png differ diff --git a/design/brand/Burrow.icon/icon.json b/design/brand/Burrow.icon/icon.json new file mode 100644 index 0000000..b1e196a --- /dev/null +++ b/design/brand/Burrow.icon/icon.json @@ -0,0 +1,20 @@ +{ + "fill": { + "type": "solid", + "color": "#00000000" + }, + "layers": [ + { + "blend-mode": "normal", + "image-name": "owl-figure.png", + "name": "panel-raster", + "position": { + "scale": 1, + "translation-in-points": [ + 0, + 0 + ] + } + } + ] +} diff --git a/design/brand/README.md b/design/brand/README.md new file mode 100644 index 0000000..30094e3 --- /dev/null +++ b/design/brand/README.md @@ -0,0 +1,57 @@ +# Burrow Brand Source + +`design/brand/panel-variants/source-sheet.png` is the locked icon style sheet. +The six cropped PNG masters in `design/brand/panel-variants/` are the canonical +app icon source. Do not redraw these as SVG; regenerate platform outputs from +the raster panel masters. + +`Scripts/generate-brand-icons.py` owns all generated outputs: + +- `Apple/UI/Assets.xcassets/AppIcon.appiconset`: primary iOS and macOS app + icons at exact asset-catalog dimensions. +- `Apple/UI/Assets.xcassets/BurrowPanel*.appiconset`: iOS alternate app icons. +- `Apple/UI/Assets.xcassets/BurrowPanel*Preview.imageset`: in-app selector + previews. +- `design/brand/watchos/AppIcon.appiconset`: watchOS reference app icon catalog + using the selected watchOS panel. +- `Android/app/src/main/res/mipmap-*`: Android launcher PNGs. +- `store-metadata/android/icon.png`: Google Play icon. +- `burrow-gtk/data/icons/hicolor/{16,24,32,48,64,128,256,512}/apps`: Linux + hicolor PNGs. +- `design/brand/low-res`: low-resolution QA exports and preview strips. + +Platform picks: + +- iOS primary: `panel-01-guardian` +- iOS alternates: `panel-02-field`, `panel-03-burrow`, `panel-04-sentinel`, + `panel-05-stride`, `panel-06-post` +- macOS primary: `panel-05-stride` +- watchOS primary: `panel-03-burrow` +- Android primary: `panel-01-guardian` +- Linux primary: `panel-01-guardian` + +Regenerate all package assets from existing masters with: + +```bash +Scripts/generate-brand-icons.py +``` + +If the locked source sheet changes, extract fresh 1024px masters and regenerate +with: + +```bash +Scripts/generate-brand-icons.py --extract-from /path/to/source-sheet.png +``` + +Run low-resolution export QA with: + +```bash +Scripts/check-brand-icon-lowres.sh +``` + +Review these after every icon change: + +- `design/brand/panel-variants/preview-strip.png` +- `design/brand/low-res/preview-strip.png` +- `design/brand/low-res/pixel-preview-strip.png` +- `design/brand/low-res/report.csv` diff --git a/design/brand/burrow-owl-icon-master.png b/design/brand/burrow-owl-icon-master.png new file mode 100644 index 0000000..e335771 Binary files /dev/null and b/design/brand/burrow-owl-icon-master.png differ diff --git a/design/brand/burrowing-owl-concept-v2.png b/design/brand/burrowing-owl-concept-v2.png new file mode 100644 index 0000000..629d4b5 Binary files /dev/null and b/design/brand/burrowing-owl-concept-v2.png differ diff --git a/design/brand/burrowing-owl-icon-flat.png b/design/brand/burrowing-owl-icon-flat.png new file mode 100644 index 0000000..e335771 Binary files /dev/null and b/design/brand/burrowing-owl-icon-flat.png differ diff --git a/design/brand/low-res/burrow-icon-1024.png b/design/brand/low-res/burrow-icon-1024.png new file mode 100644 index 0000000..e335771 Binary files /dev/null and b/design/brand/low-res/burrow-icon-1024.png differ diff --git a/design/brand/low-res/burrow-icon-128.png b/design/brand/low-res/burrow-icon-128.png new file mode 100644 index 0000000..54b67da Binary files /dev/null and b/design/brand/low-res/burrow-icon-128.png differ diff --git a/design/brand/low-res/burrow-icon-16.png b/design/brand/low-res/burrow-icon-16.png new file mode 100644 index 0000000..cf418ae Binary files /dev/null and b/design/brand/low-res/burrow-icon-16.png differ diff --git a/design/brand/low-res/burrow-icon-20.png b/design/brand/low-res/burrow-icon-20.png new file mode 100644 index 0000000..bd3cc95 Binary files /dev/null and b/design/brand/low-res/burrow-icon-20.png differ diff --git a/design/brand/low-res/burrow-icon-24.png b/design/brand/low-res/burrow-icon-24.png new file mode 100644 index 0000000..cfe8e33 Binary files /dev/null and b/design/brand/low-res/burrow-icon-24.png differ diff --git a/design/brand/low-res/burrow-icon-256.png b/design/brand/low-res/burrow-icon-256.png new file mode 100644 index 0000000..561abcb Binary files /dev/null and b/design/brand/low-res/burrow-icon-256.png differ diff --git a/design/brand/low-res/burrow-icon-29.png b/design/brand/low-res/burrow-icon-29.png new file mode 100644 index 0000000..227cb6c Binary files /dev/null and b/design/brand/low-res/burrow-icon-29.png differ diff --git a/design/brand/low-res/burrow-icon-32.png b/design/brand/low-res/burrow-icon-32.png new file mode 100644 index 0000000..52e7a25 Binary files /dev/null and b/design/brand/low-res/burrow-icon-32.png differ diff --git a/design/brand/low-res/burrow-icon-40.png b/design/brand/low-res/burrow-icon-40.png new file mode 100644 index 0000000..c0ef687 Binary files /dev/null and b/design/brand/low-res/burrow-icon-40.png differ diff --git a/design/brand/low-res/burrow-icon-48.png b/design/brand/low-res/burrow-icon-48.png new file mode 100644 index 0000000..68cf88b Binary files /dev/null and b/design/brand/low-res/burrow-icon-48.png differ diff --git a/design/brand/low-res/burrow-icon-64.png b/design/brand/low-res/burrow-icon-64.png new file mode 100644 index 0000000..46872b4 Binary files /dev/null and b/design/brand/low-res/burrow-icon-64.png differ diff --git a/design/brand/low-res/burrow-icon-80.png b/design/brand/low-res/burrow-icon-80.png new file mode 100644 index 0000000..ecf97e9 Binary files /dev/null and b/design/brand/low-res/burrow-icon-80.png differ diff --git a/design/brand/low-res/pixel-preview-16.png b/design/brand/low-res/pixel-preview-16.png new file mode 100644 index 0000000..54cb3a4 Binary files /dev/null and b/design/brand/low-res/pixel-preview-16.png differ diff --git a/design/brand/low-res/pixel-preview-20.png b/design/brand/low-res/pixel-preview-20.png new file mode 100644 index 0000000..3064ac7 Binary files /dev/null and b/design/brand/low-res/pixel-preview-20.png differ diff --git a/design/brand/low-res/pixel-preview-24.png b/design/brand/low-res/pixel-preview-24.png new file mode 100644 index 0000000..139a265 Binary files /dev/null and b/design/brand/low-res/pixel-preview-24.png differ diff --git a/design/brand/low-res/pixel-preview-29.png b/design/brand/low-res/pixel-preview-29.png new file mode 100644 index 0000000..e25f0ad Binary files /dev/null and b/design/brand/low-res/pixel-preview-29.png differ diff --git a/design/brand/low-res/pixel-preview-32.png b/design/brand/low-res/pixel-preview-32.png new file mode 100644 index 0000000..e997e05 Binary files /dev/null and b/design/brand/low-res/pixel-preview-32.png differ diff --git a/design/brand/low-res/pixel-preview-strip.png b/design/brand/low-res/pixel-preview-strip.png new file mode 100644 index 0000000..83a7060 Binary files /dev/null and b/design/brand/low-res/pixel-preview-strip.png differ diff --git a/design/brand/low-res/preview-128.png b/design/brand/low-res/preview-128.png new file mode 100644 index 0000000..41d405f Binary files /dev/null and b/design/brand/low-res/preview-128.png differ diff --git a/design/brand/low-res/preview-16.png b/design/brand/low-res/preview-16.png new file mode 100644 index 0000000..54cb3a4 Binary files /dev/null and b/design/brand/low-res/preview-16.png differ diff --git a/design/brand/low-res/preview-20.png b/design/brand/low-res/preview-20.png new file mode 100644 index 0000000..3064ac7 Binary files /dev/null and b/design/brand/low-res/preview-20.png differ diff --git a/design/brand/low-res/preview-24.png b/design/brand/low-res/preview-24.png new file mode 100644 index 0000000..139a265 Binary files /dev/null and b/design/brand/low-res/preview-24.png differ diff --git a/design/brand/low-res/preview-256.png b/design/brand/low-res/preview-256.png new file mode 100644 index 0000000..474fa4d Binary files /dev/null and b/design/brand/low-res/preview-256.png differ diff --git a/design/brand/low-res/preview-29.png b/design/brand/low-res/preview-29.png new file mode 100644 index 0000000..e25f0ad Binary files /dev/null and b/design/brand/low-res/preview-29.png differ diff --git a/design/brand/low-res/preview-32.png b/design/brand/low-res/preview-32.png new file mode 100644 index 0000000..e997e05 Binary files /dev/null and b/design/brand/low-res/preview-32.png differ diff --git a/design/brand/low-res/preview-40.png b/design/brand/low-res/preview-40.png new file mode 100644 index 0000000..5938193 Binary files /dev/null and b/design/brand/low-res/preview-40.png differ diff --git a/design/brand/low-res/preview-48.png b/design/brand/low-res/preview-48.png new file mode 100644 index 0000000..940f132 Binary files /dev/null and b/design/brand/low-res/preview-48.png differ diff --git a/design/brand/low-res/preview-64.png b/design/brand/low-res/preview-64.png new file mode 100644 index 0000000..4f563f0 Binary files /dev/null and b/design/brand/low-res/preview-64.png differ diff --git a/design/brand/low-res/preview-80.png b/design/brand/low-res/preview-80.png new file mode 100644 index 0000000..4524c81 Binary files /dev/null and b/design/brand/low-res/preview-80.png differ diff --git a/design/brand/low-res/preview-strip.png b/design/brand/low-res/preview-strip.png new file mode 100644 index 0000000..ab83302 Binary files /dev/null and b/design/brand/low-res/preview-strip.png differ diff --git a/design/brand/low-res/report.csv b/design/brand/low-res/report.csv new file mode 100644 index 0000000..7205aeb --- /dev/null +++ b/design/brand/low-res/report.csv @@ -0,0 +1,12 @@ +size,colors,gray_stddev,status +16,182,0.135534,ok +20,247,0.142914,ok +24,325,0.157326,ok +29,436,0.156951,ok +32,504,0.164219,ok +40,691,0.173161,ok +48,868,0.179509,ok +64,1287,0.190366,ok +80,1701,0.198425,ok +128,3115,0.210773,ok +256,6728,0.212284,ok diff --git a/design/brand/panel-variants/README.md b/design/brand/panel-variants/README.md new file mode 100644 index 0000000..ca368bf --- /dev/null +++ b/design/brand/panel-variants/README.md @@ -0,0 +1,16 @@ +# Burrow Raster Panel Icon Variants + +The six PNG masters here are cropped from `source-sheet.png` and are the +locked app icon source. Do not redraw them; regenerate package assets from +these rasters. + +| Variant | Use | Source | +| --- | --- | --- | +| `panel-01-guardian` | iOS primary, Android primary, Linux primary | Guardian, top-left panel | +| `panel-02-field` | iOS alternate | Field, top-middle panel | +| `panel-03-burrow` | iOS alternate, watchOS primary | Burrow, top-right panel | +| `panel-04-sentinel` | iOS alternate | Sentinel, bottom-left panel | +| `panel-05-stride` | iOS alternate, macOS primary | Stride, bottom-middle panel | +| `panel-06-post` | iOS alternate | Post, bottom-right panel | + +`preview-strip.png` shows the six raster masters side by side. diff --git a/design/brand/panel-variants/panel-01-guardian-preview.png b/design/brand/panel-variants/panel-01-guardian-preview.png new file mode 100644 index 0000000..561abcb Binary files /dev/null and b/design/brand/panel-variants/panel-01-guardian-preview.png differ diff --git a/design/brand/panel-variants/panel-01-guardian.png b/design/brand/panel-variants/panel-01-guardian.png new file mode 100644 index 0000000..e335771 Binary files /dev/null and b/design/brand/panel-variants/panel-01-guardian.png differ diff --git a/design/brand/panel-variants/panel-02-field-preview.png b/design/brand/panel-variants/panel-02-field-preview.png new file mode 100644 index 0000000..f6d9feb Binary files /dev/null and b/design/brand/panel-variants/panel-02-field-preview.png differ diff --git a/design/brand/panel-variants/panel-02-field.png b/design/brand/panel-variants/panel-02-field.png new file mode 100644 index 0000000..278575e Binary files /dev/null and b/design/brand/panel-variants/panel-02-field.png differ diff --git a/design/brand/panel-variants/panel-03-burrow-preview.png b/design/brand/panel-variants/panel-03-burrow-preview.png new file mode 100644 index 0000000..76d432e Binary files /dev/null and b/design/brand/panel-variants/panel-03-burrow-preview.png differ diff --git a/design/brand/panel-variants/panel-03-burrow.png b/design/brand/panel-variants/panel-03-burrow.png new file mode 100644 index 0000000..6f40b0a Binary files /dev/null and b/design/brand/panel-variants/panel-03-burrow.png differ diff --git a/design/brand/panel-variants/panel-04-sentinel-preview.png b/design/brand/panel-variants/panel-04-sentinel-preview.png new file mode 100644 index 0000000..36b526c Binary files /dev/null and b/design/brand/panel-variants/panel-04-sentinel-preview.png differ diff --git a/design/brand/panel-variants/panel-04-sentinel.png b/design/brand/panel-variants/panel-04-sentinel.png new file mode 100644 index 0000000..4925f9f Binary files /dev/null and b/design/brand/panel-variants/panel-04-sentinel.png differ diff --git a/design/brand/panel-variants/panel-05-stride-preview.png b/design/brand/panel-variants/panel-05-stride-preview.png new file mode 100644 index 0000000..d919e9c Binary files /dev/null and b/design/brand/panel-variants/panel-05-stride-preview.png differ diff --git a/design/brand/panel-variants/panel-05-stride.png b/design/brand/panel-variants/panel-05-stride.png new file mode 100644 index 0000000..065e8b6 Binary files /dev/null and b/design/brand/panel-variants/panel-05-stride.png differ diff --git a/design/brand/panel-variants/panel-06-post-preview.png b/design/brand/panel-variants/panel-06-post-preview.png new file mode 100644 index 0000000..7c63df0 Binary files /dev/null and b/design/brand/panel-variants/panel-06-post-preview.png differ diff --git a/design/brand/panel-variants/panel-06-post.png b/design/brand/panel-variants/panel-06-post.png new file mode 100644 index 0000000..54336b2 Binary files /dev/null and b/design/brand/panel-variants/panel-06-post.png differ diff --git a/design/brand/panel-variants/preview-strip.png b/design/brand/panel-variants/preview-strip.png new file mode 100644 index 0000000..8ecc2ff Binary files /dev/null and b/design/brand/panel-variants/preview-strip.png differ diff --git a/design/brand/panel-variants/source-sheet.png b/design/brand/panel-variants/source-sheet.png new file mode 100644 index 0000000..a3b6f7f Binary files /dev/null and b/design/brand/panel-variants/source-sheet.png differ diff --git a/design/brand/watchos/AppIcon.appiconset/Contents.json b/design/brand/watchos/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..e3f5ccd --- /dev/null +++ b/design/brand/watchos/AppIcon.appiconset/Contents.json @@ -0,0 +1,140 @@ +{ + "images": [ + { + "filename": "watch-panel-03-48.png", + "idiom": "watch", + "scale": "2x", + "size": "24x24", + "role": "notificationCenter", + "subtype": "38mm" + }, + { + "filename": "watch-panel-03-55.png", + "idiom": "watch", + "scale": "2x", + "size": "27.5x27.5", + "role": "notificationCenter", + "subtype": "42mm" + }, + { + "filename": "watch-panel-03-66.png", + "idiom": "watch", + "scale": "2x", + "size": "33x33", + "role": "notificationCenter", + "subtype": "45mm" + }, + { + "filename": "watch-panel-03-58.png", + "idiom": "watch", + "scale": "2x", + "size": "29x29", + "role": "companionSettings" + }, + { + "filename": "watch-panel-03-87.png", + "idiom": "watch", + "scale": "3x", + "size": "29x29", + "role": "companionSettings" + }, + { + "filename": "watch-panel-03-80.png", + "idiom": "watch", + "scale": "2x", + "size": "40x40", + "role": "appLauncher", + "subtype": "38mm" + }, + { + "filename": "watch-panel-03-88.png", + "idiom": "watch", + "scale": "2x", + "size": "44x44", + "role": "appLauncher", + "subtype": "40mm" + }, + { + "filename": "watch-panel-03-92.png", + "idiom": "watch", + "scale": "2x", + "size": "46x46", + "role": "appLauncher", + "subtype": "41mm" + }, + { + "filename": "watch-panel-03-100.png", + "idiom": "watch", + "scale": "2x", + "size": "50x50", + "role": "appLauncher", + "subtype": "44mm" + }, + { + "filename": "watch-panel-03-102.png", + "idiom": "watch", + "scale": "2x", + "size": "51x51", + "role": "appLauncher", + "subtype": "45mm" + }, + { + "filename": "watch-panel-03-108.png", + "idiom": "watch", + "scale": "2x", + "size": "54x54", + "role": "appLauncher", + "subtype": "49mm" + }, + { + "filename": "watch-panel-03-172.png", + "idiom": "watch", + "scale": "2x", + "size": "86x86", + "role": "quickLook", + "subtype": "38mm" + }, + { + "filename": "watch-panel-03-196.png", + "idiom": "watch", + "scale": "2x", + "size": "98x98", + "role": "quickLook", + "subtype": "42mm" + }, + { + "filename": "watch-panel-03-216.png", + "idiom": "watch", + "scale": "2x", + "size": "108x108", + "role": "quickLook", + "subtype": "44mm" + }, + { + "filename": "watch-panel-03-234.png", + "idiom": "watch", + "scale": "2x", + "size": "117x117", + "role": "quickLook", + "subtype": "45mm" + }, + { + "filename": "watch-panel-03-258.png", + "idiom": "watch", + "scale": "2x", + "size": "129x129", + "role": "quickLook", + "subtype": "49mm" + }, + { + "filename": "watch-panel-03-1024.png", + "idiom": "watch-marketing", + "scale": "1x", + "size": "1024x1024" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/design/brand/watchos/AppIcon.appiconset/watch-panel-03-100.png b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-100.png new file mode 100644 index 0000000..8d72c1b Binary files /dev/null and b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-100.png differ diff --git a/design/brand/watchos/AppIcon.appiconset/watch-panel-03-102.png b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-102.png new file mode 100644 index 0000000..d5ac27c Binary files /dev/null and b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-102.png differ diff --git a/design/brand/watchos/AppIcon.appiconset/watch-panel-03-1024.png b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-1024.png new file mode 100644 index 0000000..6f40b0a Binary files /dev/null and b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-1024.png differ diff --git a/design/brand/watchos/AppIcon.appiconset/watch-panel-03-108.png b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-108.png new file mode 100644 index 0000000..c9613d1 Binary files /dev/null and b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-108.png differ diff --git a/design/brand/watchos/AppIcon.appiconset/watch-panel-03-172.png b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-172.png new file mode 100644 index 0000000..995ec8b Binary files /dev/null and b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-172.png differ diff --git a/design/brand/watchos/AppIcon.appiconset/watch-panel-03-196.png b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-196.png new file mode 100644 index 0000000..676a117 Binary files /dev/null and b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-196.png differ diff --git a/design/brand/watchos/AppIcon.appiconset/watch-panel-03-216.png b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-216.png new file mode 100644 index 0000000..90e53cb Binary files /dev/null and b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-216.png differ diff --git a/design/brand/watchos/AppIcon.appiconset/watch-panel-03-234.png b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-234.png new file mode 100644 index 0000000..9fb18c5 Binary files /dev/null and b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-234.png differ diff --git a/design/brand/watchos/AppIcon.appiconset/watch-panel-03-258.png b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-258.png new file mode 100644 index 0000000..9eca1be Binary files /dev/null and b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-258.png differ diff --git a/design/brand/watchos/AppIcon.appiconset/watch-panel-03-48.png b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-48.png new file mode 100644 index 0000000..6eb1304 Binary files /dev/null and b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-48.png differ diff --git a/design/brand/watchos/AppIcon.appiconset/watch-panel-03-55.png b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-55.png new file mode 100644 index 0000000..147f62c Binary files /dev/null and b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-55.png differ diff --git a/design/brand/watchos/AppIcon.appiconset/watch-panel-03-58.png b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-58.png new file mode 100644 index 0000000..1efe951 Binary files /dev/null and b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-58.png differ diff --git a/design/brand/watchos/AppIcon.appiconset/watch-panel-03-66.png b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-66.png new file mode 100644 index 0000000..32d7b01 Binary files /dev/null and b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-66.png differ diff --git a/design/brand/watchos/AppIcon.appiconset/watch-panel-03-80.png b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-80.png new file mode 100644 index 0000000..37337e7 Binary files /dev/null and b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-80.png differ diff --git a/design/brand/watchos/AppIcon.appiconset/watch-panel-03-87.png b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-87.png new file mode 100644 index 0000000..e37171c Binary files /dev/null and b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-87.png differ diff --git a/design/brand/watchos/AppIcon.appiconset/watch-panel-03-88.png b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-88.png new file mode 100644 index 0000000..5c8da72 Binary files /dev/null and b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-88.png differ diff --git a/design/brand/watchos/AppIcon.appiconset/watch-panel-03-92.png b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-92.png new file mode 100644 index 0000000..74b9a60 Binary files /dev/null and b/design/brand/watchos/AppIcon.appiconset/watch-panel-03-92.png differ diff --git a/docs/DISTRIBUTION.md b/docs/DISTRIBUTION.md new file mode 100644 index 0000000..7ef29f5 --- /dev/null +++ b/docs/DISTRIBUTION.md @@ -0,0 +1,135 @@ +# Distribution + +Burrow distribution is split by platform authority. + +## Apple + +macOS, iOS, and visionOS builds use the Apple app plus NetworkExtension packet +tunnel provider. App Store and TestFlight upload lanes stay separate from build +lanes so signing, export, metadata, and external distribution are visible. + +Developer ID signing is moving to a KMS-backed key path. The +`apple-developer-id-application` key in the Burrow `burrow-identity` Google KMS +key ring is non-exportable and can produce a standard Apple CSR through +`Scripts/apple/google-kms-csr.py` or the manual Forgejo +`apple-developer-id-kms-csr.yml` workflow. The active G2 Developer ID +Application certificate is `9JKN6HXBHC`, stored as public material at +`Apple/Certificates/developer-id-application-9JKN6HXBHC.cer`, and expires on +`2031-06-08`. + +App Store iOS signing uses the same non-exportable model. The +`apple-ios-distribution` key in the Burrow identity key ring produced the active +`IOS_DISTRIBUTION` certificate `3G42677598`, stored as public material at +`Apple/Certificates/ios-distribution-3G42677598.cer`, and expires on +`2027-06-07`. App Store Connect certificate creation can be driven by +`Scripts/apple/create-asc-certificate.mjs` once a KMS-backed CSR has been +generated. + +When `BURROW_IOS_DISTRIBUTION_CERTIFICATE_ID` is set, provisioning-profile sync +pins iOS App Store profiles to that certificate. Existing App Store profiles +with the same name are deleted and recreated if Apple reports that they contain +a different distribution certificate. + +Sparkle appcast signing keeps the `sparkle-ed25519` Google KMS key available +for payloads small enough for direct KMS Ed25519 signing, but normal macOS +release archives are larger than Google KMS accepts for direct Ed25519 +messages. Those archives are signed directly from the decrypted release +`SPARKLE_EDDSA_KEY_PATH` seed so Sparkle receives the standard +full-archive EdDSA signature it verifies at update time. macOS release builds +embed public EdDSA key +`uugZuJeqvvKd91NZ6F1Fv2cQenUbIG/ZW3L9MuaEz30=` and point Sparkle metadata at +`https://releases.burrow.net/sparkle/appcast.xml`. The appcast signer runs only +when `BURROW_SPARKLE_SIGN_WITH_KMS=true` so unsigned local validation artifacts +do not require Google credentials. + +This is not equivalent to the existing `.p12` keychain import path. The current +Xcode packaging lane can still use exportable signing assets, while the +KMS-backed Apple certificates require a follow-up signer integration that can +ask Google KMS to produce code signatures without exporting the private key. + +## Android + +Android starts with a Kotlin shell and Rust core FFI stub. Full VPN support must +use Android `VpnService`, which means Play Store builds need the VPN service +declaration, clear in-app disclosure, and data-safety review before upload. + +## Linux + +The GTK app is the desktop UI. For VPN operation, it should talk to a host +daemon or privileged helper that owns TUN, routes, DNS, and firewall state. + +Flatpak can package the GUI, but it should not be treated as the privileged data +plane. The preferred Linux shape is: + +- native packages install `burrowd`, the systemd unit/socket, D-Bus policy, and + polkit policy +- the Flatpak GUI talks to the host service over a narrowly named D-Bus API or a + constrained local daemon socket +- the daemon performs privileged operations only after polkit authorizes the + user action + +A Flatpak build can either: + +- connect to a system/user Burrow daemon over a constrained local API +- ask a host-installed helper to start or configure the daemon through a + reviewed D-Bus policy +- stay as a configuration/status UI when no helper is installed + +It should not silently install native packages. PackageKit can be an optional +bootstrap path on distros where the native Burrow daemon package is available, +PackageKit is installed, and the Flatpak has a narrow +`org.freedesktop.PackageKit` system-bus permission. That path is a convenience, +not the baseline, because it is distro-dependent and still requires native +package trust and polkit authorization. + +The native repository plan is now: + +- `packages.burrow.net/apt` for Debian-family packages +- `packages.burrow.net/rpm//` for RPM-family packages +- `packages.burrow.net/arch/burrow/` for pacman binary packages +- `aur.archlinux.org/burrow-git.git` for the Arch source-build package +- a Flatpak repository descriptor for the GTK GUI, paired with the native daemon +- the NixOS flake/module for declarative NixOS installs + +Package repository signing is split by repository format. Google Cloud KMS owns +non-exportable RSA signing keys for APT, RPM, pacman, Flatpak, and AUR source +surfaces. The current repository builder signs APT `Release`, RPM `repomd.xml`, +and pacman database/package sidecar signatures through the KMS OpenPGP bridge. +Embedded RPM package signatures and Flatpak OSTree summary signing still need a +dedicated implementation pass before those channels are promoted beyond +staging. + +Release artifacts and signed repository trees publish through repo-owned storage +wrappers. Garage is the required S3-compatible primary target; GCS remains the +first backup target through buckets owned by `infra/releases`: +`burrow-net-releases` for build artifacts and `burrow-net-packages` for package +repositories. CI authenticates with Authentik-backed Google Workload Identity +Federation before using Google KMS or `gcloud storage`; no Google +service-account JSON key or rclone transport is part of the release path. + +An AppImage may be useful as a portable GUI on distributions without current +Flatpak support, but it has the same daemon boundary as Flatpak. NixOS should +prefer the flake/module path so daemon, policy, and service activation are +declarative. + +## F-Droid and Play Store + +F-Droid should build from source with reproducible metadata and no proprietary +Play dependencies in the free flavor. Play Store can use the same Rust core but +requires the Play policy path for `VpnService`. + +## Flatpak + +Flatpak distribution is useful for desktop reach, but the app sandbox does not +grant route, DNS, or TUN authority by itself. Burrow should publish Flatpak only +with clear daemon/helper requirements until a real desktop smoke test proves the +full flow. + +Flatpak can start child processes inside its sandbox and can request background +or autostart permission for the Flatpak app. That is not enough for the VPN data +plane. Starting the host daemon belongs to one of these paths: + +- systemd socket or D-Bus activation installed by the native package +- explicit D-Bus call to a host helper with narrow permissions and polkit +- PackageKit-assisted native package install where supported +- manual native package install instructions opened from the GUI diff --git a/docs/GETTING_STARTED.md b/docs/GETTING_STARTED.md index 346f7e7..e36bbad 100644 --- a/docs/GETTING_STARTED.md +++ b/docs/GETTING_STARTED.md @@ -75,7 +75,7 @@ rustup toolchain install stable-msvc 1. Clone the repository: ``` -git clone git@github.com:hackclub/burrow.git +git clone https://git.burrow.net/hackclub/burrow.git ``` 2. Open the `burrow` folder in Visual Studio Code: diff --git a/docs/GTK_APP.md b/docs/GTK_APP.md index 582b0a2..a22f8fc 100644 --- a/docs/GTK_APP.md +++ b/docs/GTK_APP.md @@ -1,7 +1,10 @@ # Linux GTK App Getting Started -Currently, the GTK App can be built as a binary or as an AppImage. -Note that the flatpak version can compile but will not run properly! +Currently, the GTK App can be built as a binary or as an AppImage. The Flatpak +lane is a GUI packaging target until Burrow has a verified host daemon/helper +path for TUN, routes, DNS, and firewall state. The intended Flatpak behavior is +to discover and talk to a native Burrow daemon installed by DEB, RPM, or the +NixOS flake/module, not to own privileged routing itself. ## Dependencies diff --git a/docs/NIX_CACHE.md b/docs/NIX_CACHE.md new file mode 100644 index 0000000..96862c3 --- /dev/null +++ b/docs/NIX_CACHE.md @@ -0,0 +1,88 @@ +# Burrow Nix Cache + +`nix.burrow.net` is the Burrow Nix binary cache surface for forge jobs and +workers. + +The host layout is: + +- Garage stores objects on the forge host's Garage data volume. +- Attic serves the Nix binary cache API at `nix.burrow.net`. +- Attic stores NAR chunks in the Garage `attic` bucket through the local S3 API. +- Workers consume `https://nix.burrow.net/burrow` as a substituter once the + cache public key is configured. + +Garage is not a multi-backend object sync manager. It can replicate across +Garage nodes, but it does not write the same object to GCS and another provider +as independent storage backends. Multi-cloud backup should be a separate mirror +or export job from Garage buckets to GCS and later to additional providers. + +## Host Bootstrap + +`services.burrow.garage` creates a host-local environment file at +`/var/lib/burrow/garage/env`. The file is not stored in Git or the Nix store. +It contains: + +- Garage RPC secret +- Garage access keys for Attic, release artifacts, package repositories, and + read-only backups +- Attic JWT signing secret +- AWS-compatible variables used by Attic to talk to Garage + +`burrow-garage-bootstrap.service` creates the initial single-node Garage layout, +imports the generated keys, and creates the `attic`, `burrow-releases`, and +`burrow-packages` buckets. It grants the backup key read-only access to those +three buckets so CI can mirror them without receiving owner/write access to +Garage. + +`services.burrow.nixCache` enables Attic, points it at Garage, exposes it through +Caddy, creates a public `burrow` cache, and writes two host-local tokens: + +- `/var/lib/burrow/nix-cache/admin-token`: bootstrap/admin recovery token +- `/var/lib/burrow/nix-cache/ci-push-token`: scoped pull/push token for the + `burrow` cache + +## Worker Configuration + +`Scripts/ci/ensure-nix.sh` uses the Burrow cache only when +`BURROW_NIX_CACHE_PUBLIC_KEY` is present: + +```sh +BURROW_NIX_CACHE_URL=https://nix.burrow.net/burrow +BURROW_NIX_CACHE_PUBLIC_KEY= +``` + +Without the public key, CI falls back to `cache.nixos.org` only. This avoids +configuring an unsigned or untrusted substituter. + +After deployment, get the public key from the host: + +```sh +attic cache info local:burrow +``` + +Then set `BURROW_NIX_CACHE_PUBLIC_KEY` in Forgejo variables. + +Seal the scoped push token from `/var/lib/burrow/nix-cache/ci-push-token` into +Forgejo/OpenBao as `BURROW_NIX_CACHE_PUSH_TOKEN`. The +`Cache: Publish Nix` workflow runs `Scripts/ci/publish-nix-cache.sh`, builds the +selected flake outputs, and pushes their closures to Attic. It skips cleanly +when the push token is absent unless `BURROW_NIX_CACHE_REQUIRED=true`. + +## Backups + +The Garage `attic` bucket is backed up to the private GCS bucket +`burrow-net-nix-cache`. Release artifacts and package repositories are backed up +to their public GCS buckets. The scheduled `Backup: Garage Storage` workflow +runs `Scripts/ci/backup-garage-to-gcs.sh` with: + +```sh +BURROW_GARAGE_ENDPOINT=https://objects.burrow.net +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +BURROW_NIX_CACHE_GCS_BUCKET=burrow-net-nix-cache +``` + +The workflow authenticates to Google through Authentik-backed WIF and uses +`gcloud storage rsync`. It does not use rclone or Google service-account JSON +keys. Destination deletes are disabled by default; set +`BURROW_GARAGE_BACKUP_DELETE=true` only for an intentional prune run. diff --git a/docs/OBSERVABILITY.md b/docs/OBSERVABILITY.md new file mode 100644 index 0000000..04a17b3 --- /dev/null +++ b/docs/OBSERVABILITY.md @@ -0,0 +1,60 @@ +# Burrow Observability + +The forge host imports `services.burrow.observability`, which wires the first +production observability spine: + +- Prometheus on `127.0.0.1:9090` +- OpenTelemetry collector OTLP gRPC on `127.0.0.1:4317` +- OpenTelemetry collector OTLP HTTP on `127.0.0.1:4318` +- collector Prometheus export on `127.0.0.1:9464` +- Jaeger all-in-one on local ports only +- Grafana at `graphs.burrow.net`, backed by Authentik SSO + +Grafana datasources are provisioned by NixOS: + +- `prometheus` points at local Prometheus +- `jaeger` points at the local Jaeger query API + +OpenTofu owns checked-in dashboards under `services/grafana/dashboards/`: + +- `burrow-overview.json` +- `headscale.json` +- `observability.json` + +## Metrics + +Prometheus scrapes: + +- Prometheus self metrics +- node exporter +- systemd exporter +- Grafana `/metrics` +- Headscale `/metrics` on `127.0.0.1:9098` +- OpenTelemetry collector metrics +- Jaeger admin metrics +- Garage admin metrics when `services.burrow.garage.enable = true` +- the optional Tailscale exporter when its OAuth environment file is configured + +Headscale and Tailscale are treated as the same Tailnet family in dashboards. +Headscale exposes a local Prometheus listener through +`services.burrow.headscale.enableMetrics`. Tailscale SaaS metrics require the +NixOS Tailscale exporter and an OAuth environment file; the module leaves that +disabled until the credential is provisioned. + +## Traces + +Burrow services that emit OpenTelemetry traces should use: + +```sh +OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4317 +OTEL_EXPORTER_OTLP_PROTOCOL=grpc +OTEL_SERVICE_NAME=burrow +``` + +The collector exports traces to Jaeger. Jaeger is intentionally local-only for +now; Grafana can query it server-side through the provisioned datasource. + +Headscale and Tailscale currently enter the spine through Prometheus metrics and +systemd state. If an upstream Tailnet component starts emitting OTLP, point it +at the same local collector endpoint rather than exposing Jaeger or Prometheus +directly. diff --git a/docs/PLATFORM_SERVICES.md b/docs/PLATFORM_SERVICES.md new file mode 100644 index 0000000..b4d1304 --- /dev/null +++ b/docs/PLATFORM_SERVICES.md @@ -0,0 +1,99 @@ +# Platform Services + +Burrow's next platform layer is split into service boundaries that can be +enabled independently after their security and rollback checks pass. + +## Identity and KMS + +`infra/identity` owns Google Cloud KMS and Workload Identity Federation +resources for the Burrow Google project: + +- project id: `project-88c23ce9-918a-470a-b33` +- project number: `416198671487` +- key ring: `burrow-identity` +- intended keys: Authentik signing, SAML CA signing, release signing + +The WIF path is for Authentik-backed Forgejo runners. Runners should exchange an +OIDC token for a short-lived Google credential instead of carrying static +service-account JSON. + +Release storage uses provider-neutral upload wrappers. Garage is the required +S3-compatible primary target. GCS is the first backup target and remains the +compatibility source for current +Sparkle/store follow-on jobs: + +- release artifacts: `burrow-net-releases` +- signed package repositories: `burrow-net-packages` +- private Nix cache backup: `burrow-net-nix-cache` + +Forgejo jobs authenticate to the same Google project through Authentik-backed +WIF, then use `gcloud storage` for upload/download and Google KMS for release +and repository signatures. No rclone transport or Google service-account JSON +key is part of the release path. + +`services.burrow.garage` is enabled by the forge host. It provides the host +activation point for Garage API, static-web, and admin listeners, and +bootstraps the initial single-node layout plus the `attic`, `burrow-releases`, +and `burrow-packages` buckets. It creates separate owner/write keys for Attic, +release artifacts, and package repositories, plus a read-only backup key for +the scheduled Garage-to-GCS mirror. + +Garage is now the primary object-storage surface for release/package uploads and +the Nix cache. It uses host-local storage for object data and metadata; it does +not fan out writes to multiple object-store backends. Multi-cloud failover +should be implemented as explicit Garage bucket mirrors/backups, with GCS as the +first backup target. + +## Nix Cache + +`nix.burrow.net` is the Burrow Nix binary cache surface. The forge host runs +Attic behind Caddy and stores cache chunks in the Garage `attic` bucket through +Garage's local S3 API. Workers can use `https://nix.burrow.net/burrow` once the +cache public key is published as `BURROW_NIX_CACHE_PUBLIC_KEY` in Forgejo. The +host bootstrap also creates `/var/lib/burrow/nix-cache/ci-push-token`; seal it +as `BURROW_NIX_CACHE_PUSH_TOKEN` before enabling broad cache publication. + +## Observability + +`graphs.burrow.net` is backed by Grafana with Authentik SSO. The forge host now +imports `services.burrow.observability`, which starts local Prometheus, +OpenTelemetry collector, and Jaeger services. NixOS provisions Grafana +datasources; OpenTofu manages checked-in dashboards for the Burrow overview, +Headscale, and the broader Prometheus/OpenTelemetry/Jaeger spine. + +Jaeger is local-only at first and is queried through Grafana. Headscale metrics +are scraped locally. Tailscale SaaS metrics are optional until the OAuth +credential file exists. + +## OpenBao + +`vault.burrow.net` is the planned OpenBao surface. The repository now has: + +- `infra/openbao` for KMS seal wrapping and OpenBao auth/policy resources +- `services.burrow.openbao` as a disabled-by-default NixOS switch point +- `Scripts/openbao-tofu.sh` for stack-local OpenTofu operations + +OpenBao should not be enabled until the KMS seal key, bootstrap token handling, +backup/restore procedure, and Authentik roles are verified. + +## Jitsi Meet + +`meet.burrow.net` is the planned Jitsi Meet surface. The repository now has +`services.burrow.jitsi` as a disabled-by-default NixOS switch point. + +Jitsi is not just an HTTP service. The rollout needs DNS, TLS, XMPP/prosody +state, and an explicit UDP media-port decision before activation. + +## Mail and Webmail + +`inbox.burrow.net` is the intended webmail surface. Stalwart is the planned mail +server, but this flake does not currently expose the expected Stalwart NixOS +option. Forward Email remains the current production mail path until the +Stalwart module name, ports, DKIM rotation, backup target, spam policy, and +migration steps are pinned in a follow-up BEP update. + +## MCP Hub + +The MCP hub should be extracted to `compatible.systems/burrow/mcp-hub`. Until +that repository exists, `services/mcp-hub/` records the extraction boundary and +tool inventory. diff --git a/evolution/proposals/BEP-0009-release-infrastructure-and-store-upload-pipeline.md b/evolution/proposals/BEP-0009-release-infrastructure-and-store-upload-pipeline.md new file mode 100644 index 0000000..4d8f5c9 --- /dev/null +++ b/evolution/proposals/BEP-0009-release-infrastructure-and-store-upload-pipeline.md @@ -0,0 +1,374 @@ +# `BEP-0009` - Release Infrastructure and Store Upload Pipeline + +```text +Status: Draft +Proposal: BEP-0009 +Authors: gpt-5.5 +Coordinator: gpt-5.5 +Reviewers: Pending +Constitution Sections: II, III, IV, V +Implementation PRs: Pending +Decision Date: Pending +``` + +## Summary + +Burrow needs a release pipeline that behaves like the project infrastructure it is replacing: release eligibility is detected from forge build tags, build artifacts are produced per platform, upload lanes are separate from build lanes, and store credentials are explicit automation inputs rather than hidden local state. + +The first implementation creates the release spine now: `release-if-needed` dispatches a build when HEAD has not been tagged as released, `build-release` packages current artifacts on Namespace-backed runners, and `publish-store-uploads` performs guarded upload steps for App Store Connect, Sparkle, Microsoft Store, and storage-backed public channels after Authentik-backed Google WIF authentication. + +The same change also makes the forge itself the release authority: release tags prefer the Burrow Forgejo remote, dispatch helpers talk to Forgejo directly with a live-host fallback, runner identity is discoverable from persistent host state, repository mirror sync is disabled for the canonical Burrow repository, `nix.burrow.net` provides a Burrow-owned Nix cache for workers, and Grafana observability is bootstrapped with Nix-owned Prometheus/OpenTelemetry/Jaeger service state plus OpenTofu-owned dashboards. + +## Motivation + +- Burrow already controls its forge and runner infrastructure, but the release path only produced a Linux CLI tarball. +- Apple, Linux, Sparkle, and future Windows outputs need the same build-number and artifact layout so release evidence is inspectable. +- The Namespace account should be part of the live runner surface, including macOS and Windows lanes, instead of sitting idle behind unused configuration. +- Authentication and store credentials should be named and checked at lane boundaries so dedicated accounts can be added without rewriting workflows. + +## Detailed Design + +- Use lightweight `builds/` tags as the authoritative release watermark. +- Keep `Scripts/version.sh status` as the release-needed check: + - `clean` means HEAD is exactly the latest authoritative build tag. + - `dirty` means the release workflow should create a new build number. +- Split workflows: + - `.forgejo/workflows/release-if-needed.yml` checks release status on a + schedule and on pushes to `main`, then dispatches `build-release.yml` when + HEAD is unreleased. + - `.forgejo/workflows/build-release.yml` builds and stages artifacts, and + defaults App Store Connect upload handoff on unless the dispatch explicitly + disables it. + - `.forgejo/workflows/publish-store-uploads.yml` uploads staged artifacts to + external stores and public channels, with App Store Connect upload enabled + by default for manual dispatches and release handoffs. +- Stage artifacts under `dist/builds///`. +- Publish generic release assets to a Forgejo release named `Build `. +- Upload release artifacts through `Scripts/ci/upload-release-storage.sh`. The wrapper requires Garage as the primary S3-compatible target by default, then mirrors to the `burrow-net-releases` GCS backup bucket unless `BURROW_RELEASE_GCS_BACKUP=false`. +- Publish signed package repository trees through `Scripts/ci/upload-package-storage.sh`. The wrapper requires Garage as the primary S3-compatible target by default, then mirrors to the `burrow-net-packages` GCS backup bucket unless `BURROW_PACKAGE_GCS_BACKUP=false`. +- Publish selected Nix closures through `.forgejo/workflows/publish-nix-cache.yml` and `Scripts/ci/publish-nix-cache.sh`. The workflow logs into `nix.burrow.net` with the scoped `BURROW_NIX_CACHE_PUSH_TOKEN` generated by host bootstrap and skips when the token is absent unless explicitly required. +- Mirror Garage buckets through `.forgejo/workflows/backup-garage-storage.yml` and `Scripts/ci/backup-garage-to-gcs.sh`. The scheduled workflow uses the host-generated Garage read-only backup key, Authentik-backed Google WIF, and `gcloud storage rsync` to back up `burrow-releases`, `burrow-packages`, and `attic` to GCS. +- Build Apple artifacts on `namespace-profile-macos-large` through Bazel wrapper targets: + - `//bazel/apple:release_ios_stamp` + - `//bazel/apple:release_macos_stamp` + These targets wrap the existing Xcode project and give the workflow one stable entrypoint that shares the same Bazel/Nix cache setup while Burrow decides whether deeper `rules_apple` targets are worth the migration. +- Use Namespace cache setup before Bazel/Nix work. Prefer the Namespace Bazel remote cache when `nsc` is authenticated and fall back to a local disk/repository cache when remote setup is unavailable. + Cache setup is optional release acceleration: Bazel-only cache steps must not + install filesystem-cache helpers such as `spacectl`, and Namespace cache + probes must be timeout-bounded so Apple builds can continue without the + remote cache. Apple workflows should call the fail-open cache helper directly + instead of entering the full Nix development shell just to decide whether a + cache is available. macOS runners should use the local Bazel disk/repository + cache path and skip the `nsc` remote-cache auth probe, which is optional and + can block without GNU timeout support. +- The Nix CI shell must not pin Apple builds to a Bazel major that disagrees + with `.bazelversion`. Prefer Bazelisk or a Bazel 9 package so the release + lane uses the repository-declared Bazel 9.1.0 toolchain. +- Moving tarball URLs are not acceptable for release-critical Nix inputs. The + forge worker lockfile must resolve nixpkgs through a fixed Git revision so + fresh workers do not fail when a branch tarball no longer matches a stored + NAR hash. +- The CI shell should prefer currently supported Node runtimes when nixpkgs + marks an older major insecure. Release workers must fail on product build + errors, not on avoidable toolchain end-of-life policy checks. +- Bazel repository and disk caches must live outside the checked-out repository + on macOS runners. Bazel 9 rejects a repository contents cache inside the main + repo because it can create spurious build graph failures. +- Bazel Apple genrules must explicitly pass the Nix CI shell tool path and + `PROTOC` into the action environment. Xcode build phases run with a reduced + path, and the Rust Network Extension build depends on `protoc`. +- Forgejo release workflows must use the artifact action generation supported + by the deployed forge. The v4 artifact actions assume GitHub's newer artifact + service and fail on this Forgejo install before downstream signing/upload + jobs can consume the staged Apple artifacts. +- The release secret decrypt action must be self-contained after the Nix + bootstrap step. Linux Namespace signing jobs install Nix at runtime, so the + bootstrap writes Nix profile directories to `GITHUB_PATH`, the decrypt action + resolves Nix from those profile paths, and the action builds `.#age` before + falling back to `.#agenix`. The decrypt step must not require Python before + the Nix CI shell is active. +- Authentik-backed Google WIF must exchange tokens against Authentik's OAuth + token endpoint, not a provider-slug child path. The helper should prefer an + explicit `BURROW_AUTHENTIK_WIF_TOKEN_ENDPOINT`, then OIDC discovery, then the + Authentik `/application/o/token/` fallback derived from the configured issuer. +- The Google WIF Authentik application is a machine-to-machine + client-credentials provider. It must not default to a human group policy + binding, because the token exchange has no interactive user and Authentik will + reject the grant before Google WIF can validate the issued JWT. +- Forgejo should store the Authentik WIF credential as the client-credentials + `client_secret` form value. For service-account authentication, that value is + `base64(":")`; the helper must + send it as form data, not HTTP Basic auth. +- Produce unsigned Apple validation artifacts when signing is absent, but require signing for an App Store requested iOS release and for a Sparkle tester release. Uploadable artifacts are produced only after provisioning profiles can be synced from App Store Connect credentials and the relevant Apple certificate is proven to match the selected Google KMS key. +- Resolve release credentials through age/agenix before signed Apple lanes run. Forgejo secrets should carry only the runner age identity fallback and the Authentik WIF client secret until OpenBao can mint the runner token directly. App Store Connect keys and signing certificates live as sealed files under `secrets/`. +- Persist the forge runner SSH key as `/var/lib/forgejo-runner-agent/age_keystore` and export `BURROW_RUNNER_AGE_IDENTITY_PATH` so jobs can resolve agenix identities without embedding long-lived material in every workflow. +- Add `Scripts/forgejo-dispatch.sh` and `Scripts/forgejo-dispatch-via-host.sh`: + - local dispatch uses an explicit token, local intake token, or the sealed forgejo-nsc dispatcher config when available; + - host fallback SSHes to the live forge and reads the agenix-materialized dispatcher config there; + - neither path relies on a GitHub remote or GitHub workflow API. +- Default build tag reads and pushes to the Burrow Forgejo remote when that remote exists. `BURROW_VERSION_REMOTE` remains the override for unusual migrations. +- Keep the canonical Forgejo repo as an ordinary source repository, not a mirror. The host config disables new mirror creation and removes mirror/push-mirror rows for the canonical Burrow repository at activation time. +- Add `.forgejo/workflows/infra-opentofu.yml` and `Scripts/grafana-tofu.sh` for Grafana API-managed folders and dashboards. NixOS owns the Grafana service, SSO, reverse proxy, datasources, Prometheus, OpenTelemetry collector, Jaeger, secrets, and boot-time configuration; OpenTofu owns API-created dashboard objects. +- Sync provisioning profiles from App Store Connect in CI using the decrypted API key: + - iOS App Store profiles for `net.burrow.app` and `net.burrow.app.network`. + - macOS Developer ID profiles for the same bundle identifiers. + Provisioning profile `.age` files are not part of the normal release path. +- Add a non-exportable Google KMS RSA-2048/SHA-256 key named + `apple-developer-id-application` in the Burrow identity key ring. The manual + `apple-developer-id-kms-csr.yml` workflow uses Authentik-backed Google WIF to + generate a standard Developer ID Application CSR without exporting private key + material. +- Treat Developer ID certificate issuance as a Developer website or Xcode step + until Apple documents App Store Connect API creation for Developer ID + certificates. The returned `.cer` is public release material; the private key + remains in Google KMS and must not be converted into `.p12` form. +- The first KMS-backed G2 Developer ID Application certificate is + `9JKN6HXBHC`, stored at + `Apple/Certificates/developer-id-application-9JKN6HXBHC.cer`, and expires on + `2031-06-08`. +- Add a non-exportable Google KMS RSA-2048/SHA-256 key named + `apple-ios-distribution` in the Burrow identity key ring. The KMS-backed CSR + can be submitted through the App Store Connect API with + `Scripts/apple/create-asc-certificate.mjs`. +- The first KMS-backed iOS Distribution certificate is `3G42677598`, stored at + `Apple/Certificates/ios-distribution-3G42677598.cer`, and expires on + `2027-06-07`. +- When `BURROW_IOS_DISTRIBUTION_CERTIFICATE_ID` is set, provisioning-profile + sync must verify App Store profiles reference that certificate. Stale profiles + with the same name may be deleted and recreated so CI does not silently sign + against an older distribution identity. +- Apple release signing uses a staged KMS flow because Google publishes the + Cloud KMS PKCS#11 library for Linux release runners, not macOS runners: + - macOS Namespace builders compile unsigned iOS device and macOS app bundles + with the existing Xcode project. + - Linux release runners download those staged artifacts, authenticate to + Google through Authentik WIF, verify the Apple `.cer` public key matches the + intended Google KMS key version, embed the synced provisioning profiles, and + sign the app/extension bundles with the patched `rcodesign` PKCS#11 path. + - The signed iOS IPA is uploaded to App Store Connect, and the signed macOS + ZIP is used as the Sparkle tester artifact. +- Add a Google KMS key named `sparkle-ed25519` for small Sparkle signing probes + and future signing-service work. It uses `EC_SIGN_ED25519` with software + protection level because Google KMS rejects Ed25519 for HSM protection. Google + KMS also rejects normal macOS release archives as direct Ed25519 messages, so + the tester pipeline signs full-size Sparkle archives directly from the + decrypted `SPARKLE_EDDSA_KEY_PATH` release seed until a compatible KMS-backed + Sparkle signing service is introduced. macOS builds embed public EdDSA key + `uugZuJeqvvKd91NZ6F1Fv2cQenUbIG/ZW3L9MuaEz30=`. +- Use Namespace labels for platform lanes: + - `namespace-profile-linux-medium` + - `namespace-profile-macos-large` + - `namespace-profile-windows-large` +- Use dedicated Apple distribution labels for the focused tester-distribution + workflow so stale generic Namespace jobs cannot consume Apple release runners: + - `namespace-profile-linux-medium-apple-v2` + - `namespace-profile-macos-large-apple-v2` + Label revisions are allowed when earlier accepted workflows have stale + queued jobs; the autoscaler should serve only the current focused label set. +- Configure macOS Namespace targets with the Compute API CPU-by-memory shape + format. `12x28` is the Burrow large macOS baseline; platform-prefixed values + such as `macos/arm64:8x16` are not accepted by the macOS launcher. +- Treat macOS shape fallback as part of the release lane rather than as a + best-effort debug path. When large shapes are quota-constrained, the + dispatcher may try smaller accepted shapes, but every fallback must have a + bounded create timeout and additional shapes must reuse the final timeout + policy instead of crashing the dispatcher. +- Keep the shared Linux runner work directory out of macOS bootstraps. The + dispatcher normalizes macOS runners to `/tmp/forgejo-runner` when the shared + config points at Linux state paths such as `/var/lib/forgejo-runner`. +- Do not destroy Namespace Linux runners until `nsc describe` shows a real + terminal container state or tombstone. Empty describe payloads mean the + environment is still starting, not that the one-job runner has finished. +- Keep the autoscaler-to-dispatcher HTTP timeout longer than the runner TTL. + Dispatch requests intentionally block until the one-job runner exits, so short + HTTP client timeouts cancel macOS provisioning mid-bootstrap. +- Run forge Namespace services with the repo-owned `nsc` package and keep it + current with the token format expected by Namespace. `nsc 0.0.520` is the + first required baseline for revokable token-file auth. The dispatcher and + autoscaler systemd units must also use the repo-built packages so runner fixes + ship with Burrow deploys instead of staying pinned to the module input. +- Render the sealed Namespace runner token with `nsc token create --token_file` + instead of `nsc auth generate-dev-token`. The dev-token output is for direct + API/registry access, while the dispatcher needs the JSON token-file format + consumed by `nsc run`. +- Add a Rust `burrow-windows-stub` binary so the Windows lane can validate packaging and upload mechanics before native Windows networking support is implemented. +- Treat Sparkle as a macOS public-channel upload lane: + - Generate staged appcast content from the signed macOS artifact when present. + - Publish `sparkle//`, `sparkle/appcast.xml`, and `sparkle/default/` pointers from `publish-store-uploads`. + - The macOS app embeds Sparkle and consumes the `https://releases.burrow.net/sparkle/appcast.xml` feed. +- Treat TestFlight distribution as a retryable post-upload step. Apple build + processing can exceed 30 minutes after a successful IPA upload, so + `apple-distribute-testers` and `publish-store-uploads` wait up to 7200 + seconds by default and allow Forgejo variable + `TESTFLIGHT_WAIT_PROCESSING_TIMEOUT_SECONDS` to tune that ceiling without a + repo change. TestFlight wait jobs must use `namespace-profile-linux-testflight` + or `namespace-profile-macos-large-testflight`; the generic Linux and Apple + macOS profiles expire before the 7200-second processing window. The + autoscaler-to-dispatcher timeout must stay above those runner TTLs because + dispatch requests block until the one-job runner exits. `publish-store-uploads` + has a separate no-`needs` `distribute-ios-testflight` retry job for + `distribute_testflight=true` and `upload_app_store=false`, so skipped + upload/signing jobs cannot suppress distribution of an already-uploaded build. + `distribute-testflight` is the narrower one-job retry workflow when only App + Store Connect processing and tester assignment need to be retried. +- Internal TestFlight distribution must not submit the build for external beta + review. The internal lane waits for processing, sets export-compliance + metadata, uses Fastlane `skip_submission:true`, and relies on App Store + Connect's configured internal tester group availability. External TestFlight + distribution requires explicit groups plus beta-review metadata before it can + be enabled. +- Add `infra/releases` as the OpenTofu boundary for the GCS release and package repository backup buckets. Garage is the required S3-compatible primary distribution target after host bootstrap. `infra/identity` remains the boundary for Google KMS signing keys, the Authentik WIF pool/provider, and the runner service account. +- Serve `releases.burrow.net` and `packages.burrow.net` from the forge Caddy + edge as stable Burrow domains backed by the GCS release and package buckets. + Appcast enclosure URLs and package repository metadata must use those Burrow + domains instead of provider-specific object-storage URLs. + +## Security and Operational Considerations + +- Store credentials are consumed only by signed build or upload jobs, not by ordinary build/test jobs. +- GCS backup and Google KMS access must use Authentik-backed Workload Identity Federation against project `project-88c23ce9-918a-470a-b33`; workflows must not use Google service-account JSON keys. +- Garage uploads use S3-compatible access keys scoped to release/package buckets. They are required by default; GCS is a backup mirror, not the success fallback. +- Garage backup uses a separate read-only key spanning the release, package, and Attic buckets. That key may be sealed into Forgejo/OpenBao for backup jobs, but it must not be reused for release/package writes. +- Attic cache publishing uses a scoped CI push token for the `burrow` cache instead of the bootstrap admin token. +- rclone is not part of the release path. Multi-cloud failover should be added through provider-specific or S3-compatible wrappers with explicit credentials and evidence. +- Required upload credentials are checked explicitly after `./.forgejo/actions/decrypt-release-secrets` materializes them from age: + - `secrets/apple/appstore-connect.env.age`: `ASC_API_KEY_ID`, `ASC_API_ISSUER_ID`, and base64-encoded `.p8` key material. + - KMS-backed Apple signing must not use `.p12` private-key material. The + legacy `secrets/apple/distribution-signing.env.age` path remains accepted + only for emergency keychain signing and should not be used for the normal + tester release lane. + - Sparkle appcasts are signed with Google KMS by default; the legacy + `secrets/apple/sparkle.env.age` path remains accepted only for emergency + local EdDSA signing. + - future Microsoft Partner Center credentials +- The temporary CI keychain password is always the distribution certificate password; there is no separate keychain-password release secret. +- KMS-backed Apple certificates do not satisfy the existing Xcode/keychain + import path. Shipping with these certificates requires a signer that can + delegate Apple code-signing operations to Google KMS. +- iOS KMS signing must filter provisioning-profile entitlements through the + checked-in iOS entitlement templates before signing. App Store Connect + validates the bundle signature, not just the profile, and rejects profile-only + capabilities such as system extensions or unsupported NetworkExtension values + when they leak into an iOS app or extension signature. +- The App target must keep `Assets.xcassets` in its Resources phase. Xcode + derives the `CFBundleIcons` metadata and standalone App Store icon PNGs from + that resource membership during iOS builds. +- App Store Connect upload steps must fail on `altool` validation output as + well as non-zero process exits. Apple can emit a textual upload failure before + the workflow reaches TestFlight processing, and downstream tester waits must + not run unless the IPA upload was actually accepted. +- If the first key ring or Developer ID key is bootstrapped before the + OpenTofu remote state backend is available locally, the live resources must be + imported into `infra/identity` before enabling managed identity applies. +- Dedicated store accounts should be sealed with agenix before enabling always-on uploads. The runner only needs an age identity such as `/var/lib/forgejo-runner-agent/age_keystore`; `AGE_FORGE_SSH_KEY` is a fallback bootstrap secret, not a place for release material. +- The canonical identity registry reserves `release@burrow.net` for release automation and `namespace@burrow.net` for Namespace runner capacity credentials; secrets stay outside `contributors.nix`. +- Grafana starts with a sealed admin password and a pending OIDC client secret. Local admin login remains available until the real OIDC secret is rotated and the Authentik reconciliation service creates the Grafana provider. +- OpenTofu apply/import modes require an explicit confirmation and remote state. Validation may run without remote state. +- Build tags are pushed only after artifacts have been assembled for the build number. +- App Store Connect upload and internal/private tester lanes may default on only + after dedicated credentials and export metadata are verified. This default + applies to `release-if-needed`, `build-release`, `publish-store-uploads`, and + `apple-distribute-testers`. External TestFlight distribution and public + app-store rollout must stay explicit. + +## Contributor Playbook + +1. Check whether a release is needed: + ```bash + Scripts/version.sh status + ``` +2. Build local artifacts: + ```bash + BUILD_NUMBER=local Scripts/ci/build-release-artifacts.sh all + ``` +3. Build Apple release validation artifacts on macOS: + ```bash + BUILD_NUMBER=local bazel build //bazel/apple:release_ios_stamp //bazel/apple:release_macos_stamp + ``` +4. Verify the Windows stub still builds: + ```bash + cargo test --locked -p burrow-windows-stub + ``` +5. Validate BEP metadata: + ```bash + python3 Scripts/check-bep-metadata.py + ``` +6. Before turning on an upload lane, seal the dedicated service-account secret and run: + ```bash + Scripts/seal-release-secrets.sh --source-dir intake/release + Scripts/ci/check-release-config.sh app-store + Scripts/ci/check-release-config.sh apple-signing + Scripts/ci/check-release-config.sh gcs + ``` +7. Treat successful Forgejo release asset publication and successful store upload jobs as separate evidence points. +8. Validate Grafana OpenTofu syntax locally: + ```bash + Scripts/grafana-tofu.sh init -backend=false + Scripts/grafana-tofu.sh validate + ``` +9. Validate release storage OpenTofu syntax locally: + ```bash + Scripts/releases-tofu.sh init -backend=false + Scripts/releases-tofu.sh validate + ``` +10. Validate release storage wrapper syntax: + ```bash + bash -n Scripts/ci/upload-release-storage.sh Scripts/ci/upload-package-storage.sh Scripts/ci/backup-garage-to-gcs.sh Scripts/ci/publish-nix-cache.sh + ``` +11. Dispatch a Forgejo workflow without GitHub: + ```bash + Scripts/forgejo-dispatch.sh build-release.yml --ref main + ``` +12. After deploying the forge host, seal: + ```text + BURROW_NIX_CACHE_PUSH_TOKEN from /var/lib/burrow/nix-cache/ci-push-token + BURROW_GARAGE_BACKUP_ACCESS_KEY_ID from /var/lib/burrow/garage/env + BURROW_GARAGE_BACKUP_SECRET_ACCESS_KEY from /var/lib/burrow/garage/env + ``` + +## Alternatives Considered + +- Keep one monolithic release workflow. Rejected because build failures, upload failures, and credential gaps become hard to distinguish. +- Wait for native Windows support before adding a Windows lane. Rejected because packaging and Microsoft Store authentication can be validated with a Rust stub first. +- Add Sparkle to the Apple app in the same change. Rejected because Sparkle changes the client update trust boundary and should be reviewed separately from release plumbing. + +## Impact on Other Work + +- Future Apple release work can fill in signed archive/export details without changing release numbering. +- Future Windows work can replace the stub package with the native client while preserving upload shape. +- Identity and credential follow-up should derive long-lived automation accounts from `contributors.nix` where they represent Burrow-operated identities. + +## Decision + +Pending. + +## References + +- `CONSTITUTION.md` +- `contributors.nix` +- `.forgejo/workflows/release-if-needed.yml` +- `.forgejo/workflows/build-release.yml` +- `.forgejo/workflows/publish-store-uploads.yml` +- `Scripts/version.sh` +- `Scripts/ci/nscloud-cache.sh` +- `Scripts/ci/ensure-nix.sh` +- `Scripts/ci/package-apple-artifacts.sh` +- `Scripts/ci/upload-release-storage.sh` +- `Scripts/ci/upload-package-storage.sh` +- `Scripts/ci/publish-nix-cache.sh` +- `Scripts/ci/backup-garage-to-gcs.sh` +- `bazel/apple/BUILD.bazel` +- `Scripts/forgejo-dispatch.sh` +- `Scripts/forgejo-dispatch-via-host.sh` +- `Scripts/grafana-tofu.sh` +- `Scripts/releases-tofu.sh` +- `.forgejo/workflows/infra-opentofu.yml` +- `.forgejo/workflows/publish-nix-cache.yml` +- `.forgejo/workflows/backup-garage-storage.yml` +- `infra/grafana/` +- `infra/releases/` +- `nixos/modules/burrow-garage.nix` +- `nixos/modules/burrow-observability.nix` +- `services/grafana/dashboards/burrow-overview.json` +- `services/grafana/dashboards/headscale.json` +- `services/grafana/dashboards/observability.json` diff --git a/evolution/proposals/BEP-0010-platform-services-core-and-distribution.md b/evolution/proposals/BEP-0010-platform-services-core-and-distribution.md new file mode 100644 index 0000000..211554a --- /dev/null +++ b/evolution/proposals/BEP-0010-platform-services-core-and-distribution.md @@ -0,0 +1,332 @@ +# `BEP-0010` - Platform Services, Core, and Distribution + +```text +Status: Draft +Proposal: BEP-0010 +Authors: gpt-5.5 +Coordinator: gpt-5.5 +Reviewers: Pending +Constitution Sections: II, III, IV, V +Implementation PRs: Pending +Decision Date: Pending +``` + +## Summary + +Burrow should grow from a forge-hosted VPN project into a coherent platform: a +KMS-backed identity and signing plane, OpenBao-backed secret distribution, +private meeting and mail services, an extracted MCP hub for operator and agent +workflows, and app builds for Apple, Linux, Android, and later store channels. + +The first implementation is deliberately scaffolding-heavy. It adds OpenTofu +boundaries for Google KMS, Workload Identity Federation, GCS release backup +storage, and OpenBao; enables Garage-backed object storage and a Burrow-owned +Nix cache at `nix.burrow.net`; adds +NixOS wiring for Grafana, Prometheus, OpenTelemetry, and Jaeger; adds +disabled-by-default NixOS service switch points for `vault.burrow.net` and +`meet.burrow.net`; introduces a small cross-platform Rust core and Android +Kotlin stub; and records the distribution model before stores or public +production services are enabled. + +## Motivation + +- The forge now controls source and release automation, but release signing, + SAML signing, and runner cloud access still need a stronger non-exportable key + story. +- Secrets are still primarily age-managed files. That remains a good bootstrap + path, but long-running services and agents need short-lived, attributable + runtime access. +- Burrow needs mobile and desktop clients that share protocol logic instead of + repeatedly embedding platform-local behavior. +- The GTK Flatpak can be a useful desktop shell, but the actual VPN data plane + cannot be assumed to work inside an unprivileged Flatpak sandbox. +- App store, F-Droid, Flatpak, and Play Store distribution should be designed as + separate release surfaces with explicit signing, policy, and metadata gates. + +## Detailed Design + +- Add `infra/identity` as the OpenTofu boundary for Google Cloud identity keys + and Authentik-backed Workload Identity Federation: + - Google project id: `project-88c23ce9-918a-470a-b33`. + - Google project number: `416198671487`. + - KMS key ring: `burrow-identity`. + - non-exportable signing keys for Authentik signing, SAML CA signing, and + release signing. + - a Forgejo runner service account that can be assumed only through the + configured Authentik WIF provider and IAM bindings. Machine-to-machine + runner tokens are scoped by the Authentik WIF client ID + `google-wif.burrow.net`, with `burrow-automation` kept as the human/group + policy boundary. +- Add `infra/releases` as the OpenTofu boundary for Google Cloud + Storage-backed release backups: + - `burrow-net-releases` backs up build artifacts and Sparkle public channels. + - `burrow-net-packages` backs up signed APT, RPM, pacman, Flatpak, and Arch + repository trees. + - `burrow-net-nix-cache` backs up the Garage `attic` bucket and remains + private by default. + - Garage is the required S3-compatible primary target for release and package + uploads. + - `services.burrow.garage` is enabled by the forge host and bootstraps the + single-node layout, the `attic`, `burrow-releases`, and `burrow-packages` + buckets, scoped owner/write S3 access keys, and a read-only backup key from + a host-local environment file. + - Forgejo jobs authenticate with Authentik-backed WIF before using `gcloud + storage` for backup and Google KMS for signing; rclone and Google + service-account JSON keys are not part of the release path. +- Add `services.burrow.nixCache` for `nix.burrow.net`: + - Attic serves `https://nix.burrow.net/burrow` as the public Burrow cache. + - Attic stores chunks in the Garage `attic` bucket through the local S3 API. + - Workers use the cache only after `BURROW_NIX_CACHE_PUBLIC_KEY` is published + in Forgejo variables. + - Push access uses `/var/lib/burrow/nix-cache/ci-push-token`, sealed into + Forgejo/OpenBao as `BURROW_NIX_CACHE_PUSH_TOKEN`, instead of the host-local + bootstrap admin token. + - `.forgejo/workflows/publish-nix-cache.yml` builds selected flake outputs and + publishes their closures to Attic. +- Add `services.burrow.observability` as the forge host observability spine: + - Prometheus scrapes local system, Grafana, Headscale, OpenTelemetry + collector, and Jaeger metrics. + - Headscale exposes local metrics on `127.0.0.1:9098`. + - Tailscale SaaS metrics can be enabled later through the Prometheus + Tailscale exporter once the OAuth environment file is provisioned. + - Burrow backend/frontend processes emit OTLP to the local collector at + `127.0.0.1:4317` or `127.0.0.1:4318`. + - The collector exports traces to local Jaeger, while Grafana queries Jaeger + server-side through a provisioned datasource. +- Add `infra/openbao` as the OpenTofu boundary for OpenBao: + - Google KMS seal wrapping. + - an `age/` KV v2 mount for migrated runtime secrets. + - Authentik OIDC roles for administrators and automation. + - AppRole policy scaffolding for machine consumers. +- Add NixOS modules under `services.burrow.openbao` and + `services.burrow.jitsi`: + - both are imported by the forge host but disabled by default. + - DNS, reverse proxy, KMS seal, storage, and UDP/video bridge requirements are + visible in repo-owned options before activation. + - live enablement requires a separate deploy with secrets, DNS, and rollback + evidence. +- Keep webmail as a second mail phase: + - `inbox.burrow.net` is the intended webmail surface. + - Stalwart is the planned mail server, but the current Nixpkgs module set in + this flake does not expose the expected `services.stalwart-mail` option. + - Forward Email remains the current production mail path until a Stalwart BEP + revision names the exact NixOS module, ports, spam policy, backup target, + DKIM rotation, and migration plan. +- Extract an MCP hub to a dedicated compatible.systems repository: + - target repository: `compatible.systems/burrow/mcp-hub`. + - this repository keeps `services/mcp-hub/` as the extraction plan and + bootstrap manifest until the external repo exists. + - MCP tools should cover OpenBao, Authentik, KMS/WIF, Forgejo runners, Jitsi, + mail, release signing, and Burrow agent identity. +- Create a `burrow-core` Rust crate as the cross-platform protocol/application + core boundary: + - no direct TUN, NetworkExtension, VpnService, GTK, SwiftUI, or desktop UI + dependencies. + - platform shells link it through a thin FFI crate or native Rust API. + - target platforms include Linux x86_64/aarch64/riscv64, Android, macOS, iOS, + visionOS, and future Windows. +- Add an Android stub: + - Kotlin app shell in `Android/app`. + - Rust JNI/FFI crate in `crates/burrow-mobile-ffi`. + - the stub loads the Rust core and displays its version. + - full VPN support must use Android `VpnService`; it must not bypass platform + disclosure and consent flows. +- Keep Bazel as the stable build orchestration entrypoint: + - platform lanes expose wrapper targets under `bazel/`. + - Bazel actions may call repo-owned scripts, Cargo, Gradle, Xcode, Meson, and + OpenTofu while the project migrates deeper native rules selectively. + - Namespace cache setup remains the fast path for remote Bazel and local disk + caches. +- Use a shared Burrow owl identity across app shells: + - the mark uses a grounded Burrowing Owl silhouette: compact face, warm brown + body, small cream markings, and long pale legs visible in front of the + burrow rim. + - `design/brand/Burrow.icon` is the Icon Composer source and is intentionally + kept to three broad raster layers: burrow ground, owl figure, and front + legs. + - `design/brand/burrow-owl-icon-master.png` is the generated raster master for + Apple app icon outputs. + - Apple asset catalogs derive all `AppIcon` PNG sizes from that master and + use a restrained warm brown/gold accent color. + - GTK keeps a simple vector owl/burrow icon and symbolic icon so Linux + desktops do not inherit the old blue gear-style mark. + - Brown/black stays the core palette, with lighter brown, orange, or gold used + only as accents for eyes, beak, highlights, and platform tint. +- For Linux distribution, split the GUI package from the privileged daemon: + - DEB, RPM, pacman, AUR, and the NixOS flake/module install `burrowd`, + systemd units, D-Bus policy, and polkit policy. + - APT, RPM, and pacman repository metadata is generated from release package + artifacts and signed through Google KMS-backed OpenPGP signatures. + - Repository trees publish through the storage wrapper: Garage first when + configured, then GCS backup after the runner obtains a short-lived Google + credential from Authentik-backed WIF. + - AUR is a source-build git repository, with `burrow-git` tracked in this + repo before publication to `aur.archlinux.org`. + - Flatpak and AppImage packages are GUI-first shells that connect to the host + daemon/helper. + - Flatpak may request background/autostart permission for the GUI, but it + must not be responsible for the privileged VPN data plane. + - PackageKit may be used only as an optional native-package bootstrap on + supported distros, with narrow D-Bus permission and polkit authorization. + +## Security and Operational Considerations + +- Google KMS keys are non-exportable and have `prevent_destroy` enabled. +- Workload Identity Federation is scoped by issuer, audience, mapped + attributes, and service-account IAM bindings. Runners should not receive + static Google credentials. +- OpenBao bootstrap tokens and AppRole SecretIDs must never enter OpenTofu + state. OpenTofu manages mounts, policies, roles, and cloud KMS objects only. +- OpenBao should start behind `vault.burrow.net` only after: + - KMS seal key exists and decrypt permission is limited to the service + identity. + - root/admin token bootstrap is recorded out of band. + - backup/restore and seal/unseal drills are documented. +- Jitsi should start behind `meet.burrow.net` only after: + - HTTPS and XMPP domains resolve. + - UDP media ports are intentionally opened. + - Authentik guest/member policy is decided. +- Flatpak cannot be the privileged VPN backend by itself. A Flatpak GUI may talk + to a host daemon or privileged helper, but opening TUN devices, installing + routes, and owning system DNS/routing policy belong outside the sandbox. +- Host service bootstrap should be auditable. A Flatpak may discover the daemon, + open native install instructions, or request a host helper through a narrow + D-Bus name. It must not require broad system-bus access, host filesystem + access, or `flatpak-spawn --host` as the normal production path. +- Mobile VPN support uses platform VPN APIs: + - Android: `VpnService` with Play policy disclosure for Play Store builds. + - iOS and visionOS: NetworkExtension packet tunnel provider. +- Release signing, SAML CA signing, and Authentik signing should remain separate + keys even when they share a KMS key ring. +- Package repository signing should stay split by repository format. APT, RPM, + pacman, Flatpak, and AUR source surfaces each get a dedicated KMS key so a + compromised publisher path does not automatically sign every Linux channel. +- Observability ingress is local-first. Prometheus, the OpenTelemetry collector, + and Jaeger bind to loopback; Grafana is the authenticated public surface. +- Jaeger should not be exposed publicly until an Authentik-protected route or + equivalent access boundary is added. +- GCS is a backup target, not the storage abstraction. Future multi-cloud + failover should add explicit provider mirrors or S3-compatible endpoints + behind the storage wrappers. +- Garage needs real host storage for object data and metadata. It replicates + across Garage nodes, but it does not manage multiple external storage + backends. GCS and later providers should be explicit mirror/backup jobs. +- `.forgejo/workflows/backup-garage-storage.yml` is the first explicit mirror. + It uses a read-only Garage key and Authentik-backed WIF to copy Garage bucket + contents to GCS without rclone or static Google service-account keys. + +## Contributor Playbook + +1. Validate BEP metadata: + ```bash + python3 Scripts/check-bep-metadata.py + ``` +2. Check the Android/Rust stub: + ```bash + cargo check --locked -p burrow-mobile-ffi + bazel build //bazel/android:check_stub_stamp + ``` +3. Validate identity OpenTofu syntax: + ```bash + Scripts/identity-tofu.sh init -backend=false + Scripts/identity-tofu.sh validate + ``` +4. Validate release storage OpenTofu syntax: + ```bash + Scripts/releases-tofu.sh init -backend=false + Scripts/releases-tofu.sh validate + ``` +5. Validate observability Nix wiring and dashboard JSON: + ```bash + nix eval .#nixosConfigurations.burrow-forge.config.services.prometheus.scrapeConfigs + jq empty services/grafana/dashboards/headscale.json services/grafana/dashboards/observability.json + ``` +6. Validate the Nix cache module wiring: + ```bash + nix eval .#nixosConfigurations.burrow-forge.config.services.atticd.settings.storage --json + ``` +7. Validate cache publishing and Garage backup wrapper syntax: + ```bash + bash -n Scripts/ci/publish-nix-cache.sh Scripts/ci/backup-garage-to-gcs.sh + ``` +8. Validate OpenBao OpenTofu syntax: + ```bash + Scripts/openbao-tofu.sh init -backend=false + Scripts/openbao-tofu.sh validate + ``` +9. Before enabling `vault.burrow.net`, create or import the Google KMS seal key, + configure OpenBao bootstrap access, and record a restore test. +10. Before enabling `meet.burrow.net`, verify DNS, TLS, UDP reachability, and + Authentik access policy. +11. Before distributing Flatpak as more than a GUI, prove the host daemon/helper + path on a real Linux desktop. +12. Before Play Store distribution, complete the `VpnService` declaration and + data-safety review. +13. Before relying on PackageKit bootstrap, test Fedora, Debian/Ubuntu, and an + immutable/atomic desktop separately. PackageKit support is not universal and + should degrade to native install instructions. +14. Before promoting package repositories to stable, run the repository + publisher, import the generated public key on a clean VM for each package + family, and install Burrow from that repository rather than from the loose + artifact. + +## Alternatives Considered + +- Enable OpenBao and Jitsi immediately on the forge host. Rejected because both + change public ingress and security boundaries before secrets, DNS, and + rollback evidence are complete. +- Store Google service-account JSON in Forgejo secrets. Rejected because WIF + gives the runner an attributable short-lived credential path without static + cloud keys. +- Put Android directly on the existing daemon crate. Rejected for now because + the daemon carries OS-specific TUN and service assumptions. A small + cross-platform core gives mobile a safer first boundary. +- Treat Flatpak as the complete Linux VPN package. Rejected because routing, + TUN, and DNS changes need host authority. +- Use broad Flatpak host escape permissions to fork the daemon directly. + Rejected because that defeats the value of Flatpak and makes review harder + than shipping a small native daemon package with explicit polkit policy. +- Use one package signing key for every Linux repository. Rejected because + format-specific keys give cleaner revocation and narrower IAM grants. + +## Impact on Other Work + +- BEP-0009 release work gains identity and app-distribution follow-up lanes. +- BEP-0005 and BEP-0006 remain authoritative for daemon/client boundaries. +- BEP-0004 remains authoritative for current hosted mail until a Stalwart + revision supersedes it. +- MCP extraction should not move forge runner code until the external + compatible.systems repository exists and import paths are stable. + +## Decision + +Pending. + +## References + +- `CONSTITUTION.md` +- `contributors.nix` +- `evolution/proposals/BEP-0004-hosted-mail-and-saas-identity.md` +- `evolution/proposals/BEP-0005-daemon-ipc-and-apple-boundary.md` +- `evolution/proposals/BEP-0006-tailnet-authority-first-control-plane.md` +- `evolution/proposals/BEP-0009-release-infrastructure-and-store-upload-pipeline.md` +- `infra/identity/` +- `infra/releases/` +- `infra/openbao/` +- `docs/OBSERVABILITY.md` +- `docs/NIX_CACHE.md` +- `.forgejo/workflows/publish-nix-cache.yml` +- `.forgejo/workflows/backup-garage-storage.yml` +- `Scripts/ci/publish-nix-cache.sh` +- `Scripts/ci/backup-garage-to-gcs.sh` +- `package/repositories/` +- `nixos/modules/burrow-garage.nix` +- `nixos/modules/burrow-nix-cache.nix` +- `nixos/modules/burrow-observability.nix` +- `nixos/modules/burrow-openbao.nix` +- `nixos/modules/burrow-jitsi.nix` +- `crates/burrow-core/` +- `crates/burrow-mobile-ffi/` +- `Android/` +- `bazel/android/` +- `services/mcp-hub/` diff --git a/evolution/proposals/BEP-0011-panel-icon-family-and-platform-assets.md b/evolution/proposals/BEP-0011-panel-icon-family-and-platform-assets.md new file mode 100644 index 0000000..a8ed094 --- /dev/null +++ b/evolution/proposals/BEP-0011-panel-icon-family-and-platform-assets.md @@ -0,0 +1,87 @@ +# `BEP-0011` - Panel Icon Family and Platform Assets + +```text +Status: Implemented +Proposal: BEP-0011 +Authors: gpt-5.4 +Coordinator: gpt-5.4 +Reviewers: Pending +Constitution Sections: II, V +Implementation PRs: Pending +Decision Date: 2026-06-07 +``` + +## Summary + +Burrow uses a locked six-panel burrowing owl icon family as the product icon +language. The supplied panel sheet and its six cropped PNG masters are the +canonical source; platform-specific PNGs are generated from those rasters. + +## Motivation + +- Burrow needs one recognizable icon language across iOS, macOS, watchOS, + Android, and Linux packaging. +- The iOS app should expose the six panel variants as local alternate app icons. +- Platform packages need exact launcher dimensions without hand-edited raster + drift. + +## Detailed Design + +- `Scripts/generate-brand-icons.py` owns the raster crop and platform exports. +- `design/brand/panel-variants/source-sheet.png` stores the locked panel sheet. +- The generator writes six 1024px PNG masters under + `design/brand/panel-variants/` when run with `--extract-from`. +- iOS uses `panel-01-guardian` as the primary icon and exposes the other five + panel variants through native alternate app icon asset sets. +- macOS uses `panel-05-stride` as the primary app icon. +- watchOS uses `panel-03-burrow` as the primary app icon; exact watch icon + sizes live in `design/brand/watchos/AppIcon.appiconset` until a watch target + owns them directly. +- Android launcher mipmaps and Linux hicolor PNGs are generated from the same + raster master as iOS primary. +- The Apple UI calls only `UIApplication.setAlternateIconName`; no daemon, + control-plane, or network path is added for icon selection. + +## Security and Operational Considerations + +- Icon selection is local presentation state and does not touch auth, routing, + daemon IPC, or account material. +- Generated rasters are deterministic from checked-in raster masters. +- The rollback path is to revert the generator and regenerate assets. + +## Contributor Playbook + +- Keep icon geometry in the raster panel masters; do not redraw it as SVG. +- Edit `Scripts/generate-brand-icons.py` only for crop boxes, package sizes, or + platform picks. +- Run `Scripts/generate-brand-icons.py`. +- Review `design/brand/panel-variants/preview-strip.png`. +- Review `design/brand/low-res/preview-strip.png` and + `design/brand/low-res/pixel-preview-strip.png`. +- Run `Scripts/check-brand-icon-lowres.sh`. +- Build the Apple app and Android app after asset changes. + +## Alternatives Considered + +- Keep a single app icon. Rejected because the six panel variants are all valid + product directions and iOS has a native alternate icon API. +- Redraw the sheet as SVG. Rejected because the supplied raster panel already + carries the desired style, texture, and proportions. +- Let the daemon choose app icons. Rejected because icon selection is local + presentation behavior and should not cross the daemon boundary. + +## Impact on Other Work + +- Store metadata and packaging jobs should use generated platform assets. +- Future design changes should preserve the raster panel source and generated + package outputs. + +## Decision + +Implemented on 2026-06-07. + +## References + +- `Scripts/generate-brand-icons.py` +- `design/brand/panel-variants/` +- `Apple/UI/BurrowView.swift` diff --git a/flake.lock b/flake.lock index 0067dab..e2ce1a1 100644 --- a/flake.lock +++ b/flake.lock @@ -52,8 +52,8 @@ ] }, "locked": { - "lastModified": 1773889306, - "narHash": "sha256-PAqwnsBSI9SVC2QugvQ3xeYCB0otOwCacB1ueQj2tgw=", + "lastModified": 1780290312, + "narHash": "sha256-eTAlX0CwgB84Ts3GaBd944A3DRXVMzgA0EqroZBISUo=", "type": "tarball", "url": "https://codeload.github.com/nix-community/disko/tar.gz/master" }, @@ -113,14 +113,18 @@ }, "nixpkgs": { "locked": { - "lastModified": 1773389992, - "narHash": "sha256-wvfdLLWJ2I9oEpDd9PfMA8osfIZicoQ5MT1jIwNs9Tk=", - "type": "tarball", - "url": "https://codeload.github.com/NixOS/nixpkgs/tar.gz/nixos-unstable" + "lastModified": 1780243769, + "narHash": "sha256-x5UQuRsH3MqI0U9afaXSNqzTPSeZlRLvFAav2Ux1pNw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "331800de5053fcebacf6813adb5db9c9dca22a0c", + "type": "github" }, "original": { - "type": "tarball", - "url": "https://codeload.github.com/NixOS/nixpkgs/tar.gz/nixos-unstable" + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" } }, "nsc-autoscaler": { diff --git a/flake.nix b/flake.nix index e842fba..bdaa590 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "Burrow development shell and forge host configuration"; inputs = { - nixpkgs.url = "tarball+https://codeload.github.com/NixOS/nixpkgs/tar.gz/nixos-unstable"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "tarball+https://codeload.github.com/numtide/flake-utils/tar.gz/main"; agenix = { url = "github:ryantm/agenix"; @@ -38,7 +38,148 @@ inherit system; }; lib = pkgs.lib; + bazelPkg = + if lib.hasAttr "bazelisk" pkgs then + pkgs.bazelisk + else if lib.hasAttr "bazel_9" pkgs then + pkgs.bazel_9 + else if lib.hasAttr "bazel" pkgs then + pkgs.bazel + else + pkgs.bazel_7; + buildifierPkg = + if lib.hasAttr "buildifier" pkgs then + pkgs.buildifier + else + pkgs.bazel-buildtools; + nodejsPkg = + if lib.hasAttr "nodejs_22" pkgs then + pkgs.nodejs_22 + else if lib.hasAttr "nodejs_24" pkgs then + pkgs.nodejs_24 + else if lib.hasAttr "nodejs" pkgs then + pkgs.nodejs + else + pkgs.nodejs_20; + python3WithCrypto = pkgs.python3.withPackages (pythonPackages: [ + pythonPackages.cryptography + ]); + optionalPackage = name: lib.optional (lib.hasAttr name pkgs) (lib.getAttr name pkgs); + googleKmsPkcs11Package = + if pkgs.stdenv.hostPlatform.isx86_64 && pkgs.stdenv.isLinux then + let + version = "1.9"; + in + pkgs.stdenv.mkDerivation { + pname = "google-kms-pkcs11"; + inherit version; + src = pkgs.fetchurl { + url = "https://github.com/GoogleCloudPlatform/kms-integrations/releases/download/pkcs11-v${version}/libkmsp11-${version}-linux-amd64.tar.gz"; + sha256 = "sha256-U5f5ZQc81dHixD5RSPEC8xp8g1kC+X60HHycDxuHakA="; + }; + nativeBuildInputs = [ pkgs.autoPatchelfHook ]; + buildInputs = [ pkgs.stdenv.cc.cc.lib ]; + installPhase = '' + runHook preInstall + install -Dm755 libkmsp11.so "$out/lib/libkmsp11.so" + install -Dm644 kmsp11.h "$out/include/kmsp11.h" + install -Dm644 LICENSE "$out/share/licenses/google-kms-pkcs11/LICENSE" + mkdir -p "$out/bin" + cat > "$out/bin/google-kms-pkcs11-module" < dashboard.url } +} + +output "grafana_folder_uids" { + description = "Grafana folder UIDs managed by this stack." + value = { for name, folder in grafana_folder.folders : name => folder.uid } +} diff --git a/infra/grafana/providers.tf b/infra/grafana/providers.tf new file mode 100644 index 0000000..6dc01f6 --- /dev/null +++ b/infra/grafana/providers.tf @@ -0,0 +1,4 @@ +provider "grafana" { + url = var.grafana_url + auth = var.grafana_auth +} diff --git a/infra/grafana/terraform.tfvars.example b/infra/grafana/terraform.tfvars.example new file mode 100644 index 0000000..27dbab5 --- /dev/null +++ b/infra/grafana/terraform.tfvars.example @@ -0,0 +1,18 @@ +grafana_url = "https://graphs.burrow.net" + +manage_grafana_dashboards = true + +grafana_folders = { + burrow = { + title = "Burrow" + uid = "burrow" + } +} + +grafana_dashboards = { + burrow-overview = { + path = "../../services/grafana/dashboards/burrow-overview.json" + folder = "burrow" + overwrite = true + } +} diff --git a/infra/grafana/variables.tf b/infra/grafana/variables.tf new file mode 100644 index 0000000..585ad0e --- /dev/null +++ b/infra/grafana/variables.tf @@ -0,0 +1,56 @@ +variable "grafana_url" { + description = "Grafana base URL." + type = string + default = "https://graphs.burrow.net" +} + +variable "grafana_auth" { + description = "Grafana API token or basic auth in username:password form. Prefer GRAFANA_AUTH in CI." + type = string + default = null + sensitive = true +} + +variable "manage_grafana_dashboards" { + description = "Manage Grafana folders and dashboards through the Grafana API." + type = bool + default = false +} + +variable "grafana_folders" { + description = "Grafana folders to create before dashboards." + type = map(object({ + title = string + uid = optional(string) + })) + default = { + burrow = { + title = "Burrow" + uid = "burrow" + } + } +} + +variable "grafana_dashboards" { + description = "Grafana dashboards to manage from checked-in JSON." + type = map(object({ + path = string + folder = optional(string) + message = optional(string, "Managed by Burrow OpenTofu") + overwrite = optional(bool, true) + })) + default = { + burrow-overview = { + path = "../../services/grafana/dashboards/burrow-overview.json" + folder = "burrow" + } + burrow-headscale = { + path = "../../services/grafana/dashboards/headscale.json" + folder = "burrow" + } + burrow-observability = { + path = "../../services/grafana/dashboards/observability.json" + folder = "burrow" + } + } +} diff --git a/infra/grafana/versions.tf b/infra/grafana/versions.tf new file mode 100644 index 0000000..1186143 --- /dev/null +++ b/infra/grafana/versions.tf @@ -0,0 +1,12 @@ +terraform { + required_version = ">= 1.8.0" + + required_providers { + grafana = { + source = "grafana/grafana" + version = ">= 4.36.0, < 5.0" + } + } + + backend "s3" {} +} diff --git a/infra/identity/.gitignore b/infra/identity/.gitignore new file mode 100644 index 0000000..b12b9ed --- /dev/null +++ b/infra/identity/.gitignore @@ -0,0 +1,5 @@ +.terraform/ +backend.hcl +terraform.tfstate +terraform.tfstate.backup +*.tfplan diff --git a/infra/identity/.terraform.lock.hcl b/infra/identity/.terraform.lock.hcl new file mode 100644 index 0000000..0a51a6e --- /dev/null +++ b/infra/identity/.terraform.lock.hcl @@ -0,0 +1,20 @@ +# This file is maintained automatically by "tofu init". +# Manual edits may be lost in future updates. + +provider "registry.opentofu.org/hashicorp/google" { + version = "6.50.0" + constraints = ">= 5.40.0, < 7.0.0" + hashes = [ + "h1:MAAe4zFFdqS9M5rpmJK/vKgdb6ZMD/s/0Xd97yTDipA=", + "zh:1d4695f807d998f11fcdcfa174766287b82a8093513af857bcdad2d81c642480", + "zh:3173ac5df0294624d113812e49e2a55714aff7db617488168cecdf4168df9e29", + "zh:34d2b3d44c23bd6354fc4ab5917b302872ea1ab8de107034567f955b1717fa5b", + "zh:3a77f3cc2f3664cd5aaeeef4d044e6ec1695a079588fffec3ca03953664e5f04", + "zh:6b444e4b629ea8dc8cb112a39dde098dc5584d26d6de4177558f556a9a226696", + "zh:96545c8cd4d3a57069c5d1799eab5aedd887e16d98b5559a195f6d2c2d9bc674", + "zh:ba464caafde95ee16671d6b5ec90f053ed77a9d06c567456db6efd9160fa3165", + "zh:d876938e5b0d3f57a984d9be72467995f87fef6569968623415dc51d9f54d30b", + "zh:dfd908d873e314ab807d0abc9cfd42d2611cd06dc1b9ec719ebdbb738e8e68d6", + "zh:f9f16819a7738d564afd45fd169ba61004ec4e4e7089d2a4950cb8895be1fe1f", + ] +} diff --git a/infra/identity/README.md b/infra/identity/README.md new file mode 100644 index 0000000..b774578 --- /dev/null +++ b/infra/identity/README.md @@ -0,0 +1,147 @@ +# Burrow Identity KMS and WIF + +This OpenTofu stack owns Google Cloud KMS and Workload Identity Federation +resources for Burrow identity and release automation. + +It may manage: + +- the `burrow-identity` Google KMS key ring +- non-exportable KMS signing keys for Authentik, the SAML CA, and release + signing +- dedicated non-exportable KMS signing keys for APT, RPM, pacman, Flatpak, and + AUR source release surfaces +- a non-exportable KMS signing key for the Apple Developer ID Application CSR + path (`apple-developer-id-application`) +- a non-exportable KMS signing key for the Apple iOS Distribution CSR path + (`apple-ios-distribution`) +- a non-exportable software KMS signing key for Sparkle Ed25519 appcast + signatures (`sparkle-ed25519`) +- an Authentik-backed WIF pool/provider for Forgejo runners +- the runner service account and its narrow IAM binding for the Authentik WIF + audience/client value `google-wif.burrow.net`; human/group grants are opt-in + +It must not manage: + +- Authentik private signing key material +- OpenBao bootstrap tokens +- store credentials or service-account JSON keys + +Forgejo CI should authenticate with `Scripts/ci/google-wif-auth.sh`. That helper +uses Authentik to obtain an OIDC token and lets Google WIF impersonate +`burrow-forgejo-runner@project-88c23ce9-918a-470a-b33.iam.gserviceaccount.com` +in project `project-88c23ce9-918a-470a-b33`. + +## Apple Developer ID CSR + +`Scripts/apple/google-kms-csr.py` builds a standard PKCS#10 CSR using the public +key from `projects/project-88c23ce9-918a-470a-b33/locations/global/keyRings/burrow-identity/cryptoKeys/apple-developer-id-application` +and asks Google KMS to sign the CSR payload. The private key remains +non-exportable in KMS. + +Forgejo can generate the Apple-uploadable CSR with: + +```sh +Scripts/forgejo-dispatch.sh apple-developer-id-kms-csr.yml --ref main +``` + +Apple currently documents Developer ID certificate creation through the +Developer website or Xcode. After downloading the returned `.cer`, keep it with +release artifacts; do not convert this key path into an exportable `.p12`. + +The active certificate created from this path is Apple certificate +`9JKN6HXBHC`, stored at +`Apple/Certificates/developer-id-application-9JKN6HXBHC.cer`. Its public key +matches KMS key version `apple-developer-id-application/cryptoKeyVersions/1`. + +## Apple iOS Distribution CSR + +The iOS App Store distribution certificate uses the same CSR builder with the +`apple-ios-distribution` KMS key: + +```sh +Scripts/apple/google-kms-csr.py \ + --kms-key apple-ios-distribution \ + --common-name "Burrow iOS Distribution" \ + --output ios-distribution.certSigningRequest +``` + +The App Store Connect API can create the certificate from that CSR: + +```sh +Scripts/apple/create-asc-certificate.mjs \ + --certificate-type IOS_DISTRIBUTION \ + --csr-file ios-distribution.certSigningRequest \ + --out-dir Apple/Certificates +``` + +The active certificate created from this path is Apple certificate +`3G42677598`, stored at `Apple/Certificates/ios-distribution-3G42677598.cer`. +Its public key matches KMS key version +`apple-ios-distribution/cryptoKeyVersions/1`. + +## Sparkle Appcast Signing + +Sparkle appcasts keep `sparkle-ed25519`, a Google KMS key with algorithm +`EC_SIGN_ED25519` and software protection level, for small signing probes and +future signing-service work. Google KMS rejects Ed25519 at HSM protection level +and also rejects full-size macOS release archives as direct Ed25519 messages. +The tester pipeline therefore signs normal Sparkle archives directly from the +decrypted `SPARKLE_EDDSA_KEY_PATH` release seed so the appcast contains the +standard full-archive EdDSA signature Sparkle verifies. + +The public EdDSA key embedded in macOS release builds is: + +```text +uugZuJeqvvKd91NZ6F1Fv2cQenUbIG/ZW3L9MuaEz30= +``` + +The appcast signer is: + +```sh +Scripts/sparkle/sign-appcast-kms.py \ + --appcast dist/builds//sparkle//appcast.xml \ + --artifact-dir dist/builds//sparkle/ +``` + +## Run + +```sh +Scripts/identity-tofu.sh init -backend-config=backend.hcl +Scripts/identity-tofu.sh plan -var-file=terraform.tfvars +``` + +For local syntax work without remote state: + +```sh +Scripts/identity-tofu.sh init -backend=false +Scripts/identity-tofu.sh validate +``` + +Start with `manage_google = false`. Import existing resources before enabling +management, then turn on one resource group at a time. + +## Bootstrap Imports + +The first live Apple Developer ID pass may need these resources imported before +an `identity` apply can own them: + +```sh +Scripts/identity-tofu.sh import 'google_kms_key_ring.identity[0]' \ + projects/project-88c23ce9-918a-470a-b33/locations/global/keyRings/burrow-identity + +Scripts/identity-tofu.sh import 'google_kms_crypto_key.signing["apple_developer_id_application"]' \ + projects/project-88c23ce9-918a-470a-b33/locations/global/keyRings/burrow-identity/cryptoKeys/apple-developer-id-application + +Scripts/identity-tofu.sh import 'google_kms_crypto_key.signing["apple_ios_distribution"]' \ + projects/project-88c23ce9-918a-470a-b33/locations/global/keyRings/burrow-identity/cryptoKeys/apple-ios-distribution + +Scripts/identity-tofu.sh import 'google_kms_crypto_key.signing["sparkle_ed25519"]' \ + projects/project-88c23ce9-918a-470a-b33/locations/global/keyRings/burrow-identity/cryptoKeys/sparkle-ed25519 + +Scripts/identity-tofu.sh import 'google_service_account.runner[0]' \ + projects/project-88c23ce9-918a-470a-b33/serviceAccounts/burrow-forgejo-runner@project-88c23ce9-918a-470a-b33.iam.gserviceaccount.com +``` + +Run imports with the same `manage_google`, key-ring, and service-account +variables that will be used for apply. Key-level IAM bindings should be imported +after the signing keys and service account exist. diff --git a/infra/identity/backend.hcl.example b/infra/identity/backend.hcl.example new file mode 100644 index 0000000..60350e3 --- /dev/null +++ b/infra/identity/backend.hcl.example @@ -0,0 +1,4 @@ +bucket = "burrow-opentofu-state" +key = "identity/identity.tfstate" +region = "us-west-2" +encrypt = true diff --git a/infra/identity/google.tf b/infra/identity/google.tf new file mode 100644 index 0000000..a429401 --- /dev/null +++ b/infra/identity/google.tf @@ -0,0 +1,172 @@ +locals { + google_required_services = toset([ + "cloudkms.googleapis.com", + "cloudresourcemanager.googleapis.com", + "iam.googleapis.com", + "iamcredentials.googleapis.com", + "sts.googleapis.com", + ]) + + google_existing_kms_key_ring_id = var.google_kms_key_ring_id != "" ? var.google_kms_key_ring_id : "projects/${var.google_project_id}/locations/${var.google_kms_key_ring_location}/keyRings/${var.google_kms_key_ring_name}" + + google_kms_key_ring_id = var.manage_google_kms_key_ring ? ( + google_kms_key_ring.identity[0].id + ) : local.google_existing_kms_key_ring_id + + google_runner_service_account_email = var.manage_google_runner_service_account ? ( + google_service_account.runner[0].email + ) : var.google_runner_service_account_email + + google_runner_wif_group_members = var.google_wif_runner_group != "" ? ( + toset([ + "principalSet://iam.googleapis.com/projects/${var.google_project_number}/locations/global/workloadIdentityPools/${var.google_wif_pool_id}/group/${var.google_wif_runner_group}" + ]) + ) : ( + toset([]) + ) + + google_runner_wif_client_members = var.google_wif_runner_client_id != "" ? ( + toset([ + "principalSet://iam.googleapis.com/projects/${var.google_project_number}/locations/global/workloadIdentityPools/${var.google_wif_pool_id}/attribute.burrow_client_id/${var.google_wif_runner_client_id}" + ]) + ) : ( + toset([]) + ) + + google_runner_wif_members = setunion( + local.google_runner_wif_group_members, + local.google_runner_wif_client_members, + var.google_wif_runner_group == "" && var.google_wif_runner_client_id == "" ? toset([ + "principalSet://iam.googleapis.com/projects/${var.google_project_number}/locations/global/workloadIdentityPools/${var.google_wif_pool_id}/*" + ]) : toset([]) + ) + + google_signer_members = setunion( + var.google_release_signer_members, + toset(["serviceAccount:${local.google_runner_service_account_email}"]), + ) + + google_signer_grants = var.manage_google ? { + for grant in flatten([ + for key_name in keys(google_kms_crypto_key.signing) : [ + for member in local.google_signer_members : { + id = "${key_name}|${member}" + key_name = key_name + member = member + } + ] + ]) : grant.id => grant + } : {} +} + +resource "google_project_service" "identity" { + for_each = var.manage_google ? local.google_required_services : toset([]) + + project = var.google_project_id + service = each.value + disable_on_destroy = false +} + +resource "google_kms_key_ring" "identity" { + count = var.manage_google && var.manage_google_kms_key_ring ? 1 : 0 + + project = var.google_project_id + location = var.google_kms_key_ring_location + name = var.google_kms_key_ring_name + + depends_on = [google_project_service.identity] +} + +resource "google_kms_crypto_key" "signing" { + for_each = var.manage_google && local.google_kms_key_ring_id != "" ? var.google_signing_keys : {} + + name = each.value.name + key_ring = local.google_kms_key_ring_id + purpose = "ASYMMETRIC_SIGN" + labels = merge( + { + project = "burrow" + component = "identity" + managed_by = "opentofu" + }, + var.tags, + try(each.value.labels, {}), + ) + + version_template { + algorithm = try(each.value.algorithm, "RSA_SIGN_PKCS1_2048_SHA256") + protection_level = try(each.value.protection_level, "HSM") + } + + lifecycle { + prevent_destroy = true + } +} + +resource "google_service_account" "runner" { + count = var.manage_google && var.manage_google_runner_service_account ? 1 : 0 + + project = var.google_project_id + account_id = var.google_runner_service_account_id + display_name = "Burrow Forgejo Runner" + description = "Authentik-backed WIF service account for Burrow Forgejo runners." + + depends_on = [google_project_service.identity] +} + +resource "google_iam_workload_identity_pool" "burrow" { + count = var.manage_google ? 1 : 0 + + project = var.google_project_id + workload_identity_pool_id = var.google_wif_pool_id + display_name = "Burrow Authentik" + description = "Authentik-issued identities for Burrow automation." + disabled = false + + depends_on = [google_project_service.identity] +} + +resource "google_iam_workload_identity_pool_provider" "forgejo_runners" { + count = var.manage_google ? 1 : 0 + + project = var.google_project_id + workload_identity_pool_id = google_iam_workload_identity_pool.burrow[0].workload_identity_pool_id + workload_identity_pool_provider_id = var.google_wif_provider_id + display_name = "Burrow Forgejo Runners" + description = "Authentik OIDC provider for Burrow Forgejo runner cloud access." + disabled = false + + attribute_mapping = { + "google.subject" = "assertion.sub" + "google.groups" = "assertion.groups" + "attribute.burrow_subject" = "assertion.sub" + "attribute.burrow_username" = "assertion.preferred_username" + "attribute.burrow_email" = "assertion.email" + "attribute.burrow_client_id" = "assertion.aud" + } + + attribute_condition = var.google_wif_attribute_condition + + oidc { + issuer_uri = var.google_wif_issuer_uri + allowed_audiences = var.google_wif_allowed_audiences + } +} + +resource "google_service_account_iam_member" "runner_wif" { + for_each = var.manage_google ? local.google_runner_wif_members : toset([]) + + service_account_id = var.manage_google_runner_service_account ? ( + google_service_account.runner[0].name + ) : "projects/${var.google_project_id}/serviceAccounts/${local.google_runner_service_account_email}" + role = "roles/iam.workloadIdentityUser" + member = each.value +} + +resource "google_kms_crypto_key_iam_member" "signer" { + for_each = local.google_signer_grants + + crypto_key_id = google_kms_crypto_key.signing[each.value.key_name].id + role = "roles/cloudkms.signerVerifier" + member = each.value.member +} diff --git a/infra/identity/outputs.tf b/infra/identity/outputs.tf new file mode 100644 index 0000000..2a0b9a0 --- /dev/null +++ b/infra/identity/outputs.tf @@ -0,0 +1,19 @@ +output "google_kms_key_ring_id" { + description = "Google KMS key ring id used by the identity stack." + value = local.google_kms_key_ring_id +} + +output "google_runner_service_account_email" { + description = "Forgejo runner service account email." + value = local.google_runner_service_account_email +} + +output "google_wif_pool_name" { + description = "Google WIF pool resource name when managed." + value = try(google_iam_workload_identity_pool.burrow[0].name, null) +} + +output "google_signing_key_ids" { + description = "Managed Google KMS signing key ids." + value = { for name, key in google_kms_crypto_key.signing : name => key.id } +} diff --git a/infra/identity/providers.tf b/infra/identity/providers.tf new file mode 100644 index 0000000..5343c2e --- /dev/null +++ b/infra/identity/providers.tf @@ -0,0 +1,3 @@ +provider "google" { + project = var.google_project_id +} diff --git a/infra/identity/terraform.tfvars.example b/infra/identity/terraform.tfvars.example new file mode 100644 index 0000000..7411302 --- /dev/null +++ b/infra/identity/terraform.tfvars.example @@ -0,0 +1,15 @@ +manage_google = false + +google_project_id = "project-88c23ce9-918a-470a-b33" +google_project_number = "416198671487" + +# Import the key ring before setting this true if it already exists. +manage_google_kms_key_ring = false + +# Create this only after the Authentik WIF provider design is final. +manage_google_runner_service_account = false + +google_wif_issuer_uri = "https://auth.burrow.net/application/o/google-cloud/" +google_wif_allowed_audiences = ["google-wif.burrow.net"] +google_wif_runner_group = "" +google_wif_runner_client_id = "google-wif.burrow.net" diff --git a/infra/identity/variables.tf b/infra/identity/variables.tf new file mode 100644 index 0000000..68fad72 --- /dev/null +++ b/infra/identity/variables.tf @@ -0,0 +1,201 @@ +variable "manage_google" { + description = "Manage Google Cloud identity and WIF resources." + type = bool + default = false +} + +variable "google_project_id" { + description = "Google Cloud project id for Burrow identity resources." + type = string + default = "project-88c23ce9-918a-470a-b33" +} + +variable "google_project_number" { + description = "Google Cloud project number for IAM principal URIs." + type = string + default = "416198671487" +} + +variable "google_kms_key_ring_name" { + description = "Google KMS key ring for identity and release signing keys." + type = string + default = "burrow-identity" +} + +variable "google_kms_key_ring_location" { + description = "Google KMS key ring location." + type = string + default = "global" +} + +variable "google_kms_key_ring_id" { + description = "Existing Google KMS key ring id. Leave blank to derive it from project, location, and name." + type = string + default = "" +} + +variable "manage_google_kms_key_ring" { + description = "Create/manage the Google KMS key ring. Import existing rings before enabling this." + type = bool + default = false +} + +variable "google_signing_keys" { + description = "Non-exportable Burrow signing keys to create in the identity key ring." + type = map(object({ + name = string + algorithm = optional(string, "RSA_SIGN_PKCS1_2048_SHA256") + protection_level = optional(string, "HSM") + labels = optional(map(string), {}) + })) + default = { + authentik = { + name = "authentik-signing" + labels = { + key_target = "authentik" + } + } + saml_ca = { + name = "saml-ca" + labels = { + key_target = "saml-ca" + } + } + release = { + name = "release-signing" + labels = { + key_target = "release-signing" + } + } + package_apt_repository = { + name = "package-apt-repository" + labels = { + key_target = "package-apt-repository" + repo_format = "apt" + } + } + package_rpm_repository = { + name = "package-rpm-repository" + labels = { + key_target = "package-rpm-repository" + repo_format = "rpm" + } + } + package_pacman_repository = { + name = "package-pacman-repository" + labels = { + key_target = "package-pacman-repository" + repo_format = "pacman" + } + } + package_flatpak_repository = { + name = "package-flatpak-repository" + labels = { + key_target = "package-flatpak-repository" + repo_format = "flatpak" + } + } + package_aur_source = { + name = "package-aur-source" + labels = { + key_target = "package-aur-source" + repo_format = "aur" + } + } + apple_developer_id_application = { + name = "apple-developer-id-application" + labels = { + key_target = "apple-developer-id-application" + apple_cert_type = "developer-id-application" + } + } + apple_ios_distribution = { + name = "apple-ios-distribution" + labels = { + key_target = "apple-ios-distribution" + apple_cert_type = "ios-distribution" + } + } + sparkle_ed25519 = { + name = "sparkle-ed25519" + algorithm = "EC_SIGN_ED25519" + protection_level = "SOFTWARE" + labels = { + key_target = "sparkle-ed25519" + release_surface = "sparkle" + } + } + } +} + +variable "google_release_signer_members" { + description = "Additional IAM members allowed to sign/verify with Burrow release and package repository keys." + type = set(string) + default = [] +} + +variable "manage_google_runner_service_account" { + description = "Create/manage the Forgejo runner service account for WIF." + type = bool + default = false +} + +variable "google_runner_service_account_id" { + description = "Google service account id for Authentik-backed Forgejo runners." + type = string + default = "burrow-forgejo-runner" +} + +variable "google_runner_service_account_email" { + description = "Existing runner service account email when not managed here." + type = string + default = "burrow-forgejo-runner@project-88c23ce9-918a-470a-b33.iam.gserviceaccount.com" +} + +variable "google_wif_pool_id" { + description = "Workload Identity Federation pool id for Burrow automation." + type = string + default = "burrow-authentik" +} + +variable "google_wif_provider_id" { + description = "Workload Identity Federation provider id for Authentik-issued OIDC tokens." + type = string + default = "forgejo-runners" +} + +variable "google_wif_issuer_uri" { + description = "Authentik OIDC issuer used by Google WIF." + type = string + default = "https://auth.burrow.net/application/o/google-cloud/" +} + +variable "google_wif_allowed_audiences" { + description = "Allowed audiences for Authentik-issued WIF tokens." + type = list(string) + default = ["google-wif.burrow.net"] +} + +variable "google_wif_runner_group" { + description = "Google groups principal allowed to assume the runner service account. Leave empty for machine-to-machine client credentials." + type = string + default = "" +} + +variable "google_wif_runner_client_id" { + description = "Mapped Authentik OIDC audience/client value allowed to assume the runner service account for machine-to-machine CI. Empty disables this grant." + type = string + default = "google-wif.burrow.net" +} + +variable "google_wif_attribute_condition" { + description = "CEL condition applied to Authentik-issued WIF tokens." + type = string + default = "assertion.iss == 'https://auth.burrow.net/application/o/google-cloud/'" +} + +variable "tags" { + description = "Additional labels applied to supported Google resources." + type = map(string) + default = {} +} diff --git a/infra/identity/versions.tf b/infra/identity/versions.tf new file mode 100644 index 0000000..2b6a05d --- /dev/null +++ b/infra/identity/versions.tf @@ -0,0 +1,12 @@ +terraform { + required_version = ">= 1.8.0" + + required_providers { + google = { + source = "hashicorp/google" + version = ">= 5.40.0, < 7.0" + } + } + + backend "s3" {} +} diff --git a/infra/openbao/.gitignore b/infra/openbao/.gitignore new file mode 100644 index 0000000..b12b9ed --- /dev/null +++ b/infra/openbao/.gitignore @@ -0,0 +1,5 @@ +.terraform/ +backend.hcl +terraform.tfstate +terraform.tfstate.backup +*.tfplan diff --git a/infra/openbao/.terraform.lock.hcl b/infra/openbao/.terraform.lock.hcl new file mode 100644 index 0000000..ded7beb --- /dev/null +++ b/infra/openbao/.terraform.lock.hcl @@ -0,0 +1,43 @@ +# This file is maintained automatically by "tofu init". +# Manual edits may be lost in future updates. + +provider "registry.opentofu.org/hashicorp/google" { + version = "6.50.0" + constraints = ">= 5.40.0, < 7.0.0" + hashes = [ + "h1:MAAe4zFFdqS9M5rpmJK/vKgdb6ZMD/s/0Xd97yTDipA=", + "zh:1d4695f807d998f11fcdcfa174766287b82a8093513af857bcdad2d81c642480", + "zh:3173ac5df0294624d113812e49e2a55714aff7db617488168cecdf4168df9e29", + "zh:34d2b3d44c23bd6354fc4ab5917b302872ea1ab8de107034567f955b1717fa5b", + "zh:3a77f3cc2f3664cd5aaeeef4d044e6ec1695a079588fffec3ca03953664e5f04", + "zh:6b444e4b629ea8dc8cb112a39dde098dc5584d26d6de4177558f556a9a226696", + "zh:96545c8cd4d3a57069c5d1799eab5aedd887e16d98b5559a195f6d2c2d9bc674", + "zh:ba464caafde95ee16671d6b5ec90f053ed77a9d06c567456db6efd9160fa3165", + "zh:d876938e5b0d3f57a984d9be72467995f87fef6569968623415dc51d9f54d30b", + "zh:dfd908d873e314ab807d0abc9cfd42d2611cd06dc1b9ec719ebdbb738e8e68d6", + "zh:f9f16819a7738d564afd45fd169ba61004ec4e4e7089d2a4950cb8895be1fe1f", + ] +} + +provider "registry.opentofu.org/hashicorp/vault" { + version = "5.9.0" + constraints = ">= 4.5.0, < 6.0.0" + hashes = [ + "h1:9U4AT36IqNYXfQMR7nf+oywulVKYua473W4NmuwVb7M=", + "zh:03cb46fab606872e3fc06e27f8d14b911b7a9781d0f32af335c7287a9dbe4f4f", + "zh:1e69677b09329b009a8791f9cbb556790fb4dbddc1360f953345259892dc6c5b", + "zh:4e5a3dc82e70d88f5671968b7f2217163815be259d0b26dfcc9a897409c491fa", + "zh:51b82b358fe52099ef29cae62e2040ae0224ceea40a7dfdf0b69de90fb0233a8", + "zh:60ec3477fbe712b3269eec2e4d9d5921e2e68d0861d77e11e91bea088aab27bf", + "zh:64e58a3e3fd61005b54d71eee792b8576ab42ea4cd711515043a3ac0d8bc7919", + "zh:69142fb83aff31e27f5b3d9e7afb7594013b63e490cfcef8678fd0d724609359", + "zh:6f2e58ba6bd41c4d9e0e752e55eb7d86104f9d786cf57fa8dc960c61b574f9ce", + "zh:73390b7cb186310e5aaf4a1baaa639ab0302a8da4db130b4e28ebced3ba103fe", + "zh:a2214b3fda93cfed89ba1a7d714fe8b015176927605b215365978efdaae1c6db", + "zh:b275ee0f0a63765364d2e6979e3a11464d2c2ce6d3ce9bd15b3f503aea6f12b0", + "zh:bb2cd553b1c589a0f6f5b0575e1b176a9d91c1b20c6375d1afd63bb2a47fd014", + "zh:bc38e48ae5cdb8219fef326366f46e6a25e7f77f9bbcd9bdc80c7cb960de81ed", + "zh:e54af55cf667759a400af07b927b5034f1733e6527f9352b84001205561dcf9e", + "zh:f617688ef4568c0de8a28d5e1fa3714fb2eeab9f8cf7bcf20af42a1a511844be", + ] +} diff --git a/infra/openbao/README.md b/infra/openbao/README.md new file mode 100644 index 0000000..bca0089 --- /dev/null +++ b/infra/openbao/README.md @@ -0,0 +1,36 @@ +# Burrow OpenBao Control Plane + +This OpenTofu stack manages non-secret infrastructure around +`vault.burrow.net`. + +It may manage: + +- Google KMS seal-wrapping keys for OpenBao +- the OpenBao `age/` KV v2 mount used for migrated runtime secrets +- OpenBao policies and Authentik OIDC roles +- AppRole auth scaffolding for machine consumers + +It must not manage: + +- secret values +- root tokens +- AppRole SecretIDs +- release-signing key material + +## Run + +```sh +Scripts/openbao-tofu.sh init -backend-config=backend.hcl +Scripts/openbao-tofu.sh plan -var-file=terraform.tfvars +``` + +For local syntax work: + +```sh +Scripts/openbao-tofu.sh init -backend=false +Scripts/openbao-tofu.sh validate +``` + +The Vault/OpenBao provider reads `VAULT_TOKEN` from the environment. Keep +`manage_openbao_config = false` until `vault.burrow.net` is initialized and an +operator token is available out of band. diff --git a/infra/openbao/backend.hcl.example b/infra/openbao/backend.hcl.example new file mode 100644 index 0000000..53c6b7d --- /dev/null +++ b/infra/openbao/backend.hcl.example @@ -0,0 +1,4 @@ +bucket = "burrow-opentofu-state" +key = "openbao/openbao.tfstate" +region = "us-west-2" +encrypt = true diff --git a/infra/openbao/google.tf b/infra/openbao/google.tf new file mode 100644 index 0000000..0b34f7c --- /dev/null +++ b/infra/openbao/google.tf @@ -0,0 +1,65 @@ +locals { + google_required_services = toset([ + "cloudkms.googleapis.com", + "cloudresourcemanager.googleapis.com", + "iam.googleapis.com", + ]) + + google_existing_kms_key_ring_id = var.google_kms_key_ring_id != "" ? var.google_kms_key_ring_id : "projects/${var.google_project_id}/locations/${var.google_kms_key_ring_location}/keyRings/${var.google_kms_key_ring_name}" + + google_kms_key_ring_id = var.manage_google_kms_key_ring ? ( + google_kms_key_ring.openbao[0].id + ) : local.google_existing_kms_key_ring_id +} + +resource "google_project_service" "openbao" { + for_each = var.manage_google ? local.google_required_services : toset([]) + + project = var.google_project_id + service = each.value + disable_on_destroy = false +} + +resource "google_kms_key_ring" "openbao" { + count = var.manage_google && var.manage_google_kms_key_ring ? 1 : 0 + + project = var.google_project_id + location = var.google_kms_key_ring_location + name = var.google_kms_key_ring_name + + depends_on = [google_project_service.openbao] +} + +resource "google_kms_crypto_key" "openbao_seal" { + count = var.manage_google && local.google_kms_key_ring_id != "" ? 1 : 0 + + name = var.google_openbao_seal_key_name + key_ring = local.google_kms_key_ring_id + purpose = "ENCRYPT_DECRYPT" + labels = merge( + { + project = "burrow" + component = "openbao" + managed_by = "opentofu" + key_target = "seal" + }, + var.tags, + ) + + version_template { + algorithm = "GOOGLE_SYMMETRIC_ENCRYPTION" + protection_level = "HSM" + } + + lifecycle { + prevent_destroy = true + } +} + +resource "google_kms_crypto_key_iam_member" "openbao_seal" { + for_each = var.manage_google && local.google_kms_key_ring_id != "" ? var.google_openbao_seal_members : toset([]) + + crypto_key_id = google_kms_crypto_key.openbao_seal[0].id + role = "roles/cloudkms.cryptoKeyEncrypterDecrypter" + member = each.value +} diff --git a/infra/openbao/openbao.tf b/infra/openbao/openbao.tf new file mode 100644 index 0000000..619f50e --- /dev/null +++ b/infra/openbao/openbao.tf @@ -0,0 +1,125 @@ +resource "vault_mount" "age" { + count = var.manage_openbao_config ? 1 : 0 + + path = var.age_mount_path + type = "kv-v2" + description = "Migrated Burrow age-managed runtime secrets." + + options = { + version = "2" + } +} + +resource "vault_policy" "admin" { + count = var.manage_openbao_config ? 1 : 0 + + name = "burrow-openbao-admin" + + policy = <<-EOT + path "*" { + capabilities = ["create", "read", "update", "delete", "list", "sudo"] + } + EOT +} + +resource "vault_policy" "runtime_read" { + count = var.manage_openbao_config ? 1 : 0 + + name = "burrow-runtime-read" + + policy = <<-EOT + path "${var.age_mount_path}/data/*" { + capabilities = ["read"] + } + + path "${var.age_mount_path}/metadata/*" { + capabilities = ["list", "read"] + } + EOT +} + +resource "vault_auth_backend" "approle" { + count = var.manage_openbao_config ? 1 : 0 + + path = var.approle_auth_path + type = "approle" + description = "Machine auth for Burrow runtime secret consumers." + + tune { + token_type = "default-service" + } +} + +resource "vault_approle_auth_backend_role" "runtime" { + count = var.manage_openbao_config ? 1 : 0 + + backend = vault_auth_backend.approle[0].path + role_name = var.runtime_approle_role_name + bind_secret_id = true + + token_policies = [vault_policy.runtime_read[0].name] + token_ttl = var.runtime_approle_token_ttl_seconds + token_max_ttl = var.runtime_approle_token_max_ttl_seconds + token_num_uses = 0 + + secret_id_ttl = var.runtime_approle_secret_id_ttl_seconds + secret_id_num_uses = var.runtime_approle_secret_id_num_uses +} + +resource "vault_jwt_auth_backend" "authentik" { + count = var.manage_openbao_config ? 1 : 0 + + path = "oidc" + type = "oidc" + oidc_discovery_url = var.authentik_issuer + bound_issuer = var.authentik_issuer + oidc_client_id = var.authentik_client_id + default_role = "burrow-admin" + + tune { + listing_visibility = "unauth" + token_type = "default-service" + } +} + +resource "vault_jwt_auth_backend_role" "admin" { + count = var.manage_openbao_config ? 1 : 0 + + backend = vault_jwt_auth_backend.authentik[0].path + role_name = "burrow-admin" + role_type = "oidc" + user_claim = "email" + + allowed_redirect_uris = [ + "https://vault.burrow.net/ui/vault/auth/oidc/oidc/callback", + "http://localhost:8250/oidc/callback", + ] + + bound_audiences = [var.authentik_client_id] + bound_claims = { + groups = var.authentik_admin_group + } + oidc_scopes = ["openid", "profile", "email", "groups"] + token_policies = [vault_policy.admin[0].name] +} + +resource "vault_jwt_auth_backend_role" "runtime" { + count = var.manage_openbao_config ? 1 : 0 + + backend = vault_jwt_auth_backend.authentik[0].path + role_name = "burrow-runtime-read" + role_type = "oidc" + user_claim = "email" + + allowed_redirect_uris = [ + "https://vault.burrow.net/ui/vault/auth/oidc/oidc/callback", + "http://localhost:8250/oidc/callback", + ] + + bound_audiences = [var.authentik_client_id] + bound_claims = { + groups = var.authentik_runtime_group + } + oidc_scopes = ["openid", "profile", "email", "groups"] + token_policies = [vault_policy.runtime_read[0].name] +} diff --git a/infra/openbao/outputs.tf b/infra/openbao/outputs.tf new file mode 100644 index 0000000..8474957 --- /dev/null +++ b/infra/openbao/outputs.tf @@ -0,0 +1,14 @@ +output "google_kms_key_ring_id" { + description = "Google KMS key ring id used by the OpenBao stack." + value = local.google_kms_key_ring_id +} + +output "google_openbao_seal_key_id" { + description = "Google KMS seal key id when managed." + value = try(google_kms_crypto_key.openbao_seal[0].id, null) +} + +output "openbao_age_mount_path" { + description = "OpenBao KV v2 mount path for migrated age secrets." + value = var.age_mount_path +} diff --git a/infra/openbao/providers.tf b/infra/openbao/providers.tf new file mode 100644 index 0000000..7e485d4 --- /dev/null +++ b/infra/openbao/providers.tf @@ -0,0 +1,8 @@ +provider "google" { + project = var.google_project_id +} + +provider "vault" { + address = var.openbao_address + skip_tls_verify = var.openbao_skip_tls_verify +} diff --git a/infra/openbao/terraform.tfvars.example b/infra/openbao/terraform.tfvars.example new file mode 100644 index 0000000..ae1a4e1 --- /dev/null +++ b/infra/openbao/terraform.tfvars.example @@ -0,0 +1,8 @@ +manage_google = false +manage_openbao_config = false +google_project_id = "project-88c23ce9-918a-470a-b33" +openbao_address = "https://vault.burrow.net" +authentik_issuer = "https://auth.burrow.net/application/o/openbao/" +authentik_client_id = "vault.burrow.net" +authentik_admin_group = "burrow-admins" +authentik_runtime_group = "burrow-automation" diff --git a/infra/openbao/variables.tf b/infra/openbao/variables.tf new file mode 100644 index 0000000..011eaa7 --- /dev/null +++ b/infra/openbao/variables.tf @@ -0,0 +1,137 @@ +variable "openbao_address" { + description = "OpenBao API address. The Vault provider reads the token from VAULT_TOKEN." + type = string + default = "https://vault.burrow.net" +} + +variable "openbao_skip_tls_verify" { + description = "Skip TLS verification for local bootstrap only." + type = bool + default = false +} + +variable "age_mount_path" { + description = "KV v2 mount path for migrated age-managed runtime secrets." + type = string + default = "age" +} + +variable "manage_openbao_config" { + description = "Manage OpenBao mounts, policies, and Authentik OIDC auth. Requires VAULT_TOKEN." + type = bool + default = false +} + +variable "authentik_issuer" { + description = "Authentik OpenBao OIDC issuer." + type = string + default = "https://auth.burrow.net/application/o/openbao/" +} + +variable "authentik_client_id" { + description = "Public Authentik OpenBao OIDC client id." + type = string + default = "vault.burrow.net" +} + +variable "authentik_admin_group" { + description = "Authentik group allowed to administer OpenBao." + type = string + default = "burrow-admins" +} + +variable "authentik_runtime_group" { + description = "Authentik group allowed to read runtime secrets." + type = string + default = "burrow-automation" +} + +variable "approle_auth_path" { + description = "OpenBao AppRole auth mount path for machine consumers." + type = string + default = "approle" +} + +variable "runtime_approle_role_name" { + description = "AppRole role name used by Burrow runtime secret consumers." + type = string + default = "burrow-runtime" +} + +variable "runtime_approle_token_ttl_seconds" { + description = "Token TTL for runtime AppRole login." + type = number + default = 3600 +} + +variable "runtime_approle_token_max_ttl_seconds" { + description = "Maximum token TTL for runtime AppRole login." + type = number + default = 7200 +} + +variable "runtime_approle_secret_id_ttl_seconds" { + description = "SecretID TTL for runtime AppRole. Zero means no expiry; rotate manually." + type = number + default = 0 +} + +variable "runtime_approle_secret_id_num_uses" { + description = "SecretID use limit for runtime AppRole. Zero means unlimited uses; rotate manually." + type = number + default = 0 +} + +variable "manage_google" { + description = "Manage Google Cloud KMS resources for OpenBao seal wrapping." + type = bool + default = false +} + +variable "google_project_id" { + description = "Google Cloud project id for OpenBao seal wrapping." + type = string + default = "project-88c23ce9-918a-470a-b33" +} + +variable "manage_google_kms_key_ring" { + description = "Create/manage the Google KMS key ring. Existing rings should be imported before enabling this." + type = bool + default = false +} + +variable "google_kms_key_ring_name" { + description = "Google KMS key ring for OpenBao seal wrapping." + type = string + default = "burrow-identity" +} + +variable "google_kms_key_ring_location" { + description = "Google KMS key ring location." + type = string + default = "global" +} + +variable "google_kms_key_ring_id" { + description = "Existing Google KMS key ring id." + type = string + default = "" +} + +variable "google_openbao_seal_key_name" { + description = "Google KMS symmetric key used for OpenBao seal wrapping." + type = string + default = "openbao-seal" +} + +variable "google_openbao_seal_members" { + description = "IAM members allowed to encrypt/decrypt with the OpenBao seal key." + type = set(string) + default = [] +} + +variable "tags" { + description = "Additional labels applied to supported Google resources." + type = map(string) + default = {} +} diff --git a/infra/openbao/versions.tf b/infra/openbao/versions.tf new file mode 100644 index 0000000..9de0722 --- /dev/null +++ b/infra/openbao/versions.tf @@ -0,0 +1,16 @@ +terraform { + required_version = ">= 1.8.0" + + required_providers { + google = { + source = "hashicorp/google" + version = ">= 5.40.0, < 7.0" + } + vault = { + source = "hashicorp/vault" + version = ">= 4.5.0, < 6.0" + } + } + + backend "s3" {} +} diff --git a/infra/releases/.gitignore b/infra/releases/.gitignore new file mode 100644 index 0000000..493f814 --- /dev/null +++ b/infra/releases/.gitignore @@ -0,0 +1,5 @@ +.terraform/ +*.tfstate +*.tfstate.* +backend.hcl +terraform.tfvars diff --git a/infra/releases/.terraform.lock.hcl b/infra/releases/.terraform.lock.hcl new file mode 100644 index 0000000..0a51a6e --- /dev/null +++ b/infra/releases/.terraform.lock.hcl @@ -0,0 +1,20 @@ +# This file is maintained automatically by "tofu init". +# Manual edits may be lost in future updates. + +provider "registry.opentofu.org/hashicorp/google" { + version = "6.50.0" + constraints = ">= 5.40.0, < 7.0.0" + hashes = [ + "h1:MAAe4zFFdqS9M5rpmJK/vKgdb6ZMD/s/0Xd97yTDipA=", + "zh:1d4695f807d998f11fcdcfa174766287b82a8093513af857bcdad2d81c642480", + "zh:3173ac5df0294624d113812e49e2a55714aff7db617488168cecdf4168df9e29", + "zh:34d2b3d44c23bd6354fc4ab5917b302872ea1ab8de107034567f955b1717fa5b", + "zh:3a77f3cc2f3664cd5aaeeef4d044e6ec1695a079588fffec3ca03953664e5f04", + "zh:6b444e4b629ea8dc8cb112a39dde098dc5584d26d6de4177558f556a9a226696", + "zh:96545c8cd4d3a57069c5d1799eab5aedd887e16d98b5559a195f6d2c2d9bc674", + "zh:ba464caafde95ee16671d6b5ec90f053ed77a9d06c567456db6efd9160fa3165", + "zh:d876938e5b0d3f57a984d9be72467995f87fef6569968623415dc51d9f54d30b", + "zh:dfd908d873e314ab807d0abc9cfd42d2611cd06dc1b9ec719ebdbb738e8e68d6", + "zh:f9f16819a7738d564afd45fd169ba61004ec4e4e7089d2a4950cb8895be1fe1f", + ] +} diff --git a/infra/releases/README.md b/infra/releases/README.md new file mode 100644 index 0000000..7d88b13 --- /dev/null +++ b/infra/releases/README.md @@ -0,0 +1,54 @@ +# Burrow Release Storage + +This OpenTofu stack owns Google Cloud Storage buckets used as Burrow's first +release-storage backup target. + +Garage is the required S3-compatible primary target. CI uses repo-owned storage +wrappers: they upload to Garage first, then mirror to GCS unless the backup is +explicitly disabled. + +The host activation point is `services.burrow.garage`, enabled by the forge +host. It creates the initial single-node Garage layout and buckets from +host-local runtime secrets. + +It may manage: + +- the release artifact bucket served by `releases.burrow.net` +- the signed package repository bucket served by `packages.burrow.net` +- the private Nix cache backup bucket for `nix.burrow.net` +- public object-read IAM for download buckets +- object-admin IAM for the Burrow Forgejo runner service account + +It must not manage: + +- Google service-account JSON keys +- release signing keys +- package repository metadata +- DNS or CDN cutover + +GCS access is keyless. Forgejo jobs run `Scripts/ci/google-wif-auth.sh` to +trade an Authentik-issued OIDC token for the Google runner service account in +project `project-88c23ce9-918a-470a-b33`, then use `gcloud storage` against the +managed backup buckets. The normal release path does not use rclone or Google +service-account JSON keys. + +The Nix cache backup bucket defaults to private. Attic remains the public cache +surface at `nix.burrow.net`; GCS is only a backup target for the Garage `attic` +bucket. + +## Run + +```sh +Scripts/releases-tofu.sh init -backend-config=backend.hcl +Scripts/releases-tofu.sh plan -var-file=terraform.tfvars +``` + +For local syntax work without remote state: + +```sh +Scripts/releases-tofu.sh init -backend=false +Scripts/releases-tofu.sh validate +``` + +Start with `manage_google = false`. Import existing buckets before enabling +management if they already exist. diff --git a/infra/releases/backend.hcl.example b/infra/releases/backend.hcl.example new file mode 100644 index 0000000..6f144bd --- /dev/null +++ b/infra/releases/backend.hcl.example @@ -0,0 +1,3 @@ +bucket = "burrow-opentofu-state" +key = "releases/releases.tfstate" +region = "us-west-2" diff --git a/infra/releases/outputs.tf b/infra/releases/outputs.tf new file mode 100644 index 0000000..ebb4611 --- /dev/null +++ b/infra/releases/outputs.tf @@ -0,0 +1,29 @@ +output "google_release_bucket_name" { + description = "GCS bucket used for release artifacts." + value = try(google_storage_bucket.release_storage["releases"].name, var.google_release_bucket_name) +} + +output "google_package_bucket_name" { + description = "GCS bucket used for signed package repositories." + value = try(google_storage_bucket.release_storage["packages"].name, var.google_package_bucket_name) +} + +output "google_nix_cache_bucket_name" { + description = "GCS bucket used for Nix cache backups." + value = try(google_storage_bucket.release_storage["nix-cache"].name, var.google_nix_cache_bucket_name) +} + +output "google_release_bucket_uri" { + description = "GCS URI for release artifacts." + value = "gs://${try(google_storage_bucket.release_storage["releases"].name, var.google_release_bucket_name)}" +} + +output "google_package_bucket_uri" { + description = "GCS URI for signed package repositories." + value = "gs://${try(google_storage_bucket.release_storage["packages"].name, var.google_package_bucket_name)}" +} + +output "google_nix_cache_bucket_uri" { + description = "GCS URI for Nix cache backups." + value = "gs://${try(google_storage_bucket.release_storage["nix-cache"].name, var.google_nix_cache_bucket_name)}" +} diff --git a/infra/releases/providers.tf b/infra/releases/providers.tf new file mode 100644 index 0000000..5343c2e --- /dev/null +++ b/infra/releases/providers.tf @@ -0,0 +1,3 @@ +provider "google" { + project = var.google_project_id +} diff --git a/infra/releases/storage.tf b/infra/releases/storage.tf new file mode 100644 index 0000000..f31f84c --- /dev/null +++ b/infra/releases/storage.tf @@ -0,0 +1,116 @@ +locals { + google_required_services = toset([ + "storage.googleapis.com", + ]) + + release_storage_buckets = { + releases = { + name = var.google_release_bucket_name + description = "Burrow release artifacts" + public = var.google_release_public_read + } + packages = { + name = var.google_package_bucket_name + description = "Burrow signed package repositories" + public = var.google_package_public_read + } + nix-cache = { + name = var.google_nix_cache_bucket_name + description = "Burrow Nix cache backups" + public = var.google_nix_cache_public_read + } + } + + release_storage_writer_members = setunion( + var.google_release_extra_writer_members, + toset(["serviceAccount:${var.google_runner_service_account_email}"]), + ) + + release_storage_writer_grants = var.manage_google ? { + for grant in flatten([ + for bucket_key in keys(local.release_storage_buckets) : [ + for member in local.release_storage_writer_members : { + id = "${bucket_key}|${member}" + bucket_key = bucket_key + member = member + } + ] + ]) : grant.id => grant + } : {} + + release_storage_public_grants = var.manage_google ? { + for bucket_key, bucket in local.release_storage_buckets : bucket_key => bucket + if bucket.public + } : {} +} + +resource "google_project_service" "release_storage" { + for_each = var.manage_google ? local.google_required_services : toset([]) + + project = var.google_project_id + service = each.value + disable_on_destroy = false +} + +resource "google_storage_bucket" "release_storage" { + for_each = var.manage_google ? local.release_storage_buckets : {} + + project = var.google_project_id + name = each.value.name + location = var.google_storage_location + uniform_bucket_level_access = true + public_access_prevention = each.value.public ? "inherited" : "enforced" + force_destroy = false + + labels = merge( + { + project = "burrow" + component = "release-storage" + managed_by = "opentofu" + bucket = each.key + }, + var.tags, + ) + + versioning { + enabled = true + } + + cors { + origin = var.google_storage_cors_origins + method = ["GET", "HEAD", "OPTIONS"] + response_header = ["Content-Type", "Content-Length", "ETag", "Cache-Control"] + max_age_seconds = 3600 + } + + lifecycle_rule { + condition { + age = 30 + with_state = "ARCHIVED" + num_newer_versions = 5 + matches_storage_class = ["STANDARD"] + } + + action { + type = "Delete" + } + } + + depends_on = [google_project_service.release_storage] +} + +resource "google_storage_bucket_iam_member" "release_storage_public_viewer" { + for_each = local.release_storage_public_grants + + bucket = google_storage_bucket.release_storage[each.key].name + role = "roles/storage.objectViewer" + member = "allUsers" +} + +resource "google_storage_bucket_iam_member" "release_storage_writer" { + for_each = local.release_storage_writer_grants + + bucket = google_storage_bucket.release_storage[each.value.bucket_key].name + role = "roles/storage.objectAdmin" + member = each.value.member +} diff --git a/infra/releases/terraform.tfvars.example b/infra/releases/terraform.tfvars.example new file mode 100644 index 0000000..59bd1e3 --- /dev/null +++ b/infra/releases/terraform.tfvars.example @@ -0,0 +1,12 @@ +manage_google = false + +google_project_id = "project-88c23ce9-918a-470a-b33" +google_storage_location = "US" +google_runner_service_account_email = "burrow-forgejo-runner@project-88c23ce9-918a-470a-b33.iam.gserviceaccount.com" +google_release_bucket_name = "burrow-net-releases" +google_package_bucket_name = "burrow-net-packages" +google_nix_cache_bucket_name = "burrow-net-nix-cache" +google_release_public_read = true +google_package_public_read = true +google_nix_cache_public_read = false +google_release_extra_writer_members = [] diff --git a/infra/releases/variables.tf b/infra/releases/variables.tf new file mode 100644 index 0000000..c1c8d4a --- /dev/null +++ b/infra/releases/variables.tf @@ -0,0 +1,81 @@ +variable "manage_google" { + description = "Manage Google Cloud release storage resources." + type = bool + default = false +} + +variable "google_project_id" { + description = "Google Cloud project id for Burrow release storage." + type = string + default = "project-88c23ce9-918a-470a-b33" +} + +variable "google_storage_location" { + description = "Google Cloud Storage bucket location for release, package, and cache backup buckets." + type = string + default = "US" +} + +variable "google_runner_service_account_email" { + description = "Forgejo runner service account email allowed to publish release, package, and cache backup objects." + type = string + default = "burrow-forgejo-runner@project-88c23ce9-918a-470a-b33.iam.gserviceaccount.com" +} + +variable "google_release_bucket_name" { + description = "GCS bucket for release artifacts served by releases.burrow.net." + type = string + default = "burrow-net-releases" +} + +variable "google_package_bucket_name" { + description = "GCS bucket for signed package repositories served by packages.burrow.net." + type = string + default = "burrow-net-packages" +} + +variable "google_nix_cache_bucket_name" { + description = "GCS backup bucket for the Garage-backed Burrow Nix cache." + type = string + default = "burrow-net-nix-cache" +} + +variable "google_release_public_read" { + description = "Grant allUsers objectViewer on the release artifact bucket." + type = bool + default = true +} + +variable "google_package_public_read" { + description = "Grant allUsers objectViewer on the package repository bucket." + type = bool + default = true +} + +variable "google_nix_cache_public_read" { + description = "Grant allUsers objectViewer on the Nix cache backup bucket." + type = bool + default = false +} + +variable "google_release_extra_writer_members" { + description = "Additional IAM members allowed to write release, repository, and cache backup objects." + type = set(string) + default = [] +} + +variable "google_storage_cors_origins" { + description = "Allowed origins for public release/package downloads." + type = list(string) + default = [ + "https://burrow.net", + "https://releases.burrow.net", + "https://packages.burrow.net", + ] +} + +variable "tags" { + description = "Additional labels applied to supported Google resources." + type = map(string) + default = {} +} diff --git a/infra/releases/versions.tf b/infra/releases/versions.tf new file mode 100644 index 0000000..2b6a05d --- /dev/null +++ b/infra/releases/versions.tf @@ -0,0 +1,12 @@ +terraform { + required_version = ">= 1.8.0" + + required_providers { + google = { + source = "hashicorp/google" + version = ">= 5.40.0, < 7.0" + } + } + + backend "s3" {} +} diff --git a/nixos/README.md b/nixos/README.md index 23907f3..c37a75b 100644 --- a/nixos/README.md +++ b/nixos/README.md @@ -2,7 +2,7 @@ This directory contains the Burrow forge host definition and the Hetzner bootstrap shape for `burrow-forge`. -Mail hosting is intentionally not part of this NixOS host in the current plan. Burrow's first mail path is Forward Email with Burrow-owned custom S3 backups; see [`docs/FORWARDEMAIL.md`](../docs/FORWARDEMAIL.md). +Mail hosting is intentionally not part of this NixOS host in the current plan. Burrow's first mail path is Forward Email with Burrow-owned custom S3 backups; see [`docs/FORWARDEMAIL.md`](../docs/FORWARDEMAIL.md). `inbox.burrow.net` remains the planned webmail surface for the later Stalwart phase. ## Files @@ -20,6 +20,7 @@ Mail hosting is intentionally not part of this NixOS host in the current plan. B - `../Scripts/nsc-build-and-upload-image.sh`: temporary Namespace builder -> raw image -> Hetzner snapshot - `../Scripts/bootstrap-forge-intake.sh`: copy the Forgejo bootstrap password and agent SSH key into `/var/lib/burrow/intake/` - `../Scripts/check-forge-host.sh`: verify Forgejo, Caddy, the local runner, optional NSC services, and optional Tailnet services after boot +- `../Scripts/grafana-tofu.sh`: manage Grafana API-created folders and dashboards with OpenTofu - `../Scripts/cloudflare-upsert-a-record.sh`: upsert DNS-only Cloudflare `A` records for Burrow host cutovers - `../Scripts/forge-deploy.sh`: remote `nixos-rebuild` entrypoint for the forge host - `../Scripts/provision-forgejo-nsc.sh`: render Burrow Namespace dispatcher/autoscaler runtime inputs and ensure the default Forgejo scope exists @@ -34,18 +35,21 @@ Mail hosting is intentionally not part of this NixOS host in the current plan. B 5. Let `burrow-forgejo-runner-bootstrap.service` register the self-hosted Forgejo runner and seed Git identity as `agent `. 6. Run `Scripts/provision-forgejo-nsc.sh` locally to refresh `intake/forgejo_nsc_token.txt`, `intake/forgejo_nsc_dispatcher.yaml`, and `intake/forgejo_nsc_autoscaler.yaml`. 7. Run `Scripts/seal-forgejo-nsc-secrets.sh` to encrypt those runtime inputs into the agenix secrets used by `burrow-forge`. -8. Ensure `/var/lib/agenix/agenix.key` exists on the host, encrypt `secrets/infra/authentik.env.age`, `secrets/infra/authentik-google-client-id.age`, `secrets/infra/authentik-google-client-secret.age`, `secrets/infra/forgejo-oidc-client-secret.age`, `secrets/infra/headscale-oidc-client-secret.age`, `secrets/infra/forgejo-nsc-token.age`, `secrets/infra/forgejo-nsc-dispatcher-config.age`, and `secrets/infra/forgejo-nsc-autoscaler-config.age`, and let agenix materialize them under `/run/agenix/`. -9. Use `Scripts/cloudflare-upsert-a-record.sh` to point `git.burrow.net`, `burrow.net`, `auth.burrow.net`, `ts.burrow.net`, and `nsc-autoscaler.burrow.net` at the host with Cloudflare proxying disabled for ACME. +8. Ensure `/var/lib/agenix/agenix.key` exists on the host, encrypt `secrets/infra/authentik.env.age`, `secrets/infra/authentik-google-client-id.age`, `secrets/infra/authentik-google-client-secret.age`, `secrets/infra/forgejo-oidc-client-secret.age`, `secrets/infra/grafana-admin-password.age`, `secrets/infra/grafana-oidc-client-secret.age`, `secrets/infra/headscale-oidc-client-secret.age`, `secrets/infra/forgejo-nsc-token.age`, `secrets/infra/forgejo-nsc-dispatcher-config.age`, and `secrets/infra/forgejo-nsc-autoscaler-config.age`, and let agenix materialize them under `/run/agenix/`. +9. Use `Scripts/cloudflare-upsert-a-record.sh` to point `git.burrow.net`, `burrow.net`, `auth.burrow.net`, `ts.burrow.net`, `graphs.burrow.net`, and `nsc-autoscaler.burrow.net` at the host with Cloudflare proxying disabled for ACME. 10. Use `Scripts/forge-deploy.sh --allow-dirty` for subsequent remote `nixos-rebuild` runs from the live workspace. -11. Configure Forward Email custom S3 backups for `burrow.net` and `burrow.rs` out-of-band with `Tools/forwardemail-custom-s3.sh`. +11. Rotate `secrets/infra/grafana-oidc-client-secret.age` from its pending placeholder, deploy, and let `burrow-authentik-grafana-oidc.service` reconcile the Authentik client. +12. Validate Grafana API-managed dashboards with `Scripts/grafana-tofu.sh init -backend=false` and `Scripts/grafana-tofu.sh validate`; use `.forgejo/workflows/infra-opentofu.yml` for planned dashboard apply/import. +13. Configure Forward Email custom S3 backups for `burrow.net` and `burrow.rs` out-of-band with `Tools/forwardemail-custom-s3.sh`. +14. Keep `services.burrow.openbao` and `services.burrow.jitsi` disabled until their DNS, secret, rollback, and live-service checks in BEP-0010 are complete. ## Current Constraints - `burrow-forge` is live on NixOS in `hel1` at `89.167.47.21`. - `services.forgejo-nsc` now expects agenix-backed runtime inputs at `/run/agenix/burrowForgejoNscToken`, `/run/agenix/burrowForgejoNscDispatcherConfig`, and `/run/agenix/burrowForgejoNscAutoscalerConfig`. -- Authentik and Headscale secrets now live in tracked agenix blobs under `secrets/infra/` and decrypt to `/run/agenix/` on the forge host. +- Authentik, Grafana, and Headscale secrets now live in tracked agenix blobs under `secrets/infra/` and decrypt to `/run/agenix/` on the forge host. - Public Burrow forge cutover completed on March 15, 2026: - - `burrow.net`, `git.burrow.net`, and `nsc-autoscaler.burrow.net` now publish public `A` records to `89.167.47.21` + - `burrow.net`, `git.burrow.net`, and `nsc-autoscaler.burrow.net` now publish public `A` records to `89.167.47.21`; `graphs.burrow.net` should be pointed there before Grafana public cutover - HTTP redirects to HTTPS on all three names - `https://burrow.net` returns the root forge landing response - `https://git.burrow.net` returns the live Forgejo front door diff --git a/nixos/hosts/burrow-forge/default.nix b/nixos/hosts/burrow-forge/default.nix index c4fc92e..a4f71f8 100644 --- a/nixos/hosts/burrow-forge/default.nix +++ b/nixos/hosts/burrow-forge/default.nix @@ -50,6 +50,29 @@ let forgeAuthorizedKeys = map (username: builtins.readFile identities.${username}.sshPublicKeyPath) (builtins.attrNames (lib.filterAttrs (_: identity: identity.forgeAuthorized or false) identities)); + forgejoNscMaterializeTokenCache = '' + install -d -m 700 -o forgejo-nsc -g forgejo-nsc /var/lib/forgejo-nsc/.config/ns + ${pkgs.python3}/bin/python3 - <<'PY' +import json +from pathlib import Path + +raw = Path("/var/lib/forgejo-nsc/nsc.token").read_text(encoding="utf-8").strip() +if not raw: + raise SystemExit("empty Namespace token") +if raw.startswith("{"): + data = json.loads(raw) + if "bearer_token" not in data and "session_token" not in data: + raise SystemExit("Namespace token JSON must contain bearer_token or session_token") +else: + data = {"session_token": raw} +Path("/var/lib/forgejo-nsc/.config/ns/token.json").write_text( + json.dumps(data) + "\n", + encoding="utf-8", +) +PY + chown forgejo-nsc:forgejo-nsc /var/lib/forgejo-nsc/.config/ns/token.json + chmod 600 /var/lib/forgejo-nsc/.config/ns/token.json + ''; in { @@ -60,8 +83,13 @@ in self.nixosModules.burrow-forge-runner self.nixosModules.burrow-forgejo-nsc self.nixosModules.burrow-authentik + self.nixosModules.burrow-garage self.nixosModules.burrow-headscale + self.nixosModules.burrow-nix-cache + self.nixosModules.burrow-observability self.nixosModules.burrow-zulip + self.nixosModules.burrow-openbao + self.nixosModules.burrow-jitsi ]; system.stateVersion = "24.11"; @@ -108,6 +136,24 @@ in group = "forgejo"; mode = "0440"; }; + age.secrets.burrowGrafanaAdminPassword = { + file = ../../../secrets/infra/grafana-admin-password.age; + owner = "grafana"; + group = "grafana"; + mode = "0400"; + }; + age.secrets.burrowGrafanaSecretKey = { + file = ../../../secrets/infra/grafana-secret-key.age; + owner = "grafana"; + group = "grafana"; + mode = "0400"; + }; + age.secrets.burrowGrafanaOidcClientSecret = { + file = ../../../secrets/infra/grafana-oidc-client-secret.age; + owner = "grafana"; + group = "grafana"; + mode = "0400"; + }; age.secrets.burrowTailscaleOidcClientSecret = { file = ../../../secrets/infra/tailscale-oidc-client-secret.age; owner = "root"; @@ -138,6 +184,12 @@ in group = "root"; mode = "0400"; }; + age.secrets.burrowAuthentikGoogleWifClientSecret = { + file = ../../../secrets/infra/authentik-google-wif-client-secret.age; + owner = "root"; + group = "root"; + mode = "0400"; + }; age.secrets.burrowAuthentikUiTestPassword = { file = ../../../secrets/infra/authentik-ui-test-password.age; owner = "root"; @@ -192,8 +244,8 @@ in }; networking.extraHosts = '' - 127.0.0.1 burrow.net git.burrow.net auth.burrow.net ts.burrow.net chat.burrow.net nsc-autoscaler.burrow.net - ::1 burrow.net git.burrow.net auth.burrow.net ts.burrow.net chat.burrow.net nsc-autoscaler.burrow.net + 127.0.0.1 burrow.net git.burrow.net auth.burrow.net ts.burrow.net chat.burrow.net graphs.burrow.net vault.burrow.net meet.burrow.net inbox.burrow.net nsc-autoscaler.burrow.net + ::1 burrow.net git.burrow.net auth.burrow.net ts.burrow.net chat.burrow.net graphs.burrow.net vault.burrow.net meet.burrow.net inbox.burrow.net nsc-autoscaler.burrow.net ''; services.burrow.forge = { @@ -221,29 +273,39 @@ in services.forgejo-nsc = { enable = true; + nscPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.nsc; nscTokenFile = config.age.secrets.burrowForgejoNscToken.path; dispatcher = { + package = self.packages.${pkgs.stdenv.hostPlatform.system}.forgejo-nsc-dispatcher; configFile = config.age.secrets.burrowForgejoNscDispatcherConfig.path; }; autoscaler = { enable = true; + package = self.packages.${pkgs.stdenv.hostPlatform.system}.forgejo-nsc-autoscaler; configFile = config.age.secrets.burrowForgejoNscAutoscalerConfig.path; }; }; + systemd.services.forgejo-nsc-dispatcher.preStart = lib.mkAfter forgejoNscMaterializeTokenCache; + systemd.services.forgejo-nsc-autoscaler.preStart = lib.mkAfter forgejoNscMaterializeTokenCache; + services.burrow.authentik = { enable = true; envFile = config.age.secrets.burrowAuthentikEnv.path; forgejoClientSecretFile = config.age.secrets.burrowForgejoOidcClientSecret.path; + grafanaClientSecretFile = config.age.secrets.burrowGrafanaOidcClientSecret.path; + grafanaAccessGroupName = contributors.groups.users; headscaleClientSecretFile = config.age.secrets.burrowHeadscaleOidcClientSecret.path; tailscaleClientSecretFile = config.age.secrets.burrowTailscaleOidcClientSecret.path; defaultExternalApplicationSlug = "tailscale"; googleClientIDFile = config.age.secrets.burrowAuthentikGoogleClientId.path; googleClientSecretFile = config.age.secrets.burrowAuthentikGoogleClientSecret.path; googleAccountMapFile = config.age.secrets.burrowAuthentikGoogleAccountMap.path; + googleWifClientSecretFile = config.age.secrets.burrowAuthentikGoogleWifClientSecret.path; googleLoginMode = "redirect"; userGroupName = contributors.groups.users; adminGroupName = contributors.groups.admins; + extraGroupNames = [ contributors.groups.automation ]; tailscaleAccessGroupName = contributors.groups.users; bootstrapUsers = bootstrapUsers; linearAcsUrl = "https://api.linear.app/auth/sso/d0ca13dc-ac41-4824-8aab-e0ca352fc3de/acs"; @@ -258,12 +320,91 @@ in zulipAccessGroupName = contributors.groups.users; }; + services.grafana = { + enable = true; + settings = { + server = { + domain = "graphs.burrow.net"; + root_url = "https://graphs.burrow.net/"; + http_addr = "127.0.0.1"; + http_port = 3001; + enforce_domain = true; + }; + analytics = { + reporting_enabled = false; + check_for_updates = false; + check_for_plugin_updates = false; + }; + security = { + admin_user = "admin"; + admin_password = "$__file{${config.age.secrets.burrowGrafanaAdminPassword.path}}"; + secret_key = "$__file{${config.age.secrets.burrowGrafanaSecretKey.path}}"; + cookie_secure = true; + cookie_samesite = "strict"; + disable_gravatar = true; + }; + users = { + allow_sign_up = false; + auto_assign_org = true; + auto_assign_org_role = "Viewer"; + }; + auth = { + disable_login_form = false; + oauth_auto_login = false; + }; + "auth.generic_oauth" = { + enabled = true; + name = "burrow.net"; + allow_sign_up = true; + auto_login = true; + client_id = "graphs.burrow.net"; + client_secret = "$__file{${config.age.secrets.burrowGrafanaOidcClientSecret.path}}"; + scopes = "openid profile email groups"; + auth_url = "https://auth.burrow.net/application/o/grafana/authorize/"; + token_url = "https://auth.burrow.net/application/o/grafana/token/"; + api_url = "https://auth.burrow.net/application/o/grafana/userinfo/"; + role_attribute_path = "contains(groups[*], 'burrow-admins') && 'Admin' || 'Viewer'"; + }; + }; + }; + + services.caddy.virtualHosts."graphs.burrow.net".extraConfig = '' + encode gzip zstd + reverse_proxy 127.0.0.1:3001 + ''; + + services.caddy.virtualHosts."releases.burrow.net".extraConfig = '' + encode gzip zstd + rewrite * /burrow-net-releases{uri} + reverse_proxy https://storage.googleapis.com { + header_up Host storage.googleapis.com + } + ''; + + services.caddy.virtualHosts."packages.burrow.net".extraConfig = '' + encode gzip zstd + rewrite * /burrow-net-packages{uri} + reverse_proxy https://storage.googleapis.com { + header_up Host storage.googleapis.com + } + ''; + services.burrow.headscale = { enable = true; oidcClientSecretFile = config.age.secrets.burrowHeadscaleOidcClientSecret.path; bootstrapUsers = headscaleBootstrapUsers; }; + services.burrow.garage = { + enable = true; + enableApiProxy = true; + enableWebProxy = true; + }; + + services.burrow.nixCache.enable = true; + + services.burrow.observability.enable = true; + services.burrow.zulip = { enable = true; administratorEmail = identities.contact.canonicalEmail; diff --git a/nixos/modules/burrow-authentik.nix b/nixos/modules/burrow-authentik.nix index 977b641..a96ece8 100644 --- a/nixos/modules/burrow-authentik.nix +++ b/nixos/modules/burrow-authentik.nix @@ -10,6 +10,8 @@ let dataVolume = "burrow-authentik-data:/data"; directorySyncScript = ../../Scripts/authentik-sync-burrow-directory.sh; forgejoOidcSyncScript = ../../Scripts/authentik-sync-forgejo-oidc.sh; + grafanaOidcSyncScript = ../../Scripts/authentik-sync-grafana-oidc.sh; + googleWifOidcSyncScript = ../../Scripts/authentik-sync-google-wif-oidc.sh; tailscaleOidcSyncScript = ../../Scripts/authentik-sync-tailscale-oidc.sh; onePasswordOidcSyncScript = ../../Scripts/authentik-sync-1password-oidc.sh; zulipSamlSyncScript = ../../Scripts/authentik-sync-zulip-saml.sh; @@ -136,6 +138,60 @@ in description = "Authentik application slug for Forgejo."; }; + grafanaDomain = lib.mkOption { + type = lib.types.str; + default = "graphs.burrow.net"; + description = "Grafana public domain used for the bundled OIDC client."; + }; + + grafanaProviderSlug = lib.mkOption { + type = lib.types.str; + default = "grafana"; + description = "Authentik application slug for Grafana."; + }; + + grafanaClientId = lib.mkOption { + type = lib.types.str; + default = "graphs.burrow.net"; + description = "Client ID Authentik should present to Grafana."; + }; + + grafanaClientSecretFile = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = null; + description = "Host-local file containing the Authentik Grafana OIDC client secret."; + }; + + grafanaAccessGroupName = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = null; + description = "Authentik group allowed to launch Grafana."; + }; + + googleWifProviderSlug = lib.mkOption { + type = lib.types.str; + default = "google-cloud"; + description = "Authentik application slug for Google Cloud Workload Identity Federation."; + }; + + googleWifClientId = lib.mkOption { + type = lib.types.str; + default = "google-wif.burrow.net"; + description = "Client ID Authentik should present to Google Cloud WIF consumers."; + }; + + googleWifClientSecretFile = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = null; + description = "Host-local file containing the Authentik Google WIF client-credentials secret."; + }; + + googleWifAccessGroupName = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = null; + description = "Optional Authentik group allowed to launch the Google WIF application. Leave null for client-credentials token exchange."; + }; + tailscaleProviderSlug = lib.mkOption { type = lib.types.str; default = "tailscale"; @@ -388,6 +444,12 @@ in description = "Authentik group granted Burrow administrator access."; }; + extraGroupNames = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + description = "Additional Authentik groups that should exist even if no bootstrap user currently belongs to them."; + }; + bootstrapUsers = lib.mkOption { type = with lib.types; listOf (submodule { options = { @@ -490,6 +552,13 @@ in fi ''} + ${lib.optionalString (cfg.googleWifClientSecretFile != null) '' + if [ ! -s ${lib.escapeShellArg cfg.googleWifClientSecretFile} ]; then + echo "Google WIF client secret missing: ${cfg.googleWifClientSecretFile}" >&2 + exit 1 + fi + ''} + install -d -m 0750 -o root -g root ${runtimeDir} ${blueprintDir} install -m 0644 -o root -g root ${authentikBlueprint} ${blueprintFile} @@ -517,6 +586,7 @@ AUTHENTIK_BOOTSTRAP_PASSWORD=$AUTHENTIK_BOOTSTRAP_PASSWORD AUTHENTIK_BOOTSTRAP_TOKEN=$AUTHENTIK_BOOTSTRAP_TOKEN AUTHENTIK_BURROW_TS_CLIENT_SECRET=$(read_secret ${lib.escapeShellArg cfg.headscaleClientSecretFile}) ${lib.optionalString (cfg.forgejoClientSecretFile != null) "AUTHENTIK_BURROW_FORGEJO_CLIENT_SECRET=$(read_secret ${lib.escapeShellArg cfg.forgejoClientSecretFile})"} +${lib.optionalString (cfg.googleWifClientSecretFile != null) "AUTHENTIK_BURROW_GOOGLE_WIF_CLIENT_SECRET=$(read_secret ${lib.escapeShellArg cfg.googleWifClientSecretFile})"} EOF chown root:root ${envFile} chmod 0600 ${envFile} @@ -667,7 +737,7 @@ EOF ''; }; - systemd.services.burrow-authentik-directory = lib.mkIf (cfg.bootstrapUsers != [ ]) { + systemd.services.burrow-authentik-directory = lib.mkIf (cfg.bootstrapUsers != [ ] || cfg.extraGroupNames != [ ]) { description = "Reconcile Burrow Authentik users and groups"; after = [ @@ -706,6 +776,7 @@ EOF export AUTHENTIK_URL=https://${cfg.domain} export AUTHENTIK_BURROW_USERS_GROUP=${lib.escapeShellArg cfg.userGroupName} export AUTHENTIK_BURROW_ADMINS_GROUP=${lib.escapeShellArg cfg.adminGroupName} + export AUTHENTIK_BURROW_EXTRA_GROUPS_JSON='${builtins.toJSON cfg.extraGroupNames}' export AUTHENTIK_FORGEJO_APPLICATION_SLUG=${lib.escapeShellArg cfg.forgejoProviderSlug} export AUTHENTIK_BURROW_DIRECTORY_JSON='${builtins.toJSON (map (user: { inherit (user) username name email isAdmin passwordFile; @@ -810,12 +881,112 @@ EOF export AUTHENTIK_FORGEJO_CLIENT_ID=${lib.escapeShellArg cfg.forgejoClientId} export AUTHENTIK_FORGEJO_CLIENT_SECRET="$(tr -d '\r\n' < ${lib.escapeShellArg cfg.forgejoClientSecretFile})" export AUTHENTIK_FORGEJO_LAUNCH_URL=https://${cfg.forgejoDomain}/ - export AUTHENTIK_FORGEJO_REDIRECT_URIS_JSON='["https://${cfg.forgejoDomain}/user/oauth2/burrow.net/callback","https://${cfg.forgejoDomain}/user/oauth2/authentik/callback","https://${cfg.forgejoDomain}/user/oauth2/GitHub/callback"]' + export AUTHENTIK_FORGEJO_REDIRECT_URIS_JSON='["https://${cfg.forgejoDomain}/user/oauth2/burrow.net/callback","https://${cfg.forgejoDomain}/user/oauth2/authentik/callback"]' ${pkgs.bash}/bin/bash ${forgejoOidcSyncScript} ''; }; + systemd.services.burrow-authentik-grafana-oidc = lib.mkIf (cfg.grafanaClientSecretFile != null) { + description = "Reconcile the Burrow Authentik Grafana OIDC application"; + after = [ + "burrow-authentik-ready.service" + "network-online.target" + ]; + wants = [ + "burrow-authentik-ready.service" + "network-online.target" + ]; + wantedBy = [ "multi-user.target" ]; + restartTriggers = [ + grafanaOidcSyncScript + cfg.envFile + cfg.grafanaClientSecretFile + ]; + path = [ + pkgs.bash + pkgs.coreutils + pkgs.curl + pkgs.jq + ]; + serviceConfig = { + Type = "oneshot"; + User = "root"; + Group = "root"; + }; + script = '' + set -euo pipefail + set -a + source ${lib.escapeShellArg cfg.envFile} + set +a + + export AUTHENTIK_URL=https://${cfg.domain} + export AUTHENTIK_GRAFANA_APPLICATION_SLUG=${lib.escapeShellArg cfg.grafanaProviderSlug} + export AUTHENTIK_GRAFANA_APPLICATION_NAME="Burrow Grafana" + export AUTHENTIK_GRAFANA_PROVIDER_NAME="Burrow Grafana" + export AUTHENTIK_GRAFANA_TEMPLATE_SLUG=${lib.escapeShellArg cfg.headscaleProviderSlug} + export AUTHENTIK_GRAFANA_CLIENT_ID=${lib.escapeShellArg cfg.grafanaClientId} + export AUTHENTIK_GRAFANA_CLIENT_SECRET="$(tr -d '\r\n' < ${lib.escapeShellArg cfg.grafanaClientSecretFile})" + export AUTHENTIK_GRAFANA_LAUNCH_URL=https://${cfg.grafanaDomain}/ + export AUTHENTIK_GRAFANA_REDIRECT_URIS_JSON='["https://${cfg.grafanaDomain}/login/generic_oauth"]' + ${lib.optionalString (cfg.grafanaAccessGroupName != null) '' + export AUTHENTIK_GRAFANA_ACCESS_GROUP=${lib.escapeShellArg cfg.grafanaAccessGroupName} + ''} + + ${pkgs.bash}/bin/bash ${grafanaOidcSyncScript} + ''; + }; + + systemd.services.burrow-authentik-google-wif-oidc = lib.mkIf (cfg.googleWifClientSecretFile != null) { + description = "Reconcile the Burrow Authentik Google WIF OIDC application"; + after = [ + "burrow-authentik-ready.service" + "network-online.target" + ]; + wants = [ + "burrow-authentik-ready.service" + "network-online.target" + ]; + wantedBy = [ "multi-user.target" ]; + restartTriggers = [ + googleWifOidcSyncScript + cfg.envFile + cfg.googleWifClientSecretFile + ]; + path = [ + pkgs.bash + pkgs.coreutils + pkgs.curl + pkgs.jq + ]; + serviceConfig = { + Type = "oneshot"; + User = "root"; + Group = "root"; + }; + script = '' + set -euo pipefail + set -a + source ${lib.escapeShellArg cfg.envFile} + set +a + + export AUTHENTIK_URL=https://${cfg.domain} + export AUTHENTIK_GOOGLE_WIF_APPLICATION_SLUG=${lib.escapeShellArg cfg.googleWifProviderSlug} + export AUTHENTIK_GOOGLE_WIF_APPLICATION_NAME="Google Cloud WIF" + export AUTHENTIK_GOOGLE_WIF_PROVIDER_NAME="Google Cloud WIF" + export AUTHENTIK_GOOGLE_WIF_TEMPLATE_SLUG=${lib.escapeShellArg cfg.headscaleProviderSlug} + export AUTHENTIK_GOOGLE_WIF_CLIENT_ID=${lib.escapeShellArg cfg.googleWifClientId} + export AUTHENTIK_GOOGLE_WIF_CLIENT_SECRET="$(tr -d '\r\n' < ${lib.escapeShellArg cfg.googleWifClientSecretFile})" + export AUTHENTIK_GOOGLE_WIF_LAUNCH_URL=https://console.cloud.google.com/ + export AUTHENTIK_GOOGLE_WIF_REDIRECT_URIS_JSON='[]' + ${lib.optionalString (cfg.googleWifAccessGroupName != null) '' + export AUTHENTIK_GOOGLE_WIF_ACCESS_GROUP=${lib.escapeShellArg cfg.googleWifAccessGroupName} + ''} + + ${pkgs.bash}/bin/bash ${googleWifOidcSyncScript} + ''; + }; + systemd.services.burrow-authentik-tailscale-oidc = lib.mkIf (cfg.tailscaleClientSecretFile != null) { description = "Reconcile the Burrow Authentik Tailscale OIDC application"; after = [ diff --git a/nixos/modules/burrow-forge-runner.nix b/nixos/modules/burrow-forge-runner.nix index 034fb38..b5e9d72 100644 --- a/nixos/modules/burrow-forge-runner.nix +++ b/nixos/modules/burrow-forge-runner.nix @@ -7,6 +7,7 @@ let runnerFile = "${stateDir}/.runner"; registrationFingerprintFile = "${stateDir}/.runner-registration-fingerprint"; configFile = "${stateDir}/runner.yaml"; + ageIdentityFile = "${stateDir}/age_keystore"; labelsCsv = lib.concatStringsSep "," (map (label: "${label}:host") cfg.labels); registrationFingerprint = builtins.hashString "sha256" "${cfg.instanceUrl}\n${cfg.name}\n${labelsCsv}"; sshPrivateKeyFile = cfg.sshPrivateKeyFile or ""; @@ -164,6 +165,9 @@ EOF install -m 0600 -o ${cfg.user} -g ${cfg.group} \ ${lib.escapeShellArg sshPrivateKeyFile} \ ${stateDir}/.ssh/id_ed25519 + install -m 0600 -o ${cfg.user} -g ${cfg.group} \ + ${lib.escapeShellArg sshPrivateKeyFile} \ + ${ageIdentityFile} cat > ${stateDir}/.ssh/config <&2 + exit 1 + fi + + ${pkgs.postgresql}/bin/psql -v ON_ERROR_STOP=1 \ + -h /run/postgresql -U forgejo forgejo <<'SQL' + DO $$ + DECLARE + repo_ids BIGINT[]; + BEGIN + SELECT array_agg(r.id) + INTO repo_ids + FROM repository r + JOIN "user" u ON u.id = r.owner_id + WHERE u.lower_name = lower(${sqlLiteral cfg.homeOwner}) + AND r.lower_name = lower(${sqlLiteral cfg.homeRepo}); + + IF repo_ids IS NULL THEN + RETURN; + END IF; + + IF EXISTS ( + SELECT 1 + FROM information_schema.columns + WHERE table_schema = 'public' + AND table_name = 'repository' + AND column_name = 'is_mirror' + ) THEN + UPDATE repository SET is_mirror = FALSE WHERE id = ANY(repo_ids); + END IF; + + IF to_regclass('public.mirror') IS NOT NULL THEN + DELETE FROM mirror WHERE repo_id = ANY(repo_ids); + END IF; + + IF to_regclass('public.push_mirror') IS NOT NULL THEN + DELETE FROM push_mirror WHERE repo_id = ANY(repo_ids); + END IF; + END $$; + SQL + ''; + }; + systemd.services.burrow-forgejo-oidc-bootstrap = lib.mkIf (cfg.oidcClientSecretFile != null) { description = "Seed the Burrow Forgejo OIDC login source"; after = [ diff --git a/nixos/modules/burrow-garage.nix b/nixos/modules/burrow-garage.nix new file mode 100644 index 0000000..993d5ba --- /dev/null +++ b/nixos/modules/burrow-garage.nix @@ -0,0 +1,284 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.services.burrow.garage; +in +{ + options.services.burrow.garage = { + enable = lib.mkEnableOption "Burrow Garage S3-compatible object storage"; + + environmentFile = lib.mkOption { + type = lib.types.path; + default = "/var/lib/burrow/garage/env"; + description = "Host-local environment file containing Garage and S3 bootstrap secrets."; + }; + + region = lib.mkOption { + type = lib.types.str; + default = "garage"; + description = "S3 region name advertised by Garage."; + }; + + apiListenAddress = lib.mkOption { + type = lib.types.str; + default = "127.0.0.1"; + description = "Address used by the Garage S3 API listener."; + }; + + apiPort = lib.mkOption { + type = lib.types.port; + default = 3900; + description = "Port used by the Garage S3 API listener."; + }; + + webListenAddress = lib.mkOption { + type = lib.types.str; + default = "127.0.0.1"; + description = "Address used by the Garage static-web listener."; + }; + + webPort = lib.mkOption { + type = lib.types.port; + default = 3902; + description = "Port used by the Garage static-web listener."; + }; + + adminListenAddress = lib.mkOption { + type = lib.types.str; + default = "127.0.0.1"; + description = "Address used by the Garage admin listener."; + }; + + adminPort = lib.mkOption { + type = lib.types.port; + default = 3903; + description = "Port used by the Garage admin listener."; + }; + + zone = lib.mkOption { + type = lib.types.str; + default = "burrow-forge"; + description = "Garage layout zone assigned to the forge host."; + }; + + layoutCapacity = lib.mkOption { + type = lib.types.str; + default = "100GB"; + description = "Initial Garage layout capacity assigned to the forge host."; + }; + + s3RootDomain = lib.mkOption { + type = lib.types.str; + default = "s3.burrow.net"; + description = "Wildcard root domain used for bucket-style S3 API requests."; + }; + + webRootDomain = lib.mkOption { + type = lib.types.str; + default = "web.burrow.net"; + description = "Wildcard root domain used for bucket static website requests."; + }; + + apiDomain = lib.mkOption { + type = lib.types.str; + default = "objects.burrow.net"; + description = "Public S3 API reverse-proxy domain."; + }; + + enableApiProxy = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Expose the Garage S3 API through Caddy."; + }; + + enableWebProxy = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Expose the Garage static-web listener through Caddy wildcard routes."; + }; + + atticBucket = lib.mkOption { + type = lib.types.str; + default = "attic"; + description = "Garage bucket used by the Burrow Nix cache."; + }; + + releaseBucket = lib.mkOption { + type = lib.types.str; + default = "burrow-releases"; + description = "Garage bucket used for release artifacts."; + }; + + packageBucket = lib.mkOption { + type = lib.types.str; + default = "burrow-packages"; + description = "Garage bucket used for signed package repositories."; + }; + }; + + config = lib.mkIf cfg.enable { + services.garage = { + enable = true; + package = pkgs.garage; + environmentFile = cfg.environmentFile; + settings = { + metadata_dir = "/var/lib/garage/meta"; + data_dir = "/var/lib/garage/data"; + rpc_bind_addr = "127.0.0.1:3901"; + rpc_public_addr = "127.0.0.1:3901"; + replication_factor = 1; + s3_api = { + s3_region = cfg.region; + api_bind_addr = "${cfg.apiListenAddress}:${toString cfg.apiPort}"; + root_domain = ".${cfg.s3RootDomain}"; + }; + s3_web = { + bind_addr = "${cfg.webListenAddress}:${toString cfg.webPort}"; + root_domain = ".${cfg.webRootDomain}"; + index = "index.html"; + }; + admin.api_bind_addr = "${cfg.adminListenAddress}:${toString cfg.adminPort}"; + }; + }; + + systemd.services.burrow-garage-env = { + description = "Create Burrow Garage bootstrap environment"; + before = [ "garage.service" ]; + wantedBy = [ "garage.service" ]; + requiredBy = [ "garage.service" ]; + path = [ + pkgs.coreutils + pkgs.gnugrep + pkgs.openssl + ]; + serviceConfig = { + Type = "oneshot"; + User = "root"; + Group = "root"; + RemainAfterExit = true; + }; + script = '' + set -euo pipefail + + install -d -m 0700 "$(dirname ${lib.escapeShellArg cfg.environmentFile})" + touch ${lib.escapeShellArg cfg.environmentFile} + chmod 0600 ${lib.escapeShellArg cfg.environmentFile} + chown root:root ${lib.escapeShellArg cfg.environmentFile} + + has_var() { + grep -q "^$1=" ${lib.escapeShellArg cfg.environmentFile} + } + + add_var() { + local name="$1" + local value="$2" + if ! has_var "$name"; then + printf '%s=%s\n' "$name" "$value" >> ${lib.escapeShellArg cfg.environmentFile} + fi + } + + add_var GARAGE_RPC_SECRET "$(${pkgs.openssl}/bin/openssl rand -hex 32)" + add_var GARAGE_ATTIC_ACCESS_KEY_ID "GK$(${pkgs.openssl}/bin/openssl rand -hex 12)" + add_var GARAGE_ATTIC_SECRET_ACCESS_KEY "$(${pkgs.openssl}/bin/openssl rand -hex 32)" + add_var GARAGE_RELEASE_ACCESS_KEY_ID "GK$(${pkgs.openssl}/bin/openssl rand -hex 12)" + add_var GARAGE_RELEASE_SECRET_ACCESS_KEY "$(${pkgs.openssl}/bin/openssl rand -hex 32)" + add_var GARAGE_PACKAGE_ACCESS_KEY_ID "GK$(${pkgs.openssl}/bin/openssl rand -hex 12)" + add_var GARAGE_PACKAGE_SECRET_ACCESS_KEY "$(${pkgs.openssl}/bin/openssl rand -hex 32)" + add_var GARAGE_BACKUP_ACCESS_KEY_ID "GK$(${pkgs.openssl}/bin/openssl rand -hex 12)" + add_var GARAGE_BACKUP_SECRET_ACCESS_KEY "$(${pkgs.openssl}/bin/openssl rand -hex 32)" + add_var ATTIC_SERVER_TOKEN_RS256_SECRET_BASE64 "$(${pkgs.openssl}/bin/openssl genrsa -traditional 4096 | ${pkgs.coreutils}/bin/base64 -w0)" + + . ${lib.escapeShellArg cfg.environmentFile} + add_var AWS_ACCESS_KEY_ID "$GARAGE_ATTIC_ACCESS_KEY_ID" + add_var AWS_SECRET_ACCESS_KEY "$GARAGE_ATTIC_SECRET_ACCESS_KEY" + ''; + }; + + systemd.services.burrow-garage-bootstrap = { + description = "Bootstrap Burrow Garage layout, keys, and buckets"; + after = [ "garage.service" ]; + requires = [ "garage.service" ]; + wantedBy = [ "multi-user.target" ]; + path = [ + config.services.garage.package + pkgs.coreutils + pkgs.gawk + pkgs.gnugrep + ]; + serviceConfig = { + Type = "oneshot"; + User = "root"; + Group = "root"; + }; + script = '' + set -euo pipefail + set -a + . ${lib.escapeShellArg cfg.environmentFile} + set +a + + for _ in $(seq 1 60); do + if garage status >/dev/null 2>&1; then + break + fi + sleep 1 + done + + node_id="$(garage status | tail -n1 | awk '{ print $1 }')" + if [ -n "$node_id" ]; then + garage layout assign -c ${lib.escapeShellArg cfg.layoutCapacity} -z ${lib.escapeShellArg cfg.zone} "$node_id" >/dev/null 2>&1 || true + garage layout apply --version 1 >/dev/null 2>&1 || true + fi + + ensure_key() { + local key_id="$1" + local secret="$2" + if ! garage key info "$key_id" >/dev/null 2>&1; then + garage key import "$key_id" "$secret" --yes >/dev/null + fi + } + + ensure_bucket() { + local bucket="$1" + local key_id="$2" + if ! garage bucket info "$bucket" >/dev/null 2>&1; then + garage bucket create "$bucket" >/dev/null + fi + garage bucket allow --read --write --owner "$bucket" --key "$key_id" >/dev/null + } + + ensure_bucket_reader() { + local bucket="$1" + local key_id="$2" + garage bucket allow --read "$bucket" --key "$key_id" >/dev/null + } + + ensure_key "$GARAGE_ATTIC_ACCESS_KEY_ID" "$GARAGE_ATTIC_SECRET_ACCESS_KEY" + ensure_key "$GARAGE_RELEASE_ACCESS_KEY_ID" "$GARAGE_RELEASE_SECRET_ACCESS_KEY" + ensure_key "$GARAGE_PACKAGE_ACCESS_KEY_ID" "$GARAGE_PACKAGE_SECRET_ACCESS_KEY" + ensure_key "$GARAGE_BACKUP_ACCESS_KEY_ID" "$GARAGE_BACKUP_SECRET_ACCESS_KEY" + + ensure_bucket ${lib.escapeShellArg cfg.atticBucket} "$GARAGE_ATTIC_ACCESS_KEY_ID" + ensure_bucket ${lib.escapeShellArg cfg.releaseBucket} "$GARAGE_RELEASE_ACCESS_KEY_ID" + ensure_bucket ${lib.escapeShellArg cfg.packageBucket} "$GARAGE_PACKAGE_ACCESS_KEY_ID" + ensure_bucket_reader ${lib.escapeShellArg cfg.atticBucket} "$GARAGE_BACKUP_ACCESS_KEY_ID" + ensure_bucket_reader ${lib.escapeShellArg cfg.releaseBucket} "$GARAGE_BACKUP_ACCESS_KEY_ID" + ensure_bucket_reader ${lib.escapeShellArg cfg.packageBucket} "$GARAGE_BACKUP_ACCESS_KEY_ID" + ''; + }; + + services.caddy.virtualHosts = lib.mkMerge [ + (lib.mkIf cfg.enableApiProxy { + "${cfg.apiDomain}".extraConfig = '' + encode gzip zstd + reverse_proxy ${cfg.apiListenAddress}:${toString cfg.apiPort} + ''; + }) + (lib.mkIf cfg.enableWebProxy { + "*.${cfg.webRootDomain}".extraConfig = '' + encode gzip zstd + reverse_proxy ${cfg.webListenAddress}:${toString cfg.webPort} + ''; + }) + ]; + }; +} diff --git a/nixos/modules/burrow-headscale.nix b/nixos/modules/burrow-headscale.nix index ad5ec68..b79fe48 100644 --- a/nixos/modules/burrow-headscale.nix +++ b/nixos/modules/burrow-headscale.nix @@ -26,6 +26,24 @@ in description = "Local Headscale listen port."; }; + enableMetrics = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Expose Headscale Prometheus metrics on the local host."; + }; + + metricsListenAddress = lib.mkOption { + type = lib.types.str; + default = "127.0.0.1"; + description = "Address used for the Headscale metrics listener."; + }; + + metricsPort = lib.mkOption { + type = lib.types.port; + default = 9098; + description = "Port used for the Headscale metrics listener."; + }; + oidcIssuer = lib.mkOption { type = lib.types.str; default = "https://${config.services.burrow.authentik.domain}/application/o/${config.services.burrow.authentik.headscaleProviderSlug}/"; @@ -154,6 +172,8 @@ in method = "S256"; }; }; + } // lib.optionalAttrs cfg.enableMetrics { + metrics_listen_addr = "${cfg.metricsListenAddress}:${toString cfg.metricsPort}"; }; }; diff --git a/nixos/modules/burrow-jitsi.nix b/nixos/modules/burrow-jitsi.nix new file mode 100644 index 0000000..6041632 --- /dev/null +++ b/nixos/modules/burrow-jitsi.nix @@ -0,0 +1,45 @@ +{ config, lib, ... }: + +let + cfg = config.services.burrow.jitsi; +in +{ + options.services.burrow.jitsi = { + enable = lib.mkEnableOption "the Burrow Jitsi Meet deployment"; + + domain = lib.mkOption { + type = lib.types.str; + default = "meet.burrow.net"; + description = "Public Jitsi Meet domain."; + }; + + videobridgeUdpPort = lib.mkOption { + type = lib.types.port; + default = 10000; + description = "Public UDP port used by Jitsi Videobridge media traffic."; + }; + + enableHttpProxy = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Expose Jitsi through the repo-owned Caddy reverse proxy."; + }; + }; + + config = lib.mkIf cfg.enable { + services.jitsi-meet = { + enable = true; + hostName = cfg.domain; + nginx.enable = false; + }; + + services.jitsi-videobridge.openFirewall = true; + + networking.firewall.allowedUDPPorts = [ cfg.videobridgeUdpPort ]; + + services.caddy.virtualHosts."${cfg.domain}".extraConfig = lib.mkIf cfg.enableHttpProxy '' + encode gzip zstd + reverse_proxy 127.0.0.1:5280 + ''; + }; +} diff --git a/nixos/modules/burrow-nix-cache.nix b/nixos/modules/burrow-nix-cache.nix new file mode 100644 index 0000000..420d3b9 --- /dev/null +++ b/nixos/modules/burrow-nix-cache.nix @@ -0,0 +1,163 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.services.burrow.nixCache; + garageCfg = config.services.burrow.garage; +in +{ + options.services.burrow.nixCache = { + enable = lib.mkEnableOption "Burrow Nix binary cache"; + + domain = lib.mkOption { + type = lib.types.str; + default = "nix.burrow.net"; + description = "Public domain for the Burrow Nix binary cache."; + }; + + listenAddress = lib.mkOption { + type = lib.types.str; + default = "127.0.0.1"; + description = "Attic listen address."; + }; + + port = lib.mkOption { + type = lib.types.port; + default = 8080; + description = "Attic listen port."; + }; + + cacheName = lib.mkOption { + type = lib.types.str; + default = "burrow"; + description = "Default public Attic cache name."; + }; + + environmentFile = lib.mkOption { + type = lib.types.path; + default = garageCfg.environmentFile; + description = "Environment file containing Attic JWT and Garage S3 credentials."; + }; + + adminTokenFile = lib.mkOption { + type = lib.types.path; + default = "/var/lib/burrow/nix-cache/admin-token"; + description = "Host-local file containing the generated Attic admin token."; + }; + + ciPushTokenFile = lib.mkOption { + type = lib.types.path; + default = "/var/lib/burrow/nix-cache/ci-push-token"; + description = "Host-local file containing the generated Attic CI push token."; + }; + + ciPushTokenValidity = lib.mkOption { + type = lib.types.str; + default = "1y"; + description = "Validity duration for the generated Attic CI push token."; + }; + }; + + config = lib.mkIf cfg.enable { + assertions = [ + { + assertion = garageCfg.enable; + message = "services.burrow.nixCache requires services.burrow.garage.enable = true."; + } + ]; + + services.atticd = { + enable = true; + environmentFile = cfg.environmentFile; + settings = { + listen = "${cfg.listenAddress}:${toString cfg.port}"; + allowed-hosts = [ cfg.domain ]; + api-endpoint = "https://${cfg.domain}/"; + require-proof-of-possession = true; + storage = { + type = "s3"; + bucket = garageCfg.atticBucket; + region = garageCfg.region; + endpoint = "http://${garageCfg.apiListenAddress}:${toString garageCfg.apiPort}"; + }; + }; + }; + + environment.systemPackages = [ + pkgs.attic-client + ]; + + services.caddy.virtualHosts."${cfg.domain}".extraConfig = '' + encode gzip zstd + reverse_proxy ${cfg.listenAddress}:${toString cfg.port} + ''; + + systemd.services.atticd = { + after = [ "burrow-garage-bootstrap.service" ]; + wants = [ "burrow-garage-bootstrap.service" ]; + requires = [ "burrow-garage-bootstrap.service" ]; + }; + + systemd.services.burrow-nix-cache-bootstrap = { + description = "Bootstrap Burrow Nix binary cache"; + after = [ "atticd.service" ]; + requires = [ "atticd.service" ]; + wantedBy = [ "multi-user.target" ]; + path = [ + pkgs.attic-client + pkgs.attic-server + pkgs.coreutils + ]; + serviceConfig = { + Type = "oneshot"; + User = "root"; + Group = "root"; + }; + script = '' + set -euo pipefail + + install -d -m 0700 "$(dirname ${lib.escapeShellArg cfg.adminTokenFile})" + install -d -m 0700 "$(dirname ${lib.escapeShellArg cfg.ciPushTokenFile})" + + for _ in $(seq 1 60); do + if (: > /dev/tcp/${cfg.listenAddress}/${toString cfg.port}) >/dev/null 2>&1; then + break + fi + sleep 1 + done + + if [ ! -s ${lib.escapeShellArg cfg.adminTokenFile} ]; then + umask 077 + atticadm make-token \ + --sub burrow-nix-cache-bootstrap \ + --validity 10y \ + --create-cache '*' \ + --pull '*' \ + --push '*' \ + --delete '*' \ + --configure-cache '*' \ + --configure-cache-retention '*' \ + > ${lib.escapeShellArg cfg.adminTokenFile} + fi + + token="$(cat ${lib.escapeShellArg cfg.adminTokenFile})" + export HOME=/var/lib/burrow/nix-cache + install -d -m 0700 "$HOME" + + attic login local http://${cfg.listenAddress}:${toString cfg.port} "$token" --set-default + if ! attic cache info ${lib.escapeShellArg "local:${cfg.cacheName}"} >/dev/null 2>&1; then + attic cache create --public --priority 39 ${lib.escapeShellArg "local:${cfg.cacheName}"} + fi + + if [ ! -s ${lib.escapeShellArg cfg.ciPushTokenFile} ]; then + umask 077 + atticadm make-token \ + --sub burrow-ci-cache-publisher \ + --validity ${lib.escapeShellArg cfg.ciPushTokenValidity} \ + --pull ${lib.escapeShellArg cfg.cacheName} \ + --push ${lib.escapeShellArg cfg.cacheName} \ + > ${lib.escapeShellArg cfg.ciPushTokenFile} + fi + ''; + }; + }; +} diff --git a/nixos/modules/burrow-observability.nix b/nixos/modules/burrow-observability.nix new file mode 100644 index 0000000..090c2ee --- /dev/null +++ b/nixos/modules/burrow-observability.nix @@ -0,0 +1,302 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.services.burrow.observability; + otelCollectorPackage = + if builtins.hasAttr "opentelemetry-collector-contrib" pkgs then + pkgs."opentelemetry-collector-contrib" + else + pkgs.opentelemetry-collector; + garageCfg = config.services.burrow.garage; + headscaleCfg = config.services.burrow.headscale; + grafanaHttpPort = config.services.grafana.settings.server.http_port or 3000; + grafanaHttpAddress = config.services.grafana.settings.server.http_addr or "127.0.0.1"; + tailscaleExporterEnabled = cfg.tailscaleExporterEnvironmentFile != null; +in +{ + options.services.burrow.observability = { + enable = lib.mkEnableOption "Burrow Prometheus, OpenTelemetry, Jaeger, and Grafana wiring"; + + prometheusListenAddress = lib.mkOption { + type = lib.types.str; + default = "127.0.0.1"; + description = "Address used by the local Prometheus server."; + }; + + prometheusPort = lib.mkOption { + type = lib.types.port; + default = 9090; + description = "Port used by the local Prometheus server."; + }; + + otelGrpcEndpoint = lib.mkOption { + type = lib.types.str; + default = "127.0.0.1:4317"; + description = "Local OTLP gRPC endpoint accepted by the OpenTelemetry collector."; + }; + + otelHttpEndpoint = lib.mkOption { + type = lib.types.str; + default = "127.0.0.1:4318"; + description = "Local OTLP HTTP endpoint accepted by the OpenTelemetry collector."; + }; + + otelPrometheusEndpoint = lib.mkOption { + type = lib.types.str; + default = "127.0.0.1:9464"; + description = "Prometheus endpoint where the OpenTelemetry collector exports its own metrics."; + }; + + jaegerImage = lib.mkOption { + type = lib.types.str; + default = "docker.io/jaegertracing/all-in-one:1.57"; + description = "OCI image used for the local Jaeger all-in-one service."; + }; + + jaegerUiPort = lib.mkOption { + type = lib.types.port; + default = 16686; + description = "Local Jaeger UI and query API port."; + }; + + jaegerOtlpGrpcPort = lib.mkOption { + type = lib.types.port; + default = 14317; + description = "Local remapped OTLP gRPC port forwarded to Jaeger."; + }; + + jaegerOtlpHttpPort = lib.mkOption { + type = lib.types.port; + default = 14318; + description = "Local remapped OTLP HTTP port forwarded to Jaeger."; + }; + + jaegerAdminPort = lib.mkOption { + type = lib.types.port; + default = 14269; + description = "Local Jaeger admin and metrics port."; + }; + + tailscaleExporterEnvironmentFile = lib.mkOption { + type = lib.types.nullOr lib.types.path; + default = null; + description = "Optional environment file for the Prometheus Tailscale exporter OAuth credentials."; + }; + }; + + config = lib.mkIf cfg.enable (lib.mkMerge [ + { + virtualisation.podman.enable = true; + + services.grafana = { + settings = { + metrics = { + enabled = true; + disable_total_stats = true; + }; + }; + provision = { + enable = true; + datasources.settings = { + apiVersion = 1; + prune = true; + datasources = [ + { + name = "Prometheus"; + uid = "prometheus"; + type = "prometheus"; + access = "proxy"; + url = "http://${cfg.prometheusListenAddress}:${toString cfg.prometheusPort}"; + isDefault = true; + jsonData = { + timeInterval = "15s"; + httpMethod = "POST"; + }; + } + { + name = "Jaeger"; + uid = "jaeger"; + type = "jaeger"; + access = "proxy"; + url = "http://127.0.0.1:${toString cfg.jaegerUiPort}"; + } + ]; + }; + }; + }; + + services.prometheus = { + enable = true; + listenAddress = cfg.prometheusListenAddress; + port = cfg.prometheusPort; + retentionTime = "30d"; + checkConfig = "syntax-only"; + exporters = { + node = { + enable = true; + listenAddress = "127.0.0.1"; + }; + systemd = { + enable = true; + listenAddress = "127.0.0.1"; + }; + }; + scrapeConfigs = [ + { + job_name = "prometheus"; + static_configs = [ + { targets = [ "${cfg.prometheusListenAddress}:${toString cfg.prometheusPort}" ]; } + ]; + } + { + job_name = "node"; + static_configs = [ + { targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ]; } + ]; + } + { + job_name = "systemd"; + static_configs = [ + { targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.systemd.port}" ]; } + ]; + } + { + job_name = "grafana"; + metrics_path = "/metrics"; + static_configs = [ + { targets = [ "${grafanaHttpAddress}:${toString grafanaHttpPort}" ]; } + ]; + } + { + job_name = "headscale"; + metrics_path = "/metrics"; + static_configs = [ + { targets = [ "${headscaleCfg.metricsListenAddress}:${toString headscaleCfg.metricsPort}" ]; } + ]; + } + { + job_name = "otel-collector"; + static_configs = [ + { targets = [ cfg.otelPrometheusEndpoint ]; } + ]; + } + { + job_name = "jaeger"; + metrics_path = "/metrics"; + static_configs = [ + { targets = [ "127.0.0.1:${toString cfg.jaegerAdminPort}" ]; } + ]; + } + ] ++ lib.optionals garageCfg.enable [ + { + job_name = "garage"; + metrics_path = "/metrics"; + static_configs = [ + { targets = [ "${garageCfg.adminListenAddress}:${toString garageCfg.adminPort}" ]; } + ]; + } + ] ++ lib.optionals tailscaleExporterEnabled [ + { + job_name = "tailscale"; + static_configs = [ + { targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.tailscale.port}" ]; } + ]; + } + ]; + }; + + services.opentelemetry-collector = { + enable = true; + package = otelCollectorPackage; + settings = { + receivers = { + otlp = { + protocols = { + grpc.endpoint = cfg.otelGrpcEndpoint; + http.endpoint = cfg.otelHttpEndpoint; + }; + }; + }; + processors = { + resource.attributes = [ + { + key = "service.namespace"; + value = "burrow"; + action = "upsert"; + } + { + key = "deployment.environment"; + value = config.networking.hostName; + action = "upsert"; + } + ]; + batch = { }; + }; + exporters = { + "otlp/jaeger" = { + endpoint = "127.0.0.1:${toString cfg.jaegerOtlpGrpcPort}"; + tls.insecure = true; + }; + prometheus.endpoint = cfg.otelPrometheusEndpoint; + }; + service.pipelines = { + traces = { + receivers = [ "otlp" ]; + processors = [ + "resource" + "batch" + ]; + exporters = [ "otlp/jaeger" ]; + }; + metrics = { + receivers = [ "otlp" ]; + processors = [ + "resource" + "batch" + ]; + exporters = [ "prometheus" ]; + }; + }; + }; + }; + + virtualisation.oci-containers.containers.burrow-jaeger = { + image = cfg.jaegerImage; + autoStart = true; + environment = { + COLLECTOR_OTLP_ENABLED = "true"; + SPAN_STORAGE_TYPE = "badger"; + BADGER_EPHEMERAL = "false"; + BADGER_DIRECTORY_VALUE = "/badger/data"; + BADGER_DIRECTORY_KEY = "/badger/key"; + }; + volumes = [ + "burrow-jaeger-badger:/badger" + ]; + ports = [ + "127.0.0.1:${toString cfg.jaegerUiPort}:16686" + "127.0.0.1:${toString cfg.jaegerOtlpGrpcPort}:4317" + "127.0.0.1:${toString cfg.jaegerOtlpHttpPort}:4318" + "127.0.0.1:${toString cfg.jaegerAdminPort}:14269" + ]; + extraOptions = [ "--pull=always" ]; + }; + + systemd.services.opentelemetry-collector.after = [ "podman-burrow-jaeger.service" ]; + systemd.services.opentelemetry-collector.wants = [ "podman-burrow-jaeger.service" ]; + + environment.sessionVariables = { + OTEL_EXPORTER_OTLP_ENDPOINT = "http://${cfg.otelGrpcEndpoint}"; + OTEL_EXPORTER_OTLP_PROTOCOL = "grpc"; + }; + } + + (lib.mkIf tailscaleExporterEnabled { + services.prometheus.exporters.tailscale = { + enable = true; + listenAddress = "127.0.0.1"; + environmentFile = cfg.tailscaleExporterEnvironmentFile; + }; + }) + ]); +} diff --git a/nixos/modules/burrow-openbao.nix b/nixos/modules/burrow-openbao.nix new file mode 100644 index 0000000..82f7718 --- /dev/null +++ b/nixos/modules/burrow-openbao.nix @@ -0,0 +1,101 @@ +{ config, lib, ... }: + +let + cfg = config.services.burrow.openbao; +in +{ + options.services.burrow.openbao = { + enable = lib.mkEnableOption "the Burrow OpenBao deployment"; + + domain = lib.mkOption { + type = lib.types.str; + default = "vault.burrow.net"; + description = "Public OpenBao domain."; + }; + + listenAddress = lib.mkOption { + type = lib.types.str; + default = "127.0.0.1"; + description = "Local OpenBao listener address."; + }; + + port = lib.mkOption { + type = lib.types.port; + default = 8200; + description = "Local OpenBao API port."; + }; + + clusterPort = lib.mkOption { + type = lib.types.port; + default = 8201; + description = "Local OpenBao cluster port."; + }; + + dataDir = lib.mkOption { + type = lib.types.str; + default = "/var/lib/burrow/openbao"; + description = "Persistent OpenBao state directory."; + }; + + googleKmsSeal = { + enable = lib.mkEnableOption "Google Cloud KMS seal wrapping"; + + project = lib.mkOption { + type = lib.types.str; + default = "project-88c23ce9-918a-470a-b33"; + description = "Google Cloud project containing the seal key."; + }; + + location = lib.mkOption { + type = lib.types.str; + default = "global"; + description = "Google Cloud KMS key ring location."; + }; + + keyRing = lib.mkOption { + type = lib.types.str; + default = "burrow-identity"; + description = "Google Cloud KMS key ring name."; + }; + + cryptoKey = lib.mkOption { + type = lib.types.str; + default = "openbao-seal"; + description = "Google Cloud KMS crypto key name used for seal wrapping."; + }; + }; + }; + + config = lib.mkIf cfg.enable { + systemd.tmpfiles.rules = [ + "d ${cfg.dataDir} 0700 openbao openbao - -" + "d ${cfg.dataDir}/data 0700 openbao openbao - -" + ]; + + services.openbao = { + enable = true; + settings = { + ui = true; + api_addr = "https://${cfg.domain}"; + cluster_addr = "http://${cfg.listenAddress}:${toString cfg.clusterPort}"; + storage.file.path = "${cfg.dataDir}/data"; + listener.tcp = { + address = "${cfg.listenAddress}:${toString cfg.port}"; + tls_disable = true; + }; + } // lib.optionalAttrs cfg.googleKmsSeal.enable { + seal.gcpckms = { + project = cfg.googleKmsSeal.project; + region = cfg.googleKmsSeal.location; + key_ring = cfg.googleKmsSeal.keyRing; + crypto_key = cfg.googleKmsSeal.cryptoKey; + }; + }; + }; + + services.caddy.virtualHosts."${cfg.domain}".extraConfig = '' + encode gzip zstd + reverse_proxy ${cfg.listenAddress}:${toString cfg.port} + ''; + }; +} diff --git a/package/arch/README.md b/package/arch/README.md new file mode 100644 index 0000000..71567cd --- /dev/null +++ b/package/arch/README.md @@ -0,0 +1,15 @@ +# Arch and AUR + +Burrow has two Arch-family distribution surfaces: + +- `package/arch/aur/burrow-git` is the source-build AUR package repository. +- `package/repositories/pacman/pacman.conf` describes the binary pacman + repository at `packages.burrow.net`. + +Publish `burrow-git` to the AUR as its own git repository. Regenerate +`.SRCINFO` from the same `PKGBUILD` before pushing an AUR update. + +The binary pacman repository is built by +`Scripts/package/build-repositories.sh arch` and signs both packages and the +repository database sidecars through the `package-pacman-repository` Google KMS +key. diff --git a/package/arch/aur/burrow-git/.SRCINFO b/package/arch/aur/burrow-git/.SRCINFO new file mode 100644 index 0000000..34cc320 --- /dev/null +++ b/package/arch/aur/burrow-git/.SRCINFO @@ -0,0 +1,21 @@ +pkgbase = burrow-git + pkgdesc = Burrow VPN daemon and CLI + pkgver = 0.1.r0.g0000000 + pkgrel = 1 + url = https://git.burrow.net/hackclub/burrow + install = burrow.install + arch = x86_64 + arch = aarch64 + license = GPL-3.0-or-later + makedepends = cargo + makedepends = git + makedepends = protobuf + depends = openssl + depends = sqlite + depends = systemd + provides = burrow + conflicts = burrow + source = git+https://git.burrow.net/hackclub/burrow.git + sha256sums = SKIP + +pkgname = burrow-git diff --git a/package/arch/aur/burrow-git/PKGBUILD b/package/arch/aur/burrow-git/PKGBUILD new file mode 100644 index 0000000..92a7555 --- /dev/null +++ b/package/arch/aur/burrow-git/PKGBUILD @@ -0,0 +1,35 @@ +# Maintainer: Burrow Release Automation + +pkgname=burrow-git +pkgver=0.1.r0.g0000000 +pkgrel=1 +pkgdesc="Burrow VPN daemon and CLI" +arch=("x86_64" "aarch64") +url="https://git.burrow.net/hackclub/burrow" +license=("GPL-3.0-or-later") +depends=("openssl" "sqlite" "systemd") +makedepends=("cargo" "git" "protobuf") +provides=("burrow") +conflicts=("burrow") +source=("git+https://git.burrow.net/hackclub/burrow.git") +sha256sums=("SKIP") +install="burrow.install" + +pkgver() { + cd burrow + printf "0.1.r%s.g%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" +} + +build() { + cd burrow + cargo build --locked --release -p burrow --bin burrow +} + +package() { + cd burrow + install -Dm755 target/release/burrow "${pkgdir}/usr/bin/burrow" + install -Dm644 systemd/burrow.service "${pkgdir}/usr/lib/systemd/system/burrow.service" + install -Dm644 systemd/burrow.socket "${pkgdir}/usr/lib/systemd/system/burrow.socket" + install -Dm644 README.md "${pkgdir}/usr/share/doc/burrow/README.md" + install -Dm644 LICENSE.md "${pkgdir}/usr/share/licenses/burrow/LICENSE.md" +} diff --git a/package/arch/aur/burrow-git/burrow.install b/package/arch/aur/burrow-git/burrow.install new file mode 100644 index 0000000..355547d --- /dev/null +++ b/package/arch/aur/burrow-git/burrow.install @@ -0,0 +1,16 @@ +post_install() { + systemctl daemon-reload + echo "Enable Burrow with: systemctl enable --now burrow.socket" +} + +post_upgrade() { + systemctl daemon-reload +} + +pre_remove() { + systemctl disable --now burrow.socket >/dev/null 2>&1 || true +} + +post_remove() { + systemctl daemon-reload +} diff --git a/package/repositories/README.md b/package/repositories/README.md new file mode 100644 index 0000000..bc227fe --- /dev/null +++ b/package/repositories/README.md @@ -0,0 +1,52 @@ +# Burrow Native Package Repositories + +Burrow publishes native daemon packages through repository formats that Linux +desktops already understand: + +- APT repository for Debian and Ubuntu +- RPM repository for Fedora, RHEL-family systems, and openSUSE-family systems +- pacman repository for Arch-family systems +- AUR source package repository for Arch users who prefer local builds +- Flatpak repository descriptor for the GTK GUI, with the daemon still supplied + by a native package +- NixOS flake/module for NixOS + +APT, RPM, and pacman repository metadata is signed with OpenPGP signatures +produced by `Scripts/package/google-kms-openpgp.py`. The OpenPGP public keys are +derived from the Google Cloud KMS public keys, while the private RSA signing +operation happens inside Google Cloud KMS. Each repository format has its own +KMS key: + +- `package-apt-repository` +- `package-rpm-repository` +- `package-pacman-repository` +- `package-flatpak-repository` +- `package-aur-source` + +Build repository metadata from package artifacts with: + +```sh +BURROW_PACKAGE_INPUT_DIR=dist/packages \ +BURROW_APT_REPO_KMS_PUBLIC_KEY_PEM=.kms/apt.pem \ +BURROW_RPM_REPO_KMS_PUBLIC_KEY_PEM=.kms/rpm.pem \ +BURROW_PACMAN_REPO_KMS_PUBLIC_KEY_PEM=.kms/pacman.pem \ +Scripts/package/build-repositories.sh all +``` + +The builder writes repository trees under `publish/repositories` by default: + +- `apt/dists//...` +- `rpm///...` +- `arch/burrow//...` +- `keys/*.asc` + +The Forgejo workflow `.forgejo/workflows/publish-package-repositories.yml` +builds Linux package artifacts, exports KMS public keys, signs repository +metadata through Google KMS, uploads the repository tree as a workflow artifact, +and publishes the tree to the package GCS bucket when `publish_gcs` is enabled. +The workflow authenticates to the Burrow Google project through Authentik-backed +Workload Identity Federation before it calls Google KMS or writes objects. + +PackageKit is an optional install frontend. It is not the repository format and +it is not available everywhere. The Flatpak GUI should try PackageKit only as a +convenience path, then degrade to native repository setup instructions. diff --git a/package/repositories/apt/burrow.sources b/package/repositories/apt/burrow.sources new file mode 100644 index 0000000..99da324 --- /dev/null +++ b/package/repositories/apt/burrow.sources @@ -0,0 +1,6 @@ +Types: deb +URIs: https://packages.burrow.net/apt +Suites: stable +Components: main +Architectures: amd64 arm64 +Signed-By: /usr/share/keyrings/burrow-package-apt-repository.gpg diff --git a/package/repositories/flatpak/burrow.flatpakrepo.in b/package/repositories/flatpak/burrow.flatpakrepo.in new file mode 100644 index 0000000..a813194 --- /dev/null +++ b/package/repositories/flatpak/burrow.flatpakrepo.in @@ -0,0 +1,8 @@ +[Flatpak Repo] +Title=Burrow +Url=https://packages.burrow.net/flatpak +Homepage=https://burrow.net +Comment=Burrow GTK desktop UI +Description=Burrow GTK desktop UI. VPN operation requires the native Burrow daemon package on the host. +Icon=https://burrow.net/icon.png +GPGKey=@BURROW_FLATPAK_GPG_KEY_BASE64@ diff --git a/package/repositories/packagekit/README.md b/package/repositories/packagekit/README.md new file mode 100644 index 0000000..aad13c5 --- /dev/null +++ b/package/repositories/packagekit/README.md @@ -0,0 +1,16 @@ +# PackageKit Bootstrap + +PackageKit is the closest cross-distro install prompt for mutable Linux +desktops. Burrow treats it as an optional bootstrap path: + +```sh +pkcon install burrow +``` + +This works only when the host distro has PackageKit, the Burrow native +repository is configured, and polkit authorizes the action. The Flatpak GUI may +offer this path through a narrow `org.freedesktop.PackageKit` permission, but it +must also support direct native-repository instructions. + +The command fallback helper checks `apt-get`, `dnf`, `zypper`, `pacman`, `apk`, +`xbps-install`, `eopkg`, `emerge`, `swupd`, and `nix` after PackageKit. diff --git a/package/repositories/pacman/pacman.conf b/package/repositories/pacman/pacman.conf new file mode 100644 index 0000000..4c206bc --- /dev/null +++ b/package/repositories/pacman/pacman.conf @@ -0,0 +1,3 @@ +[burrow] +Server = https://packages.burrow.net/arch/burrow/$arch +SigLevel = Required DatabaseOptional diff --git a/package/repositories/rpm/burrow.repo b/package/repositories/rpm/burrow.repo new file mode 100644 index 0000000..481aa37 --- /dev/null +++ b/package/repositories/rpm/burrow.repo @@ -0,0 +1,7 @@ +[burrow] +name=Burrow +baseurl=https://packages.burrow.net/rpm/stable/$basearch +enabled=1 +gpgcheck=1 +repo_gpgcheck=1 +gpgkey=https://packages.burrow.net/keys/burrow-package-rpm-repository.asc diff --git a/patches/rcodesign-pkcs11-tool.patch b/patches/rcodesign-pkcs11-tool.patch new file mode 100644 index 0000000..c1fe36a --- /dev/null +++ b/patches/rcodesign-pkcs11-tool.patch @@ -0,0 +1,522 @@ +--- a/apple-codesign/src/cli/certificate_source.rs ++++ b/apple-codesign/src/cli/certificate_source.rs +@@ -16,0 +17 @@ ++ bytes::Bytes, +@@ -19,0 +21 @@ ++ signature::Signer, +@@ -21,2 +23,10 @@ +- std::path::PathBuf, +- x509_certificate::CapturedX509Certificate, ++ std::{ ++ path::PathBuf, ++ process::Command, ++ sync::atomic::{AtomicU64, Ordering}, ++ }, ++ x509_certificate::{ ++ CapturedX509Certificate, KeyAlgorithm, Sign, Signature, SignatureAlgorithm, ++ X509CertificateError, ++ }, ++ zeroize::Zeroizing, +@@ -36,0 +47,2 @@ ++static PKCS11_SIGN_COUNTER: AtomicU64 = AtomicU64::new(0); ++ +@@ -204,0 +214,262 @@ ++#[derive(Clone, Debug)] ++struct Pkcs11PrivateKey { ++ tool: String, ++ module: PathBuf, ++ slot_id: Option, ++ token_label: Option, ++ key_id: Option, ++ key_label: Option, ++ pin: String, ++ cert: CapturedX509Certificate, ++} ++ ++impl signature::Signer for Pkcs11PrivateKey { ++ fn try_sign(&self, message: &[u8]) -> Result { ++ match self.cert.key_algorithm() { ++ Some(KeyAlgorithm::Rsa) => {} ++ Some(algorithm) => { ++ return Err(signature::Error::from_source(format!( ++ "PKCS#11 signing currently supports RSA certificates, not {algorithm:?}" ++ ))); ++ } ++ None => { ++ return Err(signature::Error::from_source( ++ "failed to resolve PKCS#11 certificate key algorithm", ++ )); ++ } ++ } ++ ++ let sequence = PKCS11_SIGN_COUNTER.fetch_add(1, Ordering::Relaxed); ++ let base = std::env::temp_dir().join(format!( ++ "rcodesign-pkcs11-{}-{sequence}", ++ std::process::id() ++ )); ++ let input_path = base.with_extension("in"); ++ let output_path = base.with_extension("sig"); ++ let openssl_config_path = base.with_extension("openssl.cnf"); ++ let provider_debug_path = base.with_extension("pkcs11-provider.log"); ++ ++ std::fs::write(&input_path, message).map_err(signature::Error::from_source)?; ++ ++ let provider_override = ++ std::env::var("BURROW_APPLE_PKCS11_SIGN_WITH_OPENSSL_PROVIDER") ++ .or_else(|_| std::env::var("BURROW_PKCS11_SIGN_WITH_OPENSSL_PROVIDER")) ++ .ok() ++ .and_then(|value| { ++ if value.trim().is_empty() { ++ None ++ } else { ++ Some(matches!(value.as_str(), "1" | "true" | "TRUE" | "yes" | "YES" | "on" | "ON")) ++ } ++ }); ++ let use_openssl_provider = provider_override.unwrap_or_else(|| { ++ std::env::var("BURROW_APPLE_PKCS11_BACKEND") ++ .or_else(|_| std::env::var("BURROW_PKCS11_BACKEND")) ++ .map(|value| value == "gcp-kms") ++ .unwrap_or(false) ++ || self.module.to_string_lossy().contains("kmsp11") ++ || std::env::var("BURROW_GCP_KMS_PKCS11_CONFIG").is_ok() ++ || std::env::var("KMS_PKCS11_CONFIG").is_ok() ++ }); ++ ++ if use_openssl_provider { ++ let token_label = self.token_label.as_ref().ok_or_else(|| { ++ signature::Error::from_source( ++ "OpenSSL PKCS#11 provider signing requires --pkcs11-token-label", ++ ) ++ })?; ++ let mut key_uri = format!("pkcs11:token={token_label}"); ++ if let Some(label) = &self.key_label { ++ key_uri.push_str(";object="); ++ key_uri.push_str(label); ++ } else if let Some(id) = &self.key_id { ++ key_uri.push_str(";id="); ++ key_uri.push_str(id); ++ } else { ++ return Err(signature::Error::from_source( ++ "OpenSSL PKCS#11 provider signing requires --pkcs11-key-label or --pkcs11-key-id", ++ )); ++ } ++ key_uri.push_str(";type=private"); ++ ++ let pin_path = base.with_extension("pin"); ++ std::fs::write(&pin_path, &self.pin).map_err(signature::Error::from_source)?; ++ ++ let module_path = self.module.to_string_lossy(); ++ let kms_config = std::env::var("KMS_PKCS11_CONFIG") ++ .or_else(|_| std::env::var("BURROW_GCP_KMS_PKCS11_CONFIG")) ++ .ok(); ++ let needs_kms_config = module_path.contains("kmsp11") || kms_config.is_some(); ++ if needs_kms_config { ++ let config_path = kms_config.as_ref().ok_or_else(|| { ++ signature::Error::from_source( ++ "OpenSSL PKCS#11 provider signing with Google KMS requires KMS_PKCS11_CONFIG", ++ ) ++ })?; ++ let metadata = std::fs::metadata(config_path).map_err(|err| { ++ signature::Error::from_source(format!( ++ "OpenSSL PKCS#11 provider signing could not read KMS_PKCS11_CONFIG at {config_path}: {err}" ++ )) ++ })?; ++ if !metadata.is_file() || metadata.len() == 0 { ++ return Err(signature::Error::from_source(format!( ++ "OpenSSL PKCS#11 provider signing requires a non-empty KMS_PKCS11_CONFIG file at {config_path}" ++ ))); ++ } ++ } ++ ++ let openssl_modules = std::env::var("BURROW_OPENSSL_MODULES") ++ .or_else(|_| std::env::var("OPENSSL_MODULES")) ++ .ok() ++ .filter(|value| !value.trim().is_empty()); ++ if let Some(modules) = &openssl_modules { ++ let provider_extension = if cfg!(target_os = "macos") { ++ "dylib" ++ } else { ++ "so" ++ }; ++ let provider_module = PathBuf::from(modules) ++ .join(format!("pkcs11.{provider_extension}")); ++ if provider_module.is_file() { ++ let config = format!( ++ "HOME = .\nopenssl_conf = openssl_init\n\n[openssl_init]\nproviders = provider_sect\n\n[provider_sect]\ndefault = default_sect\npkcs11 = pkcs11_sect\n\n[default_sect]\nactivate = 1\n\n[pkcs11_sect]\nmodule = {}\npkcs11-module-path = {}\npkcs11-module-token-pin = file:{}\npkcs11-module-cache-pins = cache\npkcs11-module-quirks = no-operation-state no-allowed-mechanisms\nactivate = 1\n", ++ provider_module.display(), ++ self.module.display(), ++ pin_path.display(), ++ ); ++ std::fs::write(&openssl_config_path, config) ++ .map_err(signature::Error::from_source)?; ++ } ++ } ++ ++ let openssl = std::env::var("BURROW_OPENSSL").unwrap_or_else(|_| "openssl".into()); ++ let mut command = Command::new(openssl); ++ command ++ .env("PKCS11_PROVIDER_MODULE", &self.module) ++ .arg("dgst") ++ .arg("-provider") ++ .arg("pkcs11") ++ .arg("-provider") ++ .arg("default") ++ .arg("-sha256") ++ .arg("-sign") ++ .arg(&key_uri) ++ .arg("-passin") ++ .arg(format!("file:{}", pin_path.display())) ++ .arg("-out") ++ .arg(&output_path) ++ .arg(&input_path); ++ if let Some(config_path) = kms_config { ++ command ++ .env("KMS_PKCS11_CONFIG", &config_path) ++ .env("BURROW_GCP_KMS_PKCS11_CONFIG", &config_path); ++ } ++ if let Ok(credentials_path) = std::env::var("GOOGLE_APPLICATION_CREDENTIALS") { ++ command.env("GOOGLE_APPLICATION_CREDENTIALS", credentials_path); ++ } ++ if let Some(modules) = openssl_modules { ++ command.env("OPENSSL_MODULES", modules); ++ } ++ if openssl_config_path.is_file() { ++ command.env("OPENSSL_CONF", &openssl_config_path); ++ } ++ if let Ok(debug) = std::env::var("BURROW_PKCS11_PROVIDER_DEBUG") ++ .or_else(|_| std::env::var("PKCS11_PROVIDER_DEBUG")) ++ { ++ command.env("PKCS11_PROVIDER_DEBUG", debug); ++ } else { ++ command.env( ++ "PKCS11_PROVIDER_DEBUG", ++ format!("file:{},level:1", provider_debug_path.display()), ++ ); ++ } ++ ++ let output = command.output().map_err(signature::Error::from_source)?; ++ let _ = std::fs::remove_file(&input_path); ++ let _ = std::fs::remove_file(&pin_path); ++ let _ = std::fs::remove_file(&openssl_config_path); ++ ++ if !output.status.success() { ++ let _ = std::fs::remove_file(&output_path); ++ let provider_debug = std::fs::read_to_string(&provider_debug_path) ++ .ok() ++ .filter(|value| !value.trim().is_empty()) ++ .map(|value| { ++ let tail = value ++ .lines() ++ .rev() ++ .take(80) ++ .collect::>() ++ .into_iter() ++ .rev() ++ .collect::>() ++ .join("\n"); ++ format!("\nPKCS#11 provider debug tail:\n{tail}\n") ++ }) ++ .unwrap_or_default(); ++ let _ = std::fs::remove_file(&provider_debug_path); ++ return Err(signature::Error::from_source(format!( ++ "OpenSSL PKCS#11 provider signing failed with status {}: {}{}{}", ++ output.status, ++ String::from_utf8_lossy(&output.stdout), ++ String::from_utf8_lossy(&output.stderr), ++ provider_debug ++ ))); ++ } ++ let _ = std::fs::remove_file(&provider_debug_path); ++ } else { ++ let mut command = Command::new(&self.tool); ++ command ++ .arg("--module") ++ .arg(&self.module) ++ .arg("--login") ++ .arg("--pin") ++ .arg(&self.pin) ++ .arg("--sign") ++ .arg("--mechanism") ++ .arg("SHA256-RSA-PKCS") ++ .arg("--input-file") ++ .arg(&input_path) ++ .arg("--output-file") ++ .arg(&output_path); ++ ++ if let Some(slot_id) = &self.slot_id { ++ command.arg("--slot").arg(slot_id); ++ } ++ if let Some(token_label) = &self.token_label { ++ command.arg("--token-label").arg(token_label); ++ } ++ if let Some(id) = &self.key_id { ++ command.arg("--id").arg(id); ++ } ++ if let Some(label) = &self.key_label { ++ command.arg("--label").arg(label); ++ } ++ ++ let output = command.output().map_err(signature::Error::from_source)?; ++ ++ let _ = std::fs::remove_file(&input_path); ++ ++ if !output.status.success() { ++ let _ = std::fs::remove_file(&output_path); ++ return Err(signature::Error::from_source(format!( ++ "pkcs11-tool signing failed with status {}: {}{}", ++ output.status, ++ String::from_utf8_lossy(&output.stdout), ++ String::from_utf8_lossy(&output.stderr) ++ ))); ++ } ++ } ++ ++ let signature = std::fs::read(&output_path).map_err(signature::Error::from_source)?; ++ let _ = std::fs::remove_file(&output_path); ++ ++ if signature.is_empty() { ++ return Err(signature::Error::from_source( ++ "pkcs11-tool produced an empty signature", ++ )); ++ } ++ ++ Ok(signature.into()) ++ } ++} +@@ -204,0 +384,214 @@ ++impl Sign for Pkcs11PrivateKey { ++ fn sign(&self, message: &[u8]) -> Result<(Vec, SignatureAlgorithm), X509CertificateError> { ++ let algorithm = self.signature_algorithm()?; ++ ++ Ok((self.try_sign(message)?.into(), algorithm)) ++ } ++ ++ fn key_algorithm(&self) -> Option { ++ self.cert.key_algorithm() ++ } ++ ++ fn public_key_data(&self) -> Bytes { ++ self.cert.public_key_data() ++ } ++ ++ fn signature_algorithm(&self) -> Result { ++ match self.cert.key_algorithm() { ++ Some(KeyAlgorithm::Rsa) => Ok(SignatureAlgorithm::RsaSha256), ++ Some(algorithm) => Err(X509CertificateError::UnknownSignatureAlgorithm(format!( ++ "PKCS#11 signing currently supports RSA certificates, not {algorithm:?}" ++ ))), ++ None => Err(X509CertificateError::UnknownSignatureAlgorithm( ++ "failed to resolve PKCS#11 certificate key algorithm".into(), ++ )), ++ } ++ } ++ ++ fn private_key_data(&self) -> Option>> { ++ None ++ } ++ ++ fn rsa_primes( ++ &self, ++ ) -> Result>, Zeroizing>)>, X509CertificateError> { ++ Ok(None) ++ } ++} ++ ++impl x509_certificate::KeyInfoSigner for Pkcs11PrivateKey {} ++ ++impl PrivateKey for Pkcs11PrivateKey { ++ fn as_key_info_signer(&self) -> &dyn x509_certificate::KeyInfoSigner { ++ self ++ } ++ ++ fn to_public_key_peer_decrypt( ++ &self, ++ ) -> Result< ++ Box, ++ AppleCodesignError, ++ > { ++ Err(AppleCodesignError::CliGeneralError( ++ "PKCS#11 keys cannot decrypt remote-signing peer setup data".into(), ++ )) ++ } ++ ++ fn finish(&self) -> Result<(), AppleCodesignError> { ++ Ok(()) ++ } ++} ++ ++#[derive(Args, Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] ++#[serde(deny_unknown_fields)] ++pub struct Pkcs11SigningKey { ++ /// Path to pkcs11-tool ++ #[arg(id = "pkcs11_tool", long = "pkcs11-tool", default_value = "pkcs11-tool", value_name = "PATH")] ++ pub tool: String, ++ ++ /// Path to the PKCS#11 module to use for signing ++ #[arg( ++ long = "pkcs11-library", ++ alias = "pkcs11-module", ++ id = "pkcs11_library", ++ value_name = "PATH" ++ )] ++ pub module: Option, ++ ++ /// PKCS#11 slot id containing the signing key ++ #[arg(id = "pkcs11_slot_id", long = "pkcs11-slot-id", value_name = "SLOT")] ++ pub slot_id: Option, ++ ++ /// PKCS#11 token label containing the signing key ++ #[arg(id = "pkcs11_token_label", long = "pkcs11-token-label", value_name = "LABEL")] ++ pub token_label: Option, ++ ++ /// PKCS#11 private-key object id, usually hex ++ #[arg(id = "pkcs11_key_id", long = "pkcs11-key-id", value_name = "ID")] ++ pub key_id: Option, ++ ++ /// PKCS#11 private-key object label ++ #[arg(id = "pkcs11_key_label", long = "pkcs11-key-label", value_name = "LABEL")] ++ pub key_label: Option, ++ ++ /// PIN used to unlock the PKCS#11 token ++ #[arg(id = "pkcs11_pin", long = "pkcs11-pin", group = "pkcs11-pin-source", value_name = "PIN")] ++ pub pin: Option, ++ ++ /// File containing the PIN used to unlock the PKCS#11 token ++ #[arg(id = "pkcs11_pin_file", long = "pkcs11-pin-file", group = "pkcs11-pin-source", value_name = "PATH")] ++ pub pin_path: Option, ++ ++ /// Environment variable holding the PIN used to unlock the PKCS#11 token ++ #[arg(id = "pkcs11_pin_env", long = "pkcs11-pin-env", group = "pkcs11-pin-source", value_name = "ENV")] ++ #[serde(skip)] ++ pub pin_env: Option, ++ ++ /// DER certificate file corresponding to the PKCS#11 private key ++ #[arg( ++ long = "pkcs11-certificate-file", ++ alias = "pkcs11-certificate-der-file", ++ id = "pkcs11_certificate_file", ++ value_name = "PATH" ++ )] ++ pub certificate_path: Option, ++} ++ ++impl Pkcs11SigningKey { ++ pub(crate) fn configured(&self) -> bool { ++ self.module.is_some() ++ || self.slot_id.is_some() ++ || self.token_label.is_some() ++ || self.key_id.is_some() ++ || self.key_label.is_some() ++ || self.pin.is_some() ++ || self.pin_path.is_some() ++ || self.pin_env.is_some() ++ || self.certificate_path.is_some() ++ } ++ ++ fn not_configured(&self) -> bool { ++ !self.configured() ++ } ++ ++ fn resolve_pin(&self) -> Result { ++ if let Some(pin) = &self.pin { ++ Ok(pin.clone()) ++ } else if let Some(path) = &self.pin_path { ++ Ok(std::fs::read_to_string(path)?.trim().to_string()) ++ } else if let Some(env) = &self.pin_env { ++ std::env::var(env).map_err(|_| { ++ AppleCodesignError::CliGeneralError(format!( ++ "failed reading PKCS#11 PIN from {env} environment variable" ++ )) ++ }) ++ } else { ++ Err(AppleCodesignError::CliGeneralError( ++ "--pkcs11-pin, --pkcs11-pin-file, or --pkcs11-pin-env is required".into(), ++ )) ++ } ++ } ++} ++ ++impl KeySource for Pkcs11SigningKey { ++ fn resolve_certificates(&self) -> Result { ++ if !self.configured() { ++ return Ok(Default::default()); ++ } ++ ++ let module = self.module.clone().ok_or_else(|| { ++ AppleCodesignError::CliGeneralError("--pkcs11-library is required".into()) ++ })?; ++ if self.slot_id.is_none() && self.token_label.is_none() { ++ return Err(AppleCodesignError::CliGeneralError( ++ "--pkcs11-slot-id or --pkcs11-token-label is required".into(), ++ )); ++ } ++ if self.key_id.is_none() && self.key_label.is_none() { ++ return Err(AppleCodesignError::CliGeneralError( ++ "--pkcs11-key-id or --pkcs11-key-label is required".into(), ++ )); ++ } ++ let certificate_path = self.certificate_path.clone().ok_or_else(|| { ++ AppleCodesignError::CliGeneralError("--pkcs11-certificate-file is required".into()) ++ })?; ++ let pin = self.resolve_pin()?; ++ ++ warn!( ++ "reading PKCS#11 certificate data from {}", ++ certificate_path.display() ++ ); ++ let cert = CapturedX509Certificate::from_der(std::fs::read(certificate_path)?)?; ++ ++ match cert.key_algorithm() { ++ Some(KeyAlgorithm::Rsa) => {} ++ Some(algorithm) => { ++ return Err(AppleCodesignError::CliGeneralError(format!( ++ "PKCS#11 signing currently supports RSA certificates, not {algorithm:?}" ++ ))); ++ } ++ None => { ++ return Err(AppleCodesignError::CliGeneralError( ++ "failed to resolve PKCS#11 certificate key algorithm".into(), ++ )); ++ } ++ } ++ ++ let signer = Pkcs11PrivateKey { ++ tool: self.tool.clone(), ++ module, ++ slot_id: self.slot_id.clone(), ++ token_label: self.token_label.clone(), ++ key_id: self.key_id.clone(), ++ key_label: self.key_label.clone(), ++ pin, ++ cert: cert.clone(), ++ }; ++ ++ Ok(SigningCertificates { ++ keys: vec![Box::new(signer)], ++ certs: vec![cert], ++ }) ++ } ++} ++ +@@ -643,0 +1037,8 @@ ++ rename = "pkcs11", ++ skip_serializing_if = "Pkcs11SigningKey::not_configured" ++ )] ++ pub pkcs11_key: Pkcs11SigningKey, ++ ++ #[command(flatten)] ++ #[serde( ++ default, +@@ -680,0 +1082,2 @@ ++ res.push(&self.pkcs11_key as &dyn KeySource); ++ +--- a/apple-codesign/src/cli/mod.rs ++++ b/apple-codesign/src/cli/mod.rs +@@ -1529 +1532,6 @@ +- let certs = c.signer.resolve_certificates(true)?; ++ let signer = if self.certificate.pkcs11_key.configured() { ++ &self.certificate ++ } else { ++ &c.signer ++ }; ++ let certs = signer.resolve_certificates(true)?; diff --git a/secrets.nix b/secrets.nix index 3f9bba4..db95367 100644 --- a/secrets.nix +++ b/secrets.nix @@ -11,14 +11,22 @@ let burrowForgeHost ]; uiTestRecipients = burrowForgeRecipients ++ [ conradev ]; + releaseRecipients = burrowForgeRecipients ++ [ conradev ]; in { + "secrets/apple/appstore-connect.env.age".publicKeys = releaseRecipients; + "secrets/apple/distribution-signing.env.age".publicKeys = releaseRecipients; + "secrets/apple/sparkle.env.age".publicKeys = releaseRecipients; "secrets/infra/authentik.env.age".publicKeys = burrowForgeRecipients; "secrets/infra/authentik-google-client-id.age".publicKeys = burrowForgeRecipients; "secrets/infra/authentik-google-client-secret.age".publicKeys = burrowForgeRecipients; "secrets/infra/authentik-google-account-map.json.age".publicKeys = burrowForgeRecipients; + "secrets/infra/authentik-google-wif-client-secret.age".publicKeys = burrowForgeRecipients; "secrets/infra/authentik-ui-test-password.age".publicKeys = uiTestRecipients; "secrets/infra/forgejo-oidc-client-secret.age".publicKeys = burrowForgeRecipients; + "secrets/infra/grafana-admin-password.age".publicKeys = burrowForgeRecipients; + "secrets/infra/grafana-secret-key.age".publicKeys = burrowForgeRecipients; + "secrets/infra/grafana-oidc-client-secret.age".publicKeys = burrowForgeRecipients; "secrets/infra/forgejo-nsc-autoscaler-config.age".publicKeys = burrowForgeRecipients; "secrets/infra/forgejo-nsc-dispatcher-config.age".publicKeys = burrowForgeRecipients; "secrets/infra/forgejo-nsc-token.age".publicKeys = burrowForgeRecipients; diff --git a/secrets/apple/appstore-connect.env.age b/secrets/apple/appstore-connect.env.age new file mode 100644 index 0000000..5762560 Binary files /dev/null and b/secrets/apple/appstore-connect.env.age differ diff --git a/secrets/apple/sparkle.env.age b/secrets/apple/sparkle.env.age new file mode 100644 index 0000000..7a73864 --- /dev/null +++ b/secrets/apple/sparkle.env.age @@ -0,0 +1,14 @@ +age-encryption.org/v1 +-> ssh-ed25519 ux4N8Q 4lsJwrd+zftsXdTsQ3gHxHBPcj0vB4DI9rtV9tnNj34 +egBI8PYwaKvatPeSSz/IBBpsV/HSyYINcoVL1Z5+fMo +-> ssh-ed25519 IrZmAg UMLZxY6J5w1Nt3oCnkKCELS0fP8LhRQzBuata2m0/m0 +p0Nj6XUD3/Z/VgNX99POOv9d3kvMTXlCndh40uzZwuU +-> ssh-ed25519 0kWPgQ VqbeBJ9KELadFFhEUVQuXaayCw7m1XxBNoAhcavGYAs +zrUKaHsxMNI+YfFMi6w0qJ0QsGTl6lBPkAMAT6Np4U8 +-> X25519 P3EVVvgL1O/2N1tDVqdiNnwpnocO1dsT1MZEBqTk+HQ +lEdIo0nWWIwWJ0gbt1X7H6do+lCjhMEyTv2dyDtEmNs +-> ssh-ed25519 tbm5Cw YjftkJadPiA1/vTWS53xK9EkyDWXiL2+WJpAx+ZM+HQ +3b3CP3UA/TK3+2EuNDL8Vf22o+Mxgx6bsm5Ub7e7lNc +--- LKEHr9rQIZlVZQTW46XwDCDa5lsKrgIamb2ocpG5vHw +P +N D5zyL"ED0%oԄ| Oc!]# (xDTGXx؇#+XANz2bv] \ No newline at end of file diff --git a/secrets/infra/authentik-google-wif-client-secret.age b/secrets/infra/authentik-google-wif-client-secret.age new file mode 100644 index 0000000..427dbba --- /dev/null +++ b/secrets/infra/authentik-google-wif-client-secret.age @@ -0,0 +1,11 @@ +age-encryption.org/v1 +-> ssh-ed25519 ux4N8Q dmNzqS+jc7JGI31mzsRRxSr7vAxRw3uxkbs4vzG20gk +sJWziiiMhKGzEiAeIxPfeqUYIu4CzZRw+eMXle5zMRs +-> ssh-ed25519 IrZmAg McLHhYu/3wDQYB1bJ/rXsoTv2UgpVTRm4AqsCTLkhCc +Rrl0vy0mhdXR0pSHckRI39Eg0bxB/Km3lCXXxl9t9Io +-> ssh-ed25519 0kWPgQ UQoa9fP3OPYtesWmMiWL1q8MqPxsXy//hj6805JQBRg +UKt/WM0t90OPDH9A+RVgrW60vlI2FmRewGsXGD5FCkU +-> X25519 48f0e9+P3ihg3mJIQxvHvq1P/4JEfS1t7DO73/TRGwg +k70uLkBQt5F1ovKhemYRhyKuPQXfT5XSXMzaQczPC8Q +--- L9B029nBJvUvCKhU2Avmmdmw5sce7bvhFpiPm0p+TVE +nG$\_$s&ΪALlZɪ N!ZA%LVb$(`aK ssh-ed25519 ux4N8Q m92EIjRqUnhjOm40jyn0JXujyj/P8rvZX4K5T0zLvG8 +VHseS9X67DiViTwzPnTFa19CuNZX+iUDKIyeN1DlXyA +-> ssh-ed25519 IrZmAg IK6wvWDy5HghH/KodWnb4X3PR12Ra0EKY6AVG2jvUU8 +Hu1GHi2C3tbL0WY5MDfZzm4CIbROh0l2exMNOEWmm3E +-> ssh-ed25519 0kWPgQ S4PIujnjsoc/R1NoitDp+4BwGNFMvKkQh4Dcweo92W4 +HY9xiDOXSxl14ZVlNkUWVbHlOh1pizLcKiotrTdecy0 +-> X25519 n0O4uO3oVQb8d42GwI+2SjTxsXObpU0PQ4zC1l9WWSc +WhOtVcYPF9xUsm2/jqutdWMPDaeRRITW3QsxGikPYm4 +--- CT5DMaqNGPPzYUCay11loEixWG0MID4yuubYR9wDFxA +UDX!xr#S>Vw}׍L4]#f`;ɂ/3Z)QV4 +d}=}- \ No newline at end of file diff --git a/secrets/infra/grafana-secret-key.age b/secrets/infra/grafana-secret-key.age new file mode 100644 index 0000000..42af338 Binary files /dev/null and b/secrets/infra/grafana-secret-key.age differ diff --git a/services/forgejo-nsc/README.md b/services/forgejo-nsc/README.md index 79058bb..e84a71b 100644 --- a/services/forgejo-nsc/README.md +++ b/services/forgejo-nsc/README.md @@ -121,14 +121,14 @@ dispatcher: url: "http://dispatcher:8080" instances: -- name: burrow - forgejo: - base_url: "https://git.burrow.net" - token: "PENDING-FORGEJO-PAT" - scope: - level: "repository" - owner: "burrow" - name: "burrow" + - name: burrow + forgejo: + base_url: "https://git.burrow.net" + token: "PENDING-FORGEJO-PAT" + scope: + level: "repository" + owner: "hackclub" + name: "burrow" disable_polling: true # webhook-only mode poll_interval: "30s" webhook_secret: "supersecret" @@ -152,13 +152,14 @@ generate a Namespace token from the logged-in namespace account, and render the dispatcher/autoscaler configs into `intake/forgejo_nsc_{dispatcher,autoscaler}.yaml` plus `intake/forgejo_nsc_token.txt`. -For ongoing operations, use `Scripts/sync-forgejo-nsc-config.sh`: +For ongoing operations, use `Scripts/seal-forgejo-nsc-secrets.sh`: -- `Scripts/sync-forgejo-nsc-config.sh` copies the intake-backed configs and - Namespace token onto `/var/lib/burrow/intake/` on the forge host, reapplies - file ownership for `forgejo-nsc`, and restarts the dispatcher/autoscaler. -- `Scripts/sync-forgejo-nsc-config.sh --rotate-pat` additionally mints a new - Forgejo PAT on the Burrow forge host and refreshes the local intake files. +- `Scripts/seal-forgejo-nsc-secrets.sh --provision` refreshes the local + Namespace token from the logged-in Namespace account, mints a Forgejo PAT, + renders the dispatcher/autoscaler configs, and seals those runtime inputs into + agenix secrets consumed by `burrow-forge`. +- Deploy `burrow-forge` after sealing so the dispatcher and autoscaler consume + the new Namespace credentials. Run it next to the dispatcher: diff --git a/services/forgejo-nsc/autoscaler.example.yaml b/services/forgejo-nsc/autoscaler.example.yaml index 866d3b5..35ba07a 100644 --- a/services/forgejo-nsc/autoscaler.example.yaml +++ b/services/forgejo-nsc/autoscaler.example.yaml @@ -1,6 +1,7 @@ listen: ":8090" dispatcher: url: "http://localhost:8080" + timeout: "2h" instances: - name: burrow @@ -9,7 +10,7 @@ instances: token: "PENDING-FORGEJO-PAT" scope: level: "repository" - owner: "burrow" + owner: "hackclub" name: "burrow" disable_polling: true poll_interval: "30s" diff --git a/services/forgejo-nsc/deploy/autoscaler.yaml b/services/forgejo-nsc/deploy/autoscaler.yaml index 084b076..42ae6c7 100644 --- a/services/forgejo-nsc/deploy/autoscaler.yaml +++ b/services/forgejo-nsc/deploy/autoscaler.yaml @@ -2,6 +2,7 @@ listen: "127.0.0.1:8090" dispatcher: url: "http://127.0.0.1:8080" + timeout: "3h" instances: - name: burrow @@ -10,7 +11,7 @@ instances: token: "PENDING-FORGEJO-PAT" scope: level: "repository" - owner: "burrow" + owner: "hackclub" name: "burrow" disable_polling: false poll_interval: "30s" @@ -25,6 +26,26 @@ instances: min_idle: 0 ttl: "20m" machine_type: "8x16" + - labels: ["namespace-profile-linux-medium-apple-v2"] + min_idle: 0 + ttl: "30m" + machine_type: "8x16" + - labels: ["namespace-profile-linux-testflight"] + min_idle: 0 + ttl: "150m" + machine_type: "8x16" + - labels: ["namespace-profile-macos-large"] + min_idle: 0 + ttl: "60m" + machine_type: "12x28" + - labels: ["namespace-profile-macos-large-apple-v2"] + min_idle: 0 + ttl: "90m" + machine_type: "12x28" + - labels: ["namespace-profile-macos-large-testflight"] + min_idle: 0 + ttl: "150m" + machine_type: "12x28" - labels: ["namespace-profile-windows-large"] min_idle: 0 ttl: "45m" diff --git a/services/forgejo-nsc/deploy/dispatcher.yaml b/services/forgejo-nsc/deploy/dispatcher.yaml index 6d2aac5..28f55ac 100644 --- a/services/forgejo-nsc/deploy/dispatcher.yaml +++ b/services/forgejo-nsc/deploy/dispatcher.yaml @@ -6,7 +6,7 @@ forgejo: token: "PENDING-FORGEJO-PAT" default_scope: level: "repository" - owner: "burrow" + owner: "hackclub" name: "burrow" default_labels: - namespace-profile-linux-medium @@ -15,7 +15,7 @@ forgejo: namespace: nsc_binary: "/run/current-system/sw/bin/nsc" compute_base_url: "https://ord4.compute.namespaceapis.com" - image: "code.forgejo.org/forgejo/runner:3" + image: "code.forgejo.org/forgejo/runner:11" machine_type: "8x16" macos_base_image_id: "tahoe" macos_machine_arch: "arm64" diff --git a/services/forgejo-nsc/internal/autoscaler/config.go b/services/forgejo-nsc/internal/autoscaler/config.go index 7603e67..d252664 100644 --- a/services/forgejo-nsc/internal/autoscaler/config.go +++ b/services/forgejo-nsc/internal/autoscaler/config.go @@ -70,7 +70,7 @@ func LoadConfig(path string) (Config, error) { return Config{}, fmt.Errorf("dispatcher.url is required") } if cfg.Dispatcher.Timeout.Duration == 0 { - cfg.Dispatcher.Timeout = config.Duration{Duration: 15 * time.Second} + cfg.Dispatcher.Timeout = config.Duration{Duration: 2 * time.Hour} } if len(cfg.Instances) == 0 { return Config{}, fmt.Errorf("at least one instance must be configured") diff --git a/services/forgejo-nsc/internal/nsc/dispatcher.go b/services/forgejo-nsc/internal/nsc/dispatcher.go index 49cb4ec..33721b6 100644 --- a/services/forgejo-nsc/internal/nsc/dispatcher.go +++ b/services/forgejo-nsc/internal/nsc/dispatcher.go @@ -284,22 +284,28 @@ func instanceStopped(output string) bool { if len(payload) == 0 { return false } + seenTerminalState := false for _, entry := range payload { + if len(entry.PerResource) == 0 { + return false + } for _, target := range entry.PerResource { if target.Tombstone != "" { + seenTerminalState = true return true } if len(target.Container) == 0 { - continue + return false } for _, container := range target.Container { if container.Status != "stopped" && container.TerminatedAt == "" { return false } + seenTerminalState = true } } } - return true + return seenTerminalState } func (d *Dispatcher) waitForInstanceStop(ctx context.Context, runnerName, instanceID string, timeout time.Duration) bool { diff --git a/services/forgejo-nsc/internal/nsc/dispatcher_test.go b/services/forgejo-nsc/internal/nsc/dispatcher_test.go new file mode 100644 index 0000000..bcf450e --- /dev/null +++ b/services/forgejo-nsc/internal/nsc/dispatcher_test.go @@ -0,0 +1,33 @@ +package nsc + +import "testing" + +func TestInstanceStoppedRequiresObservedTerminalState(t *testing.T) { + t.Parallel() + + cases := []struct { + name string + output string + want bool + }{ + {name: "empty output", output: "", want: false}, + {name: "empty response", output: "[]", want: false}, + {name: "no resources yet", output: `[{"per_resource":{}}]`, want: false}, + {name: "resource without containers", output: `[{"per_resource":{"runner":{}}}]`, want: false}, + {name: "running container", output: `[{"per_resource":{"runner":{"container":[{"status":"running"}]}}}]`, want: false}, + {name: "stopped container", output: `[{"per_resource":{"runner":{"container":[{"status":"stopped"}]}}}]`, want: true}, + {name: "terminated container", output: `[{"per_resource":{"runner":{"container":[{"status":"running","terminated_at":"2026-06-07T15:00:00Z"}]}}}]`, want: true}, + {name: "tombstone", output: `[{"per_resource":{"runner":{"tombstone":"destroyed"}}}]`, want: true}, + } + + for _, tc := range cases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + got := instanceStopped(tc.output) + if got != tc.want { + t.Fatalf("instanceStopped(%s) = %v, want %v", tc.output, got, tc.want) + } + }) + } +} diff --git a/services/forgejo-nsc/internal/nsc/macos.go b/services/forgejo-nsc/internal/nsc/macos.go index 9bf3837..05324eb 100644 --- a/services/forgejo-nsc/internal/nsc/macos.go +++ b/services/forgejo-nsc/internal/nsc/macos.go @@ -151,6 +151,14 @@ func readNSCBearerToken() (string, error) { return trimmed, nil } +func macosRunnerWorkDir(configured string) string { + workdir := strings.TrimSpace(configured) + if workdir == "" || strings.HasPrefix(workdir, "/var/lib/") { + return "/tmp/forgejo-runner" + } + return workdir +} + func parseMachineTypeCPUxMemGB(machineType string) (vcpu int32, memoryMB int32, err error) { parts := strings.Split(machineType, "x") if len(parts) != 2 { @@ -183,10 +191,7 @@ func (d *Dispatcher) launchMacOSRunner(ctx context.Context, runnerName string, r httpClient := &http.Client{Timeout: 60 * time.Second} client := computev1betaconnect.NewComputeServiceClient(httpClient, d.opts.ComputeBaseURL) - workdir := d.opts.WorkDir - if strings.TrimSpace(workdir) == "" { - workdir = "/tmp/forgejo-runner" - } + workdir := macosRunnerWorkDir(d.opts.WorkDir) env := map[string]string{ "FORGEJO_INSTANCE_URL": req.InstanceURL, diff --git a/services/forgejo-nsc/internal/nsc/macos_nsc.go b/services/forgejo-nsc/internal/nsc/macos_nsc.go index c22fadb..b9b9a1b 100644 --- a/services/forgejo-nsc/internal/nsc/macos_nsc.go +++ b/services/forgejo-nsc/internal/nsc/macos_nsc.go @@ -52,6 +52,21 @@ func normalizeMacOSNSCMachineType(machineType string) (normalized string, change return normalized, changed, nil } +type macosNSCAttemptConfig struct { + waitTimeout time.Duration + createTimeout time.Duration +} + +func macosNSCAttemptConfigFor(index int, attempts []macosNSCAttemptConfig) macosNSCAttemptConfig { + if len(attempts) == 0 { + return macosNSCAttemptConfig{} + } + if index < len(attempts) { + return attempts[index] + } + return attempts[len(attempts)-1] +} + func (d *Dispatcher) launchMacOSRunnerViaNSC(ctx context.Context, runnerName string, req LaunchRequest, ttl time.Duration, machineType string) error { if machineType == "" { return errors.New("machine_type is required for macos runners") @@ -92,17 +107,13 @@ func (d *Dispatcher) launchMacOSRunnerViaNSC(ctx context.Context, runnerName str } candidates = uniq - type attemptCfg struct { - waitTimeout time.Duration - createTimeout time.Duration - } - attempts := []attemptCfg{ + attempts := []macosNSCAttemptConfig{ {waitTimeout: 6 * time.Minute, createTimeout: 8 * time.Minute}, {waitTimeout: 4 * time.Minute, createTimeout: 6 * time.Minute}, {waitTimeout: 3 * time.Minute, createTimeout: 5 * time.Minute}, } - createInstance := func(mt string, a attemptCfg) (instanceID string, out string, err error) { + createInstance := func(mt string, a macosNSCAttemptConfig) (instanceID string, out string, err error) { tmpDir, err := os.MkdirTemp("", "forgejo-nsc-macos-*") if err != nil { return "", "", fmt.Errorf("mktemp: %w", err) @@ -173,10 +184,7 @@ func (d *Dispatcher) launchMacOSRunnerViaNSC(ctx context.Context, runnerName str lastErr error ) for i, mt := range candidates { - a := attempts[i] - if i >= len(attempts) { - a = attempts[len(attempts)-1] - } + a := macosNSCAttemptConfigFor(i, attempts) d.log.Info("launching Namespace macos runner via nsc", "runner", runnerName, @@ -296,9 +304,7 @@ func (d *Dispatcher) destroyNSCInstance(ctx context.Context, runnerName, instanc } func macosBootstrapWrapperScript(runnerName string, req LaunchRequest, executor, workdir string) string { - if strings.TrimSpace(workdir) == "" { - workdir = "/tmp/forgejo-runner" - } + workdir = macosRunnerWorkDir(workdir) // Pass all values via stdin script so secrets do not appear in the nsc ssh argv. env := map[string]string{ diff --git a/services/forgejo-nsc/internal/nsc/macos_nsc_test.go b/services/forgejo-nsc/internal/nsc/macos_nsc_test.go new file mode 100644 index 0000000..025b52c --- /dev/null +++ b/services/forgejo-nsc/internal/nsc/macos_nsc_test.go @@ -0,0 +1,26 @@ +package nsc + +import ( + "testing" + "time" +) + +func TestMacOSNSCAttemptConfigForReusesLastFallback(t *testing.T) { + attempts := []macosNSCAttemptConfig{ + {waitTimeout: time.Minute, createTimeout: 2 * time.Minute}, + {waitTimeout: 30 * time.Second, createTimeout: time.Minute}, + } + + got := macosNSCAttemptConfigFor(3, attempts) + want := attempts[len(attempts)-1] + if got != want { + t.Fatalf("macosNSCAttemptConfigFor(3) = %+v, want %+v", got, want) + } +} + +func TestMacOSNSCAttemptConfigForEmpty(t *testing.T) { + got := macosNSCAttemptConfigFor(0, nil) + if got != (macosNSCAttemptConfig{}) { + t.Fatalf("macosNSCAttemptConfigFor(0, nil) = %+v, want zero value", got) + } +} diff --git a/services/forgejo-nsc/internal/nsc/macos_test.go b/services/forgejo-nsc/internal/nsc/macos_test.go new file mode 100644 index 0000000..28fe86b --- /dev/null +++ b/services/forgejo-nsc/internal/nsc/macos_test.go @@ -0,0 +1,25 @@ +package nsc + +import "testing" + +func TestMacOSRunnerWorkDirUsesWritableEphemeralPath(t *testing.T) { + cases := []struct { + name string + configured string + want string + }{ + {name: "empty", configured: "", want: "/tmp/forgejo-runner"}, + {name: "linux var state", configured: "/var/lib/forgejo-runner", want: "/tmp/forgejo-runner"}, + {name: "custom tmp", configured: "/tmp/custom-runner", want: "/tmp/custom-runner"}, + {name: "home path", configured: "/Users/runner/forgejo-runner", want: "/Users/runner/forgejo-runner"}, + } + + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + got := macosRunnerWorkDir(tc.configured) + if got != tc.want { + t.Fatalf("macosRunnerWorkDir(%q) = %q, want %q", tc.configured, got, tc.want) + } + }) + } +} diff --git a/services/grafana/dashboards/burrow-overview.json b/services/grafana/dashboards/burrow-overview.json new file mode 100644 index 0000000..84b4c33 --- /dev/null +++ b/services/grafana/dashboards/burrow-overview.json @@ -0,0 +1,139 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": null, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 1, + "options": { + "code": { + "language": "plaintext", + "showLineNumbers": false, + "showMiniMap": false + }, + "content": "# Burrow Operations\n\nGrafana is managed by NixOS for service/auth and OpenTofu for API-owned folders and dashboards.\n\nStart here after deploys to add service-specific panels as data sources come online.", + "mode": "markdown" + }, + "pluginVersion": "12.3.0", + "title": "Overview", + "type": "text" + }, + { + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 6 + }, + "id": 2, + "options": { + "code": { + "language": "plaintext", + "showLineNumbers": false, + "showMiniMap": false + }, + "content": "## Runtime Checks\n\n- `grafana.service` active\n- `https://graphs.burrow.net/login` reachable\n- Authentik generic OAuth login returns to `/login/generic_oauth`\n- OpenTofu dashboard import or apply succeeds", + "mode": "markdown" + }, + "pluginVersion": "12.3.0", + "title": "Readiness", + "type": "text" + }, + { + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 6 + }, + "id": 3, + "options": { + "code": { + "language": "plaintext", + "showLineNumbers": false, + "showMiniMap": false + }, + "content": "## Ownership\n\nNix owns service startup, SSO, reverse proxy, and secrets.\n\nOpenTofu owns API-created folders and dashboards so visual iteration does not require a host switch.", + "mode": "markdown" + }, + "pluginVersion": "12.3.0", + "title": "Control Plane", + "type": "text" + } + ], + "refresh": "", + "schemaVersion": 39, + "style": "dark", + "tags": [ + "burrow", + "operations" + ], + "templating": { + "list": [] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": {}, + "timezone": "browser", + "title": "Burrow Overview", + "uid": "burrow-overview", + "version": 1, + "weekStart": "" +} diff --git a/services/grafana/dashboards/headscale.json b/services/grafana/dashboards/headscale.json new file mode 100644 index 0000000..12eb33e --- /dev/null +++ b/services/grafana/dashboards/headscale.json @@ -0,0 +1,423 @@ +{ + "annotations": { + "list": [] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "mappings": [ + { + "options": { + "0": { + "text": "down" + }, + "1": { + "text": "up" + } + }, + "type": "value" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 6, + "x": 0, + "y": 0 + }, + "id": 1, + "options": { + "colorMode": "background", + "graphMode": "none", + "justifyMode": "center", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "value_and_name", + "wideLayout": true + }, + "pluginVersion": "11.0.0", + "targets": [ + { + "expr": "up{job=\"$job\"}", + "legendFormat": "headscale scrape", + "refId": "A" + } + ], + "title": "Scrape", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "mappings": [ + { + "options": { + "0": { + "text": "inactive" + }, + "1": { + "text": "active" + } + }, + "type": "value" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 6, + "x": 6, + "y": 0 + }, + "id": 2, + "options": { + "colorMode": "background", + "graphMode": "none", + "justifyMode": "center", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "value_and_name", + "wideLayout": true + }, + "pluginVersion": "11.0.0", + "targets": [ + { + "expr": "max(node_systemd_unit_state{name=\"headscale.service\",state=\"active\"}) or vector(0)", + "legendFormat": "headscale service", + "refId": "A" + } + ], + "title": "Service", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 6, + "x": 12, + "y": 0 + }, + "id": 3, + "options": { + "colorMode": "none", + "graphMode": "area", + "justifyMode": "center", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "value_and_name", + "wideLayout": true + }, + "pluginVersion": "11.0.0", + "targets": [ + { + "expr": "headscale_nodes_total or headscale_machine_count or headscale_node_count or vector(0)", + "legendFormat": "nodes", + "refId": "A" + } + ], + "title": "Tailnet Nodes", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "unit": "reqps" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 6, + "x": 18, + "y": 0 + }, + "id": 4, + "options": { + "colorMode": "none", + "graphMode": "area", + "justifyMode": "center", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "value_and_name", + "wideLayout": true + }, + "pluginVersion": "11.0.0", + "targets": [ + { + "expr": "sum(rate(headscale_http_requests_total[5m])) or vector(0)", + "legendFormat": "http requests", + "refId": "A" + } + ], + "title": "HTTP Rate", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "custom": { + "drawStyle": "line", + "fillOpacity": 12, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "showPoints": "never", + "spanNulls": false + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 4 + }, + "id": 5, + "options": { + "legend": { + "calcs": [ + "lastNotNull" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "expr": "headscale_nodes_total or headscale_machine_count or headscale_node_count or vector(0)", + "legendFormat": "nodes", + "refId": "A" + } + ], + "title": "Tailnet Node Count", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "custom": { + "drawStyle": "line", + "fillOpacity": 12, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "showPoints": "never", + "spanNulls": false + }, + "unit": "reqps" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 4 + }, + "id": 6, + "options": { + "legend": { + "calcs": [ + "lastNotNull" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "expr": "sum by (code,method) (rate(headscale_http_requests_total[5m])) or vector(0)", + "legendFormat": "{{method}} {{code}}", + "refId": "A" + } + ], + "title": "Headscale HTTP Requests", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "inspect": false + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 12 + }, + "id": 7, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true + }, + "targets": [ + { + "expr": "max by (name,state) (node_systemd_unit_state{name=~\"headscale.service|tailscaled.service\",state=~\"active|failed|activating\"})", + "format": "table", + "instant": true, + "refId": "A" + } + ], + "title": "Tailnet Service Units", + "type": "table" + } + ], + "refresh": "30s", + "schemaVersion": 39, + "tags": [ + "burrow", + "headscale", + "tailnet" + ], + "templating": { + "list": [ + { + "current": { + "selected": false, + "text": "headscale", + "value": "headscale" + }, + "hide": 2, + "name": "job", + "query": "headscale", + "type": "constant" + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": {}, + "timezone": "browser", + "title": "Burrow Headscale", + "uid": "burrow-headscale", + "version": 1, + "weekStart": "" +} diff --git a/services/grafana/dashboards/observability.json b/services/grafana/dashboards/observability.json new file mode 100644 index 0000000..344f44d --- /dev/null +++ b/services/grafana/dashboards/observability.json @@ -0,0 +1,477 @@ +{ + "annotations": { + "list": [] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "mappings": [ + { + "options": { + "0": { + "text": "down" + }, + "1": { + "text": "up" + } + }, + "type": "value" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 0, + "y": 0 + }, + "id": 1, + "options": { + "displayMode": "gradient", + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "minVizHeight": 10, + "minVizWidth": 0, + "namePlacement": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showUnfilled": true, + "sizing": "auto", + "valueMode": "color" + }, + "pluginVersion": "11.0.0", + "targets": [ + { + "expr": "up{job=~\"prometheus|grafana|headscale|otel-collector|jaeger|node|systemd|tailscale|garage\"}", + "legendFormat": "{{job}}", + "refId": "A" + } + ], + "title": "Scrape Health", + "type": "bargauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "mappings": [ + { + "options": { + "0": { + "text": "inactive" + }, + "1": { + "text": "active" + } + }, + "type": "value" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 8, + "y": 0 + }, + "id": 2, + "options": { + "displayMode": "gradient", + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "minVizHeight": 10, + "minVizWidth": 0, + "namePlacement": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showUnfilled": true, + "sizing": "auto", + "valueMode": "color" + }, + "pluginVersion": "11.0.0", + "targets": [ + { + "expr": "max by (name) (node_systemd_unit_state{name=~\"grafana.service|prometheus.service|opentelemetry-collector.service|podman-burrow-jaeger.service|headscale.service|tailscaled.service|forgejo.service\",state=\"active\"})", + "legendFormat": "{{name}}", + "refId": "A" + } + ], + "title": "Service State", + "type": "bargauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 16, + "y": 0 + }, + "id": 3, + "options": { + "colorMode": "none", + "graphMode": "area", + "justifyMode": "center", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "value_and_name", + "wideLayout": true + }, + "pluginVersion": "11.0.0", + "targets": [ + { + "expr": "sum(otelcol_receiver_accepted_spans) or sum(otelcol_receiver_refused_spans) or vector(0)", + "legendFormat": "collector spans", + "refId": "A" + } + ], + "title": "OTLP Spans", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "custom": { + "drawStyle": "line", + "fillOpacity": 12, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "showPoints": "never", + "spanNulls": false + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 6 + }, + "id": 4, + "options": { + "legend": { + "calcs": [ + "lastNotNull" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "expr": "sum by (receiver,transport) (rate(otelcol_receiver_accepted_spans[5m])) or vector(0)", + "legendFormat": "{{receiver}} {{transport}}", + "refId": "A" + }, + { + "expr": "sum by (exporter) (rate(otelcol_exporter_sent_spans[5m])) or vector(0)", + "legendFormat": "exported {{exporter}}", + "refId": "B" + } + ], + "title": "OpenTelemetry Trace Flow", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "custom": { + "drawStyle": "line", + "fillOpacity": 12, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "showPoints": "never", + "spanNulls": false + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 6 + }, + "id": 5, + "options": { + "legend": { + "calcs": [ + "lastNotNull" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "expr": "sum(rate(jaeger_collector_spans_received_total[5m])) or sum(rate(jaeger_collector_traces_received_total[5m])) or vector(0)", + "legendFormat": "jaeger received", + "refId": "A" + }, + { + "expr": "sum(rate(jaeger_query_requests_total[5m])) or vector(0)", + "legendFormat": "jaeger queries", + "refId": "B" + } + ], + "title": "Jaeger Activity", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "custom": { + "drawStyle": "line", + "fillOpacity": 12, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "showPoints": "never", + "spanNulls": false + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 14 + }, + "id": 6, + "options": { + "legend": { + "calcs": [ + "lastNotNull" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "expr": "1 - avg by (instance) (rate(node_cpu_seconds_total{mode=\"idle\"}[5m]))", + "legendFormat": "{{instance}}", + "refId": "A" + } + ], + "title": "Host CPU", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "fieldConfig": { + "defaults": { + "custom": { + "drawStyle": "line", + "fillOpacity": 12, + "lineInterpolation": "linear", + "lineWidth": 2, + "pointSize": 5, + "showPoints": "never", + "spanNulls": false + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 14 + }, + "id": 7, + "options": { + "legend": { + "calcs": [ + "lastNotNull" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "expr": "1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)", + "legendFormat": "{{instance}}", + "refId": "A" + } + ], + "title": "Host Memory", + "type": "timeseries" + }, + { + "datasource": { + "type": "jaeger", + "uid": "jaeger" + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 22 + }, + "id": 8, + "options": { + "showHeader": true + }, + "targets": [ + { + "datasource": { + "type": "jaeger", + "uid": "jaeger" + }, + "limit": 20, + "operation": "", + "queryType": "search", + "refId": "A", + "service": "burrow" + } + ], + "title": "Recent Burrow Traces", + "type": "traces" + } + ], + "refresh": "30s", + "schemaVersion": 39, + "tags": [ + "burrow", + "observability", + "opentelemetry", + "jaeger" + ], + "templating": { + "list": [] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": {}, + "timezone": "browser", + "title": "Burrow Observability", + "uid": "burrow-observability", + "version": 1, + "weekStart": "" +} diff --git a/services/mcp-hub/README.md b/services/mcp-hub/README.md new file mode 100644 index 0000000..4b1c2a2 --- /dev/null +++ b/services/mcp-hub/README.md @@ -0,0 +1,25 @@ +# Burrow MCP Hub Extraction + +This directory is the in-repo extraction plan for a dedicated MCP hub repository. + +Target repository: + +```text +compatible.systems/burrow/mcp-hub +``` + +The hub should expose Burrow-operated tools for: + +- Authentik users, groups, OIDC, SAML, SCIM, and WIF applications +- OpenBao mounts, policies, AppRole, and secret-read workflows +- Google KMS key catalog, public-key export, and signing readiness +- Forgejo workflow dispatch, runner identity, and Namespace runner status +- Grafana dashboard and alert checks +- Jitsi meeting readiness and service health +- mail and webmail readiness after the Stalwart phase starts +- release signing, store upload readiness, and distribution metadata checks +- agent identity inventory derived from `contributors.nix` + +The hub must keep identity and authorization explicit. Agent identities should be +named, attributable, and backed by Authentik/WIF or OpenBao AppRole rather than +static shared tokens. diff --git a/site/pages/index.tsx b/site/pages/index.tsx index 20d7f1b..0356c17 100644 --- a/site/pages/index.tsx +++ b/site/pages/index.tsx @@ -18,19 +18,6 @@ function ExternalLinkIcon() { ); } -function GithubIcon() { - return ( - - ); -} - export default function Page() { const [chevron, setChevron] = useState(false); const menuButtonRef = useRef(null); @@ -134,10 +121,10 @@ export default function Page() { diff --git a/store-metadata/android/README.md b/store-metadata/android/README.md new file mode 100644 index 0000000..806d885 --- /dev/null +++ b/store-metadata/android/README.md @@ -0,0 +1,22 @@ +# Android Store Metadata + +This directory is the repo-owned home for Android distribution metadata. + +Current state: + +- Kotlin app shell exists under `Android/app`. +- Rust core FFI exists under `crates/burrow-mobile-ffi`. +- full VPN support is not enabled yet. + +Before Play Store upload: + +- implement Android `VpnService` +- complete the Play VPN service declaration +- complete data-safety review +- wire signing through the release signing lane + +Before F-Droid upload: + +- add reproducible metadata +- keep a source-built flavor without proprietary Play dependencies +- document Rust core build inputs and target ABIs diff --git a/store-metadata/android/icon.png b/store-metadata/android/icon.png new file mode 100644 index 0000000..c5997ae Binary files /dev/null and b/store-metadata/android/icon.png differ diff --git a/store-metadata/app-store-connect/README.md b/store-metadata/app-store-connect/README.md new file mode 100644 index 0000000..e565b9a --- /dev/null +++ b/store-metadata/app-store-connect/README.md @@ -0,0 +1,21 @@ +# App Store Connect Metadata + +This directory is the repo-owned home for Burrow App Store Connect metadata. + +The release upload lane expects dedicated App Store Connect API credentials +sealed with agenix: + +- `secrets/apple/appstore-connect.env.age` + +That single secret contains the key ID, issuer ID, and base64-encoded `.p8`. +CI decrypts it into a temporary App Store Connect key file, syncs provisioning +profiles from App Store Connect, and then uploads `.ipa`/`.pkg` artifacts. +Forgejo secrets should only provide the runner age identity fallback, not the +App Store key itself. + +The initial release pipeline can upload `.ipa` and `.pkg` artifacts once the +Apple build lane produces signed outputs. Internal TestFlight distribution waits +for processing and skips external beta-review submission; App Store Connect then +exposes the valid build through the configured internal tester group. TestFlight +external distribution must remain explicit until review metadata, groups, and +tester policy are complete. diff --git a/store-metadata/app-store-connect/testflight/en-US/beta_app_description.txt b/store-metadata/app-store-connect/testflight/en-US/beta_app_description.txt new file mode 100644 index 0000000..82656b1 --- /dev/null +++ b/store-metadata/app-store-connect/testflight/en-US/beta_app_description.txt @@ -0,0 +1 @@ +Burrow is a VPN client for infrastructure operated by the Burrow project. diff --git a/store-metadata/app-store-connect/testflight/en-US/feedback_email.txt b/store-metadata/app-store-connect/testflight/en-US/feedback_email.txt new file mode 100644 index 0000000..2de2c1a --- /dev/null +++ b/store-metadata/app-store-connect/testflight/en-US/feedback_email.txt @@ -0,0 +1 @@ +contact@burrow.net diff --git a/store-metadata/app-store-connect/testflight/review/contact_email.txt b/store-metadata/app-store-connect/testflight/review/contact_email.txt new file mode 100644 index 0000000..2de2c1a --- /dev/null +++ b/store-metadata/app-store-connect/testflight/review/contact_email.txt @@ -0,0 +1 @@ +contact@burrow.net diff --git a/store-metadata/app-store-connect/testflight/review/contact_first_name.txt b/store-metadata/app-store-connect/testflight/review/contact_first_name.txt new file mode 100644 index 0000000..d7bed7b --- /dev/null +++ b/store-metadata/app-store-connect/testflight/review/contact_first_name.txt @@ -0,0 +1 @@ +Burrow diff --git a/store-metadata/app-store-connect/testflight/review/contact_last_name.txt b/store-metadata/app-store-connect/testflight/review/contact_last_name.txt new file mode 100644 index 0000000..9136ac3 --- /dev/null +++ b/store-metadata/app-store-connect/testflight/review/contact_last_name.txt @@ -0,0 +1 @@ +Operator diff --git a/store-metadata/app-store-connect/testflight/review/demo_account_required.txt b/store-metadata/app-store-connect/testflight/review/demo_account_required.txt new file mode 100644 index 0000000..27ba77d --- /dev/null +++ b/store-metadata/app-store-connect/testflight/review/demo_account_required.txt @@ -0,0 +1 @@ +true diff --git a/store-metadata/app-store-connect/testflight/review/notes.txt b/store-metadata/app-store-connect/testflight/review/notes.txt new file mode 100644 index 0000000..2e500d1 --- /dev/null +++ b/store-metadata/app-store-connect/testflight/review/notes.txt @@ -0,0 +1 @@ +Use the dedicated Burrow test account supplied out of band for review. The app talks to the local Burrow daemon over its gRPC boundary. diff --git a/store-metadata/flatpak/README.md b/store-metadata/flatpak/README.md new file mode 100644 index 0000000..8733e31 --- /dev/null +++ b/store-metadata/flatpak/README.md @@ -0,0 +1,8 @@ +# Flatpak Metadata + +Flatpak is a desktop GUI distribution lane for Burrow. + +The Flatpak package should not be considered a complete VPN backend unless a +host daemon or privileged helper is installed and verified. The GUI can manage +configuration and status through a constrained local API, while TUN, routes, +DNS, and firewall state remain outside the sandbox. diff --git a/store-metadata/sparkle/README.md b/store-metadata/sparkle/README.md new file mode 100644 index 0000000..bc446ed --- /dev/null +++ b/store-metadata/sparkle/README.md @@ -0,0 +1,30 @@ +# Sparkle Release Channel + +Burrow stages Sparkle files under `dist/builds//sparkle//` and +publishes them through `.forgejo/workflows/publish-store-uploads.yml`. + +The current implementation prepares the channel and public pointer layout: + +- `sparkle//appcast.xml` +- `sparkle/appcast.xml` +- `sparkle/default/` +- `sparkle/main-channel.txt` + +Sparkle enclosure signatures can be produced with the non-exportable +`sparkle-ed25519` Google KMS key: + +```sh +Scripts/sparkle/sign-appcast-kms.py \ + --appcast dist/builds//sparkle//appcast.xml \ + --artifact-dir dist/builds//sparkle/ +``` + +The public EdDSA key embedded in macOS release builds is: + +```text +Myv9ZNZT6YGKMtMezh52ra4WqaeEKc4VlvVU0evhJeI= +``` + +The build lane only signs appcasts when `BURROW_SPARKLE_SIGN_WITH_KMS=true`. +The live Google KMS key uses `EC_SIGN_ED25519` with software protection because +Google KMS rejects Ed25519 for HSM protection level.