mirror of
https://github.com/foxhole-team/foxhole-guard.git
synced 2026-10-21 10:45:41 +02:00
208 lines
8.1 KiB
YAML
208 lines
8.1 KiB
YAML
name: android
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- dev
|
|
pull_request:
|
|
paths:
|
|
- ".github/**"
|
|
- "app/**"
|
|
- "config/**"
|
|
- "core/**"
|
|
- "gradle/**"
|
|
- "scripts/**"
|
|
- "third_party/**"
|
|
- "build.gradle.kts"
|
|
- "settings.gradle.kts"
|
|
- "gradle.properties"
|
|
workflow_dispatch:
|
|
inputs:
|
|
foxcore_smoke_only:
|
|
description: "Only build and verify the pinned FoxCore JNI artifact"
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
security_scan_only:
|
|
description: "Only run secret and dependency vulnerability scans"
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: android-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
verify:
|
|
name: build/unit/security verified
|
|
runs-on: ubuntu-24.04
|
|
# A cold public checkout compiles FoxCore, i2pd and the Tor transports from source, so the timeout must clear GitHub's uncached network.
|
|
timeout-minutes: 90
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
|
|
with:
|
|
submodules: recursive
|
|
persist-credentials: false
|
|
|
|
- name: setup Android and FoxHole Core build
|
|
uses: ./.github/actions/setup-foxcore
|
|
with:
|
|
core-repository: ${{ vars.FOXCORE_REPO || 'foxhole-team/foxhole-core' }}
|
|
|
|
- name: pinned FoxCore native smoke
|
|
if: github.event_name == 'workflow_dispatch' && inputs.foxcore_smoke_only
|
|
run: ./gradlew --no-daemon --console=plain --stacktrace :app:prepareFoxCoreNative
|
|
|
|
# Run the cheap security gates before the cold native build so a policy failure is fast.
|
|
- name: secret scan
|
|
if: github.event_name != 'workflow_dispatch' || inputs.security_scan_only || !inputs.foxcore_smoke_only
|
|
run: scripts/run-gitleaks-scan.sh
|
|
|
|
- name: mandatory dependency vulnerability scan
|
|
if: github.event_name != 'workflow_dispatch' || inputs.security_scan_only || !inputs.foxcore_smoke_only
|
|
run: scripts/run-osv-source-scan.sh
|
|
|
|
- name: verify wrapper
|
|
if: github.event_name != 'workflow_dispatch' || (!inputs.foxcore_smoke_only && !inputs.security_scan_only)
|
|
run: ./gradlew --no-daemon --console=plain --version
|
|
|
|
- name: static analysis, lint, unit tests, and coverage
|
|
if: github.event_name != 'workflow_dispatch' || (!inputs.foxcore_smoke_only && !inputs.security_scan_only)
|
|
run: ./gradlew --no-daemon --console=plain --stacktrace :app:detekt verifyDetektBaseline :app:lintDebug :app:lintRelease :app:lintVitalRelease :app:testDebugUnitTest jacocoDebugUnitTestReport jacocoDebugUnitTestCoverageVerification verifyReleaseBuildConfigDefaults
|
|
|
|
- name: build debug APK
|
|
if: github.event_name != 'workflow_dispatch' || (!inputs.foxcore_smoke_only && !inputs.security_scan_only)
|
|
run: ./gradlew --no-daemon --console=plain --stacktrace :app:assembleDebug
|
|
|
|
release-candidate:
|
|
name: signed release candidate
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
|
|
needs: verify
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 90
|
|
steps:
|
|
- name: checkout verified dev commit
|
|
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
|
|
with:
|
|
submodules: recursive
|
|
persist-credentials: false
|
|
|
|
- name: setup Android and FoxHole Core build
|
|
uses: ./.github/actions/setup-foxcore
|
|
with:
|
|
core-repository: ${{ vars.FOXCORE_REPO || 'foxhole-team/foxhole-core' }}
|
|
|
|
- name: prepare release signing inputs
|
|
shell: bash
|
|
env:
|
|
FOXHOLE_RELEASE_STORE_FILE_B64: ${{ secrets.FOXHOLE_RELEASE_STORE_FILE_B64 }}
|
|
FOXHOLE_RELEASE_STORE_PASSWORD: ${{ secrets.FOXHOLE_RELEASE_STORE_PASSWORD }}
|
|
FOXHOLE_RELEASE_KEY_ALIAS: ${{ secrets.FOXHOLE_RELEASE_KEY_ALIAS }}
|
|
FOXHOLE_RELEASE_KEY_PASSWORD: ${{ secrets.FOXHOLE_RELEASE_KEY_PASSWORD }}
|
|
FOXHOLE_RELEASE_STORE_TYPE: ${{ secrets.FOXHOLE_RELEASE_STORE_TYPE }}
|
|
run: |
|
|
set -euo pipefail
|
|
missing=()
|
|
for secret_name in \
|
|
FOXHOLE_RELEASE_STORE_FILE_B64 \
|
|
FOXHOLE_RELEASE_STORE_PASSWORD \
|
|
FOXHOLE_RELEASE_KEY_ALIAS \
|
|
FOXHOLE_RELEASE_KEY_PASSWORD
|
|
do
|
|
if [[ -z "${!secret_name:-}" ]]; then
|
|
missing+=("$secret_name")
|
|
fi
|
|
done
|
|
if (( ${#missing[@]} > 0 )); then
|
|
printf 'Release signing secrets are required. Missing: %s\n' "${missing[*]}" >&2
|
|
exit 1
|
|
fi
|
|
keystore_path="$RUNNER_TEMP/foxhole-release.p12"
|
|
if ! printf '%s' "$FOXHOLE_RELEASE_STORE_FILE_B64" | base64 --decode > "$keystore_path"; then
|
|
echo "FOXHOLE_RELEASE_STORE_FILE_B64 is not valid base64" >&2
|
|
exit 1
|
|
fi
|
|
chmod 600 "$keystore_path"
|
|
{
|
|
echo "FOXHOLE_RELEASE_STORE_FILE=$keystore_path"
|
|
echo "FOXHOLE_RELEASE_STORE_PASSWORD=$FOXHOLE_RELEASE_STORE_PASSWORD"
|
|
echo "FOXHOLE_RELEASE_KEY_ALIAS=$FOXHOLE_RELEASE_KEY_ALIAS"
|
|
echo "FOXHOLE_RELEASE_KEY_PASSWORD=$FOXHOLE_RELEASE_KEY_PASSWORD"
|
|
echo "FOXHOLE_RELEASE_STORE_TYPE=${FOXHOLE_RELEASE_STORE_TYPE:-PKCS12}"
|
|
} >> "$GITHUB_ENV"
|
|
|
|
- name: resolve published versionCode floor
|
|
id: published
|
|
shell: bash
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
set -euo pipefail
|
|
version_code="$(scripts/package-release-candidate.sh published-code "$GITHUB_REPOSITORY")"
|
|
echo "version_code=$version_code" >> "$GITHUB_OUTPUT"
|
|
|
|
# The only APK assembly; main republishes these exact bytes.
|
|
# AGP cannot build ABI-split APKs and an AAB in one invocation, so the bundle is verified in a second, non-split configuration.
|
|
- name: build and verify signed candidate
|
|
run: |
|
|
./gradlew \
|
|
--no-daemon \
|
|
--console=plain \
|
|
--stacktrace \
|
|
-Pfoxhole.splitApks=true \
|
|
-Pfoxhole.sbom=true \
|
|
"-Pfoxhole.lastUploadedVersionCode=${{ steps.published.outputs.version_code }}" \
|
|
:app:validateReleaseSigningInputs \
|
|
:app:assembleRelease \
|
|
:app:verifyReleaseContainsNativeRuntime \
|
|
:app:verifyReleaseContainsBaselineProfile \
|
|
:app:verifyReleaseBuildConfigDefaults \
|
|
:app:verifyReleaseJniSurface
|
|
./gradlew \
|
|
--no-daemon \
|
|
--console=plain \
|
|
--stacktrace \
|
|
-Pfoxhole.sbom=true \
|
|
"-Pfoxhole.lastUploadedVersionCode=${{ steps.published.outputs.version_code }}" \
|
|
:app:validateReleaseSigningInputs \
|
|
:app:publicReleasePreflight
|
|
|
|
- name: package immutable candidate
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
candidate_dir="$RUNNER_TEMP/foxhole-release-candidate"
|
|
source_tree="$(git rev-parse 'HEAD^{tree}')"
|
|
FOXHOLE_SBOM_PATH=build/reports/cyclonedx/bom.json \
|
|
scripts/package-release-candidate.sh \
|
|
prepare \
|
|
"$candidate_dir" \
|
|
"$GITHUB_SHA" \
|
|
"$source_tree"
|
|
|
|
- name: upload immutable candidate
|
|
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
|
with:
|
|
name: foxhole-app-${{ github.sha }}
|
|
path: ${{ runner.temp }}/foxhole-release-candidate/*
|
|
if-no-files-found: error
|
|
retention-days: 3
|
|
compression-level: 0
|
|
|
|
# Mapping and native symbols stay authenticated Actions artifacts, never attached to the public release.
|
|
- name: retain private diagnostics
|
|
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
|
with:
|
|
name: foxhole-private-diagnostics-${{ github.sha }}
|
|
path: |
|
|
app/build/outputs/mapping/release/mapping.txt
|
|
app/build/outputs/mapping/publicRelease/mapping.txt
|
|
app/build/outputs/native-debug-symbols/publicRelease/publicRelease-native-symbols.zip
|
|
if-no-files-found: error
|
|
retention-days: 3
|