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 env: FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" 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@11d5960a326750d5838078e36cf38b85af677262 # v4 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@11d5960a326750d5838078e36cf38b85af677262 # v4 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@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 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@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 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