mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-10-31 16:22:49 +00:00
128 lines
6.4 KiB
YAML
128 lines
6.4 KiB
YAML
name: APK Build
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
merge_group:
|
|
push:
|
|
branches: [ develop ]
|
|
|
|
permissions:
|
|
# Private fork: actions/checkout needs contents:read to clone. Upstream is public,
|
|
# where an empty token can still read the repo, so an empty permissions block works there and
|
|
# fails here with `fatal: repository not found`.
|
|
contents: read
|
|
|
|
# Enrich gradle.properties for CI/CD
|
|
env:
|
|
# Reduced from upstream's -Xmx8g / 4 GB Kotlin daemon for the self-hosted runners.
|
|
# Each incus container reports 48 GiB and 8 cores, so a single build has ample room —
|
|
# but the containers are oversubscribed against their host, and two concurrent heavy
|
|
# Gradle jobs get their daemons SIGKILLed ("the daemon has disappeared", no
|
|
# OutOfMemoryError, no heap dump). Running the same job alone succeeds. Lower heaps
|
|
# make two builds likelier to coexist; the real fix is sizing the containers to the
|
|
# host. See the "Report runner capacity" step.
|
|
GRADLE_OPTS: -Dorg.gradle.jvmargs=-Xmx6g -XX:MaxMetaspaceSize=768m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError -XX:+UseG1GC -Dkotlin.daemon.jvm.options=-Xmx2g
|
|
CI_GRADLE_ARG_PROPERTIES: --stacktrace -Dsonar.gradle.skipCompile=true --no-configuration-cache
|
|
|
|
jobs:
|
|
build:
|
|
name: Build APKs
|
|
runs-on: [self-hosted, Linux, X64]
|
|
permissions:
|
|
# A job-level block replaces the workflow-level one, so contents:read has to be
|
|
# repeated here or checkout fails on this private fork.
|
|
contents: read
|
|
# For NejcZdovc/comment-pr
|
|
pull-requests: write
|
|
strategy:
|
|
matrix:
|
|
variant: [debug, release, nightly]
|
|
fail-fast: false
|
|
# Allow all jobs on develop. Just one per PR.
|
|
concurrency:
|
|
group: ${{ github.ref == 'refs/heads/develop' && format('build-develop-{0}-{1}', matrix.variant, github.sha) || format('build-{0}-{1}', matrix.variant, github.ref) }}
|
|
cancel-in-progress: true
|
|
steps:
|
|
- name: Free Disk Space (Ubuntu)
|
|
# Only meaningful on GitHub's throwaway VMs. On a persistent self-hosted runner this
|
|
# would delete dotnet/haskell/docker images from the host on every run.
|
|
if: runner.environment == 'github-hosted'
|
|
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be
|
|
with:
|
|
# This might remove tools that are actually needed, if set to "true" but frees about 6 GB
|
|
tool-cache: true
|
|
# All of these default to true, but we should only need the 'android' one (and maybe swap-storage?)
|
|
android: false
|
|
dotnet: true
|
|
haskell: true
|
|
# This takes way too long to run (~2 minutes) and it saves only ~5.5GB
|
|
large-packages: false
|
|
docker-images: true
|
|
swap-storage: false
|
|
|
|
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
with:
|
|
# Ensure we are building the branch and not the branch after being merged on develop
|
|
# https://github.com/actions/checkout/issues/881
|
|
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }}
|
|
persist-credentials: false
|
|
- name: Use JDK 21
|
|
uses: actions/setup-java@ad2b38190b15e4d6bdf0c97fb4fca8412226d287 # v5.3.0
|
|
with:
|
|
distribution: 'temurin' # See 'Supported distributions' for available options
|
|
java-version: '21'
|
|
- name: Configure gradle
|
|
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0
|
|
with:
|
|
cache-read-only: ${{ github.ref != 'refs/heads/develop' }}
|
|
- name: Assemble debug APKs
|
|
if: ${{ matrix.variant == 'debug' }}
|
|
env:
|
|
ELEMENT_ANDROID_MAPTILER_API_KEY: ${{ secrets.MAPTILER_KEY }}
|
|
ELEMENT_ANDROID_MAPTILER_LIGHT_MAP_ID: ${{ secrets.MAPTILER_LIGHT_MAP_ID }}
|
|
ELEMENT_ANDROID_MAPTILER_DARK_MAP_ID: ${{ secrets.MAPTILER_DARK_MAP_ID }}
|
|
ELEMENT_ANDROID_SENTRY_DSN: ${{ secrets.ELEMENT_ANDROID_SENTRY_DSN }}
|
|
ELEMENT_SDK_SENTRY_DSN: ${{ secrets.ELEMENT_SDK_SENTRY_DSN }}
|
|
ELEMENT_CALL_SENTRY_DSN: ${{ secrets.ELEMENT_CALL_SENTRY_DSN }}
|
|
ELEMENT_CALL_POSTHOG_API_HOST: ${{ secrets.ELEMENT_CALL_POSTHOG_API_HOST }}
|
|
ELEMENT_CALL_POSTHOG_API_KEY: ${{ secrets.ELEMENT_CALL_POSTHOG_API_KEY }}
|
|
ELEMENT_CALL_RAGESHAKE_URL: ${{ secrets.ELEMENT_CALL_RAGESHAKE_URL }}
|
|
run: ./gradlew :app:assembleGplayDebug app:assembleFDroidDebug -PallWarningsAsErrors=true $CI_GRADLE_ARG_PROPERTIES
|
|
- name: Upload debug APKs
|
|
if: ${{ matrix.variant == 'debug' }}
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: elementx-debug
|
|
path: |
|
|
app/build/outputs/apk/gplay/debug/*-universal-debug.apk
|
|
app/build/outputs/apk/fdroid/debug/*-universal-debug.apk
|
|
- uses: rnkdsh/action-upload-diawi@76778fcd1f9f589efaaa62f63d5f03430bbb1306 # v1.5.13
|
|
id: diawi
|
|
# Do not fail the whole build if Diawi upload fails
|
|
continue-on-error: true
|
|
env:
|
|
token: ${{ secrets.DIAWI_TOKEN }}
|
|
if: ${{ matrix.variant == 'debug' && github.event_name == 'pull_request' && env.token != '' }}
|
|
with:
|
|
token: ${{ env.token }}
|
|
file: app/build/outputs/apk/gplay/debug/app-gplay-arm64-v8a-debug.apk
|
|
- name: Add or update PR comment with QR Code to download APK.
|
|
if: ${{ matrix.variant == 'debug' && github.event_name == 'pull_request' && steps.diawi.conclusion == 'success' }}
|
|
uses: NejcZdovc/comment-pr@a423635d183a8259308e80593c96fecf31539c26 # v2.1.0
|
|
with:
|
|
message: |
|
|
:iphone: Scan the QR code below to install the build (arm64 only) for this PR.
|
|

|
|
If you can't scan the QR code you can install the build via this link: ${{ steps.diawi.outputs['url'] }}
|
|
# Enables to identify and update existing Ad-hoc release message on new commit in the PR
|
|
identifier: "GITHUB_COMMENT_QR_CODE"
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
- name: Compile release sources
|
|
if: ${{ matrix.variant == 'release' }}
|
|
run: ./gradlew bundleGplayRelease -PallWarningsAsErrors=true $CI_GRADLE_ARG_PROPERTIES
|
|
- name: Compile nightly sources
|
|
if: ${{ matrix.variant == 'nightly' }}
|
|
run: ./gradlew compileGplayNightlySources -PallWarningsAsErrors=true $CI_GRADLE_ARG_PROPERTIES
|