File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Build APKs for Android using Nix
2+
3+ on :
4+ workflow_dispatch :
5+
6+ jobs :
7+ build :
8+ runs-on : ubuntu-latest
9+ steps :
10+ - uses : actions/checkout@v5
11+ with :
12+ fetch-depth : 0
13+ submodules : ' recursive'
14+
15+ - uses : cachix/install-nix-action@v31
16+
17+ - name : Check Necessary environment variables presence
18+ run : |
19+ if [ -z "$LOCAL_PROPERTIES" ] || [ -z "$GOOGLE_SERVICES_JSON" ]; then
20+ echo "You may want to add LOCAL_PROPERTIES and GOOGLE_SERVICES_JSON environment variables to your secrets"
21+ exit 1
22+ fi
23+ env :
24+ LOCAL_PROPERTIES : ${{ secrets.LOCAL_PROPERTIES }}
25+ GOOGLE_SERVICES_JSON : ${{ secrets.GOOGLE_SERVICES_JSON }}
26+
27+ - name : Build Task
28+ run : nix --experimental-features "nix-command flakes" run .#buildRelease
29+ env :
30+ LOCAL_PROPERTIES : ${{ secrets.LOCAL_PROPERTIES }}
31+ GOOGLE_SERVICES_JSON : ${{ secrets.GOOGLE_SERVICES_JSON }}
32+
33+ - name : Upload Release APKs
34+ uses : actions/upload-artifact@v7
35+ with :
36+ name : Release APKs
37+ path : app/build/outputs/apk/release/*.apk
38+
Original file line number Diff line number Diff line change 1515 perSystem =
1616 { pkgs , system , ... } :
1717 let
18+ actualBuildTools = "36.0.0" ;
1819 androidComposition =
1920 pkgs :
2021 ( pkgs . androidenv . composeAndroidPackages {
2122 platformVersions = [
2223 "35"
24+ "36"
2325 ] ;
2426
2527 buildToolsVersions = [
2628 "35.0.0"
29+ actualBuildTools
2730 ] ;
2831
2932 cmakeVersions = [
7073 JAVA_HOME = "${ pkgs . jdk21 } " ;
7174 ANDROID_HOME = "${ androidComposition pkgs } /libexec/android-sdk" ;
7275 } ;
76+
77+ apps = {
78+ buildRelease = {
79+ type = "app" ;
80+ program = "${ pkgs . writeShellScriptBin "buildRelease" ''
81+ if [ -z "$LOCAL_PROPERTIES" ] || [ -z "$GOOGLE_SERVICES_JSON" ]; then
82+ echo "LOCAL_PROPERTIES and GOOGLE_SERVICES_JSON environment variables must be set"
83+ exit 1
84+ fi
85+
86+ if ! ${ pkgs . git } /bin/git submodule update --init --recursive; then
87+ echo "failed getting submodules"
88+ fi
89+
90+ echo $LOCAL_PROPERTIES >local.properties
91+ echo $GOOGLE_SERVICES_JSON >app/google-services.json
92+
93+ export ANDROID_HOME="${ androidComposition pkgs } /libexec/android-sdk/"
94+ export ANDROID_SDK_ROOT="${ androidComposition pkgs } /libexec/android-sdk/"
95+ export ANDROID_NDK_HOME="$ANDROID_HOME/ndk-bundle/"
96+ export GRADLE_OPTS="-Dorg.gradle.project.android.aapt2FromMavenOverride=${ androidComposition pkgs } /libexec/android-sdk/build-tools/${ actualBuildTools } /aapt2"
97+ export JAVA_HOME="${ pkgs . jdk21 } "
98+
99+ cd presentation/src/main/cpp/
100+ if ! [ -d libvpx_build ]; then
101+ sed -e "s|#!/bin/bash|#!${ pkgs . bash } /bin/bash|g" \
102+ -e "s|make clean|${ pkgs . gnumake } /bin/make clean|g" \
103+ -e "s|make -j|${ pkgs . gnumake } /bin/make -j|g" build.sh >new_build.sh
104+ chmod +x new_build.sh
105+ if ! ${ pkgs . bash } /bin/bash new_build.sh; then
106+ echo "libvpx build failed"
107+ exit 1
108+ fi
109+ rm new_build.sh
110+ fi
111+
112+ cd ../../../..
113+ ./gradlew assembleRelease
114+ '' } /bin/buildRelease";
115+ } ;
116+ } ;
73117 } ;
74118 } ;
75119}
You can’t perform that action at this time.
0 commit comments