mirror of
https://github.com/netbirdio/android-client.git
synced 2026-09-23 09:30:52 -07:00
Reworks the Android UI, and brings over features the desktop client already had.
142 lines
5.3 KiB
YAML
142 lines
5.3 KiB
YAML
name: 'Build Android App'
|
|
description: 'Build Android APK and AAB'
|
|
inputs:
|
|
version_name:
|
|
description: 'Version name for the build'
|
|
required: true
|
|
version_code:
|
|
description: 'Version code for the build'
|
|
required: false
|
|
default: ''
|
|
build_type:
|
|
description: 'Build type: debug or release'
|
|
required: true
|
|
outputs:
|
|
apk_path:
|
|
description: 'Path to the built APK'
|
|
value: ${{ steps.build-info.outputs.apk_path }}
|
|
bundle_path:
|
|
description: 'Path to the built AAB bundle'
|
|
value: ${{ steps.build-info.outputs.bundle_path }}
|
|
aar_path:
|
|
description: 'Path to the built NetBird Go library AAR'
|
|
value: gomobile/netbird.aar
|
|
|
|
runs:
|
|
using: 'composite'
|
|
steps:
|
|
- name: Print inputs
|
|
shell: bash
|
|
run: |
|
|
echo "Version Name: ${{ inputs.version_name }}"
|
|
echo "Version Code: ${{ inputs.version_code }}"
|
|
echo "Build Type: ${{ inputs.build_type }}"
|
|
|
|
- name: Fetch tags and history for submodule
|
|
shell: bash
|
|
run: |
|
|
cd netbird
|
|
# build-android-lib.sh resolves the version by walking HEAD's ancestry
|
|
# back to the last release tag. actions/checkout clones submodules
|
|
# shallow, which fetches the tags but not the commits between HEAD and
|
|
# the tag, so without full history the walk comes up empty and the
|
|
# build silently falls back to a ci-<sha> version.
|
|
if [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then
|
|
git fetch --unshallow --tags
|
|
else
|
|
git fetch --tags
|
|
fi
|
|
|
|
- name: Read the daemon JDK version
|
|
id: jdk
|
|
shell: bash
|
|
run: echo "version=$(sed -n 's/^toolchainVersion=//p' gradle/gradle-daemon-jvm.properties)" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Setup Java
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
java-version: ${{ steps.jdk.outputs.version }}
|
|
# AdoptOpenJDK became Eclipse Temurin; resolving "adopt" now fails
|
|
# outright, so the build never gets as far as installing a JDK.
|
|
distribution: "temurin"
|
|
cache: "gradle"
|
|
|
|
- name: Install Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: "netbird/go.mod"
|
|
cache-dependency-path: "netbird/go.sum"
|
|
|
|
- name: Read the NDK version
|
|
id: ndk
|
|
shell: bash
|
|
run: echo "version=$(sed -n 's/^readonly NDK_VERSION=//p' build-android-lib.sh)" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Cache Android NDK
|
|
id: ndk-cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
# ANDROID_HOME is set by the runner image but not visible to ${{ env.X }}
|
|
# in composite actions; the ubuntu-latest image pins it to this path.
|
|
path: /usr/local/lib/android/sdk/ndk/${{ steps.ndk.outputs.version }}
|
|
key: ndk-${{ steps.ndk.outputs.version }}
|
|
|
|
- name: Setup NDK
|
|
if: steps.ndk-cache.outputs.cache-hit != 'true'
|
|
shell: bash
|
|
run: ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install "ndk;${{ steps.ndk.outputs.version }}"
|
|
|
|
# build-android-lib.sh installs gomobile and gobind at the revision the
|
|
# submodule's go.mod names; the cache below only spares the go install on a
|
|
# hit. Its key carries that revision so it follows a submodule bump on its own.
|
|
- name: Resolve the gomobile revision
|
|
id: gomobile-version
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
version=$(cd netbird && go list -m -f '{{.Version}}' golang.org/x/mobile)
|
|
if [ -z "$version" ]; then
|
|
echo "::error::could not resolve the golang.org/x/mobile version from netbird/go.mod"
|
|
exit 1
|
|
fi
|
|
echo "Using gomobile and gobind at $version"
|
|
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
|
|
# The key has to name both tools, not just the revision: entries saved by
|
|
# the earlier gomobile-only step hold no gobind, so reusing that key would
|
|
# hit the cache, skip the install and leave the build without a generator.
|
|
- name: Cache gomobile and gobind
|
|
id: gomobile-cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/go/bin/gomobile
|
|
~/go/bin/gobind
|
|
key: gomobile-gobind-${{ steps.gomobile-version.outputs.version }}
|
|
|
|
- name: Build NetBird Go library
|
|
shell: bash
|
|
run: bash -x build-android-lib.sh
|
|
|
|
- name: Build APK and Bundle
|
|
shell: bash
|
|
run: |
|
|
BUILD_TYPE=${{ inputs.build_type == 'release' && 'Release' || 'Debug' }}
|
|
./gradlew --no-daemon assemble${BUILD_TYPE} bundle${BUILD_TYPE} -PversionName="${{ inputs.version_name }}" -PversionCode="${{ inputs.version_code }}"
|
|
|
|
- name: Rename artifacts
|
|
shell: bash
|
|
run: |
|
|
set -e
|
|
BUILD_TYPE_FOLDER="${{ inputs.build_type }}"
|
|
mv app/build/outputs/apk/${BUILD_TYPE_FOLDER}/app-${BUILD_TYPE_FOLDER}.apk app/build/outputs/apk/${BUILD_TYPE_FOLDER}/netbird-${{ inputs.version_name }}.apk
|
|
mv app/build/outputs/bundle/${BUILD_TYPE_FOLDER}/app-${BUILD_TYPE_FOLDER}.aab app/build/outputs/bundle/${BUILD_TYPE_FOLDER}/netbird-${{ inputs.version_name }}.aab
|
|
|
|
- name: Set build info
|
|
id: build-info
|
|
shell: bash
|
|
run: |
|
|
BUILD_TYPE="${{ inputs.build_type }}"
|
|
echo "apk_path=app/build/outputs/apk/${BUILD_TYPE}/netbird-${{ inputs.version_name }}.apk" >> $GITHUB_OUTPUT
|
|
echo "bundle_path=app/build/outputs/bundle/${BUILD_TYPE}/netbird-${{ inputs.version_name }}.aab" >> $GITHUB_OUTPUT
|