name: Release on: push: tags: [ 'v*' ] workflow_dispatch: # Shared by both jobs. env: # Force any JS action still declaring node20 onto Node.js 24 (GitHub # deprecated node20 runners 2026-06-02). All pinned actions are node24-native # as of the v7/v8/v3 bumps; kept as a safety net for future additions. FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" # Least-privilege floor. verify-ci/test/build only read; publish raises its # own block for the release upload + provenance. permissions: contents: read jobs: # Skip a full ~16 min unit-test re-run when CI has already # verified the tagged commit on main — same commit, same test invocation # would produce the same result. Falls through to a real test run if # CI hasn't reported yet (rare: tag created without a prior main push) # or reported anything other than success. verify-ci: runs-on: ubuntu-latest timeout-minutes: 5 outputs: ci-passed: ${{ steps.check.outputs.passed }} steps: - name: Check CI status on tagged commit id: check env: GH_TOKEN: ${{ github.token }} run: | # Ask the CI workflow directly whether it passed on THIS commit. # # Do NOT use /commits/{sha}/status: that endpoint aggregates the legacy # Statuses API, and GitHub Actions publishes *check runs*, not statuses. # This repo has zero statuses, so it answered "pending" for every commit # ever tagged — meaning this job never once skipped the test re-run it # exists to skip, and every release paid ~16 minutes for nothing. # # /commits/{sha}/check-runs is the check-run equivalent but includes this # very workflow's own in-flight runs, so it can never be all-green either. # Filtering the CI workflow's completed runs by head_sha asks exactly the # question we mean: "did CI pass on this commit?" conclusion=$(gh api \ "repos/${GITHUB_REPOSITORY}/actions/workflows/ci.yml/runs?head_sha=${GITHUB_SHA}&status=completed" \ --jq '.workflow_runs[0].conclusion // "none"' 2>/dev/null || echo "unknown") echo "CI conclusion for ${GITHUB_SHA:0:7}: ${conclusion}" if [ "$conclusion" = "success" ]; then echo "passed=true" >> "$GITHUB_OUTPUT" else # Fail safe: anything else (no CI run yet, failure, API trouble) runs # the tests for real rather than shipping on an unverified commit. echo "passed=false" >> "$GITHUB_OUTPUT" fi # Unit tests run once — flavor-agnostic, not worth duplicating per ABI. # Skipped entirely when CI already reported success for this SHA. # Runs on the free 4-core runner; larger runners are paid-tier and were # silently queueing release builds once that budget was exhausted. test: needs: verify-ci if: needs.verify-ci.outputs.ci-passed != 'true' runs-on: ubuntu-latest timeout-minutes: 45 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: submodules: false # Unit tests don't compile the Wayland native build, so we skip # `wayland-android` entirely — its freedesktop submodule chain # (cairo, mesa-drm, fontconfig, libinput) goes through # gitlab.freedesktop.org which intermittently 5xxs and breaks # this job for non-test reasons. The build job below still does # the full recursive init. - uses: ./.github/actions/init-submodules-with-retry with: paths: | termlib mosh-kotlin et-kotlin spice-kotlin reticulum-kt rnsh-kt build-proot/proot-termux prns - uses: ./.github/actions/setup-toolchain - name: Run release unit tests run: ./gradlew testDebugUnitTest -PskipWaylandNatives=true -PskipFfmpegNatives=true env: KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} KEY_ALIAS: ${{ secrets.KEY_ALIAS }} KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} # One signed APK + AAB per ABI in parallel — roughly halves wall time vs # running all four Gradle tasks sequentially in a single job. # # `needs: [verify-ci, test]` with `if: !cancelled() && (test skipped OR # test succeeded)` lets build proceed when CI has already greenlit the # SHA (test was skipped) or when a fresh test run passes. build: needs: [verify-ci, test] if: | !cancelled() && (needs.verify-ci.outputs.ci-passed == 'true' || needs.test.result == 'success') # Free 4-core runner — arm64 + x64 build jobs run in parallel (matrix). # Paid larger-tier runners silently queue forever once the Actions # spending cap is hit, so we use the free tier and eat the extra build # time. Timeout is generous to allow the full Rust/Go/Gradle compile # on 4 cores (observed: ~60 min per ABI worst-case). runs-on: ubuntu-latest timeout-minutes: 90 strategy: fail-fast: false matrix: include: - { abi: arm64, variant: Arm64 } - { abi: x64, variant: X64 } - { abi: armv7, variant: Armv7 } permissions: contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: submodules: false - uses: ./.github/actions/init-submodules-with-retry - uses: ./.github/actions/setup-toolchain - name: Decode release keystore run: echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > haven-release.jks # -PtargetAbi lets core/wayland's buildWaylandNatives skip on the ABIs it # has no binaries for. The five wayland natives are arm64-v8a only, so the # x64 and armv7 jobs would otherwise spend ~20 minutes each building # libraries they never package (#493). # Both flavours ship from GitHub: `full` is the complete app and the # only one F-Droid builds, `terminal` drops the desktop and media # native payload for a ~20 MB smaller download (#510). The AAB stays # full-only — it exists for store distribution, which the stripped # flavour is not part of. # The MEMSAMPLE loop prints host memory every 30s alongside the Gradle # output. The v5.87.36 release attempts died five times in a row with # "runner has received a shutdown signal" 26-31 min in (mid-minify) and # nothing in the log to attribute it; this puts the ground truth in the # log up to the moment of death, since evicted runners upload nothing # afterwards. - name: Build signed APK + AAB (${{ matrix.abi }}) run: | ( while true; do echo "MEMSAMPLE $(date -u +%H:%M:%S) $(free -m | awk '/^Mem:/{print "used="$3"M avail="$7"M"}')" sleep 30 done ) & MEMSAMPLER=$! # The two flavours run as SEQUENTIAL Gradle invocations, not one. # With both in a single invocation, the terminal flavour's R8 ran # concurrently with the full flavour's bundling/signing, and that # overlap is where both armv7 host-OOM deaths sat (MEMSAMPLE showed # 15.2G used of ~16G, 625M available at the kill). One R8/bundle # peak at a time keeps the host inside its memory. set +e ./gradlew :app:assemble${{ matrix.variant }}FullRelease \ :app:bundle${{ matrix.variant }}FullRelease \ -PtargetAbi=${{ matrix.abi }} rc=$? if [ "$rc" = "0" ]; then # Restart the daemons between the flavours. A Gradle daemon never # returns grown heap to the OS, so after the full flavour the host # sat at ~14.6G used and the terminal flavour's R8/lintVital spike # (15.65G used, 335M available, samples logging late = thrashing) # killed the arm64 and armv7 runners even with the flavours # serialized. A fresh daemon starts small and the terminal flavour # compiles mostly from cache. The Kotlin daemon outlives --stop on # its own idle timer, so it is killed explicitly. ./gradlew --stop pkill -f KotlinCompileDaemon || true sleep 5 ./gradlew :app:assemble${{ matrix.variant }}TerminalRelease \ -PtargetAbi=${{ matrix.abi }} rc=$? fi kill "$MEMSAMPLER" 2>/dev/null exit "$rc" env: KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} KEY_ALIAS: ${{ secrets.KEY_ALIAS }} KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} # R8 reflective-class survival check — moved here from CI's per-push # release-r8-smoke job (which now runs on PRs only). This release build # already ran R8 (minify), so the assert is free here and guarantees # every published release is checked even on direct-to-main pushes. # ABI-agnostic (inspects the R8 mapping), so run it once on arm64. - name: Assert reflectively-loaded classes survived R8 if: matrix.abi == 'arm64' run: ./scripts/check-r8-kept-classes.sh # A stale committed .so fails to dlopen on-device and kills every # cage/app-window feature (#469), with nothing failing at build time. # Inspects checked-in binaries only, so run it once. - name: Assert committed native libs resolve their stubs (#469) if: matrix.abi == 'arm64' run: ./scripts/check-native-libs.sh - name: Upload artifacts uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: haven-${{ matrix.abi }}-release path: | app/build/outputs/apk/${{ matrix.abi }}Full/release/haven-*-release.apk app/build/outputs/apk/${{ matrix.abi }}Terminal/release/haven-*-terminal-release.apk app/build/outputs/bundle/${{ matrix.abi }}FullRelease/*.aab if-no-files-found: error retention-days: 7 # Aggregate both ABIs onto a single GitHub release. Splitting this from # build lets the per-ABI jobs run in parallel while the release step # still sees every artifact. publish: needs: build # Must name a status function explicitly. With a bare `if: startsWith(...)`, # GitHub applies an implicit success() over the whole dependency GRAPH — and # once verify-ci greenlights the SHA, `test` is skipped, which makes that # implicit success() false and silently skips publish (nothing ships). `build` # already guards itself this way; publish must too. This path only became # reachable when verify-ci started skipping `test` for the first time. if: | !cancelled() && needs.build.result == 'success' && startsWith(github.ref, 'refs/tags/') # Publish is just artifact download + GitHub Release upload — no heavy # compile work. Keep on the free 4-core runner to avoid spending larger- # runner minutes on ~20 seconds of I/O. runs-on: ubuntu-latest timeout-minutes: 10 # Reviewer-gated: the `signing` Environment (configured in repo settings # with a required reviewer + v*/main restriction) must approve before the # release is published, so no single account can ship unilaterally. environment: signing permissions: contents: write # create the GitHub Release + upload assets id-token: write # OIDC for build-provenance attestation attestations: write # write the provenance attestation steps: # First — checkout runs `git clean`, so it must precede the artifact # downloads or it would wipe release/. Provides CHANGELOG.md + the # extractor script (each job runs on a fresh runner). - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: submodules: false - name: Download arm64 artifacts uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: haven-arm64-release path: release/ - name: Download x64 artifacts uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: haven-x64-release path: release/ - name: Download armv7 artifacts uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: haven-armv7-release path: release/ # Cryptographically tie each binary to this repo + commit + workflow so # downstreams (F-Droid, users) can verify provenance with `gh attestation # verify --repo GlassHaven/Haven`. - name: Attest build provenance uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2 with: subject-path: | release/**/*.apk release/**/*.aab # Publish a flat checksum manifest alongside the assets (asset names are # basenames once on the release, so the manifest uses basenames too). - name: Generate SHA256SUMS run: | : > SHA256SUMS find release -type f \( -name '*.apk' -o -name '*.aab' \) | sort | while read -r f; do printf '%s %s\n' "$(sha256sum "$f" | cut -d' ' -f1)" "$(basename "$f")" >> SHA256SUMS done cat SHA256SUMS # The notes for this tag must already exist in CHANGELOG.md (CI lint # enforces it at version-bump time). Extract that section as the release # body; generate_release_notes still appends the "Full Changelog" link. - name: Extract release notes from CHANGELOG.md run: ./scripts/check-changelog.sh extract "${GITHUB_REF_NAME}" > RELEASE_NOTES.md # #514: someone asked what the "terminal" APKs are, which means the release # page was not answering it. Appended to every release rather than left to # a changelog entry nobody scrolls back to, or an issue nobody finds. - name: Append the which-APK guide run: | cat >> RELEASE_NOTES.md <<'GUIDE' --- ### Which APK? **`haven---release.apk`** — the full app, and what F-Droid carries. If in doubt, take this one. **`haven---terminal-release.apk`** — the same app with the desktop and media parts left out, for people who only use Haven for SSH, terminals, files and storage. Less than half the size on arm64. It drops RDP and SPICE remote desktop, the native Wayland desktop, and ffmpeg — so no media conversion, and no video previews or streaming in the file browser. VNC is kept, so a Linux desktop running inside Haven's guest still works. Both are signed with the same key and carry the same version number, so you can install either over the other without losing connections, keys or your Linux guest. The shared version number does mean an updater will not offer to move you between them — switching is a deliberate download. `` is your device's CPU: `arm64` for essentially every modern phone, `armv7` for older 32-bit devices, `x64` for emulators. GUIDE - name: Create GitHub Release uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3 with: body_path: RELEASE_NOTES.md generate_release_notes: true files: | release/**/*.apk release/**/*.aab SHA256SUMS