Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 23 additions & 21 deletions .github/workflows/test-apk.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
# Compila um APK de teste do ZeroDroid SÓ quando o dono o lança à mão.
# Não publica nada: o APK fica como "artifact" do run e é apagado ao fim de
# 7 dias. É assinado com a chave de RELEASE (os secrets ZERODROID_*), por isso
# instala-se por cima da versão estável sem desinstalar nem voltar a emparelhar.
# Builds a ZeroDroid test APK, only when it is started by hand. Nothing is
# published: the APK is kept as a run artifact for 7 days. It is signed with
# the RELEASE key (the ZERODROID_* secrets), so it installs over the stable
# app without uninstalling or pairing again.
#
# Lançar (no Termux, ou em qualquer sítio com o gh):
# Start it (from Termux, or anywhere with gh):
# gh workflow run test-apk.yml -R SyscallBrain/zerodroid --ref <branch>
# gh workflow run test-apk.yml -R SyscallBrain/zerodroid --ref <branch> -f testes=false
# Seguir e descarregar:
# gh run watch -R SyscallBrain/zerodroid --exit-status
# gh run download -R SyscallBrain/zerodroid --pattern 'zerodroid-*'
# gh workflow run test-apk.yml -R SyscallBrain/zerodroid --ref <branch> -f checks=false
# Follow it and fetch the APK from that same run (the newest run of this
# workflow; gh run download without a run id would ask which run):
# run=$(gh run list -R SyscallBrain/zerodroid -w test-apk.yml -L 1 --json databaseId -q '.[0].databaseId')
# gh run watch "$run" -R SyscallBrain/zerodroid --exit-status
# gh run download "$run" -R SyscallBrain/zerodroid
name: Test APK (manual)

# Único gatilho: o botão "Run workflow" ou o "gh workflow run". Nada de push,
# pull_request ou schedule, por isso nunca corre sozinho.
# The only trigger is "Run workflow" / "gh workflow run": no push,
# pull_request or schedule, so it never starts on its own.
on:
workflow_dispatch:
inputs:
testes:
description: Correr os testes unitários antes de compilar
checks:
description: Run the unit tests before building
type: boolean
default: true

# O token automático do run só pode ler o repo.
permissions:
contents: read
permissions: {}

jobs:
apk:
runs-on: ubuntu-24.04
timeout-minutes: 30
permissions:
contents: read
steps:
- name: Check out source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand All @@ -40,21 +42,21 @@ jobs:
distribution: temurin
java-version: 21

# Instala o Gradle do wrapper, valida o gradle-wrapper.jar e guarda a cache.
# Also validates the checksum of gradle/wrapper/gradle-wrapper.jar.
- uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1

- name: Unit tests
if: inputs.testes
if: inputs.checks
run: ./gradlew testDebugUnitTest

# O keystore vive no secret em base64; é escrito num ficheiro temporário
# do runner só durante o build e apagado logo a seguir.
# The keystore lives base64-encoded in a secret; it is written to the
# runner's temp dir for the build only and deleted right after.
- name: Set up the release signing key
env:
KEYSTORE_BASE64: ${{ secrets.ZERODROID_KEYSTORE_BASE64 }}
run: |
if [ -z "$KEYSTORE_BASE64" ]; then
echo "Falta o secret ZERODROID_KEYSTORE_BASE64: sem ele o APK não instala por cima do estável" >&2
echo "The ZERODROID_KEYSTORE_BASE64 secret is not set; an unsigned APK cannot replace the stable app" >&2
exit 1
fi
printf '%s' "$KEYSTORE_BASE64" | base64 --decode > "$RUNNER_TEMP/release.jks"
Expand Down