|
| 1 | +# SuperTux |
| 2 | +# Copyright (C) 2021-2021 Sergii Pylypenko <[email protected]> |
| 3 | +# |
| 4 | +# This program is free software; you can redistribute it and/or |
| 5 | +# modify it under the terms of the GNU General Public License |
| 6 | +# as published by the Free Software Foundation; either version 3 |
| 7 | +# of the License, or (at your option) any later version. |
| 8 | +# |
| 9 | +# This program is distributed in the hope that it will be useful, |
| 10 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +# GNU General Public License for more details. |
| 13 | +# |
| 14 | +# You should have received a copy of the GNU General Public License |
| 15 | +# along with this program; if not, write to the Free Software |
| 16 | +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | + |
| 18 | +name: Android |
| 19 | +on: |
| 20 | + push: |
| 21 | + branches: |
| 22 | + - master |
| 23 | + tags: |
| 24 | + - '*' |
| 25 | + pull_request: {} |
| 26 | + |
| 27 | +jobs: |
| 28 | + build-android: |
| 29 | + env: |
| 30 | + # Revision of https://github.com/pelya/commandergenius.git - SDL2 repo is a submodule |
| 31 | + # We check out a specific stable revision, so the build won't break if I modify my SDL repo |
| 32 | + SDL_ANDROID_REV: 798fd0f5e167aa6ecce33623dbf88ebc6cd647ea |
| 33 | + # It takes 35 minutes per one architecture to build SuperTux, of which 20 minutes are for building Boost and ICU libraries |
| 34 | + # Enable additional architectures when we have these libraries inside the cache, or create a separate Android script for each architecture |
| 35 | + ARCH_LIST: armeabi-v7a arm64-v8a x86 x86_64 |
| 36 | + |
| 37 | + runs-on: ubuntu-latest |
| 38 | + |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v2 |
| 41 | + with: |
| 42 | + fetch-depth: 0 |
| 43 | + submodules: true |
| 44 | + |
| 45 | + - name: Clone SDL Android repo |
| 46 | + run: | |
| 47 | + git clone --depth=100 https://github.com/pelya/commandergenius.git build.android |
| 48 | + git -C build.android checkout ${SDL_ANDROID_REV} |
| 49 | +
|
| 50 | + - name: Clone SDL Android repo submodules |
| 51 | + # There are many more submodules in this repo, we don't need them all |
| 52 | + working-directory: build.android |
| 53 | + run: > |
| 54 | + git submodule update --init --recursive --depth=1 |
| 55 | + project/jni/boost/src project/jni/iconv/src |
| 56 | + project/jni/sdl2 project/jni/sdl2_image |
| 57 | + project/jni/sdl2_mixer project/jni/sdl2_ttf |
| 58 | +
|
| 59 | + - name: Symlink the application dir |
| 60 | + run: | |
| 61 | + rm -rf build.android/project/jni/application/supertux/supertux |
| 62 | + ln -s `pwd` build.android/project/jni/application/supertux/supertux |
| 63 | + ln -s supertux build.android/project/jni/application/src |
| 64 | +
|
| 65 | + - name: Set architectures list and version |
| 66 | + working-directory: build.android |
| 67 | + run: | |
| 68 | + VERSION_NAME="$(git -C .. describe --tags | cut -f 1,2 -d "-" | sed 's/[^0-9\\.\\-]//g' | sed 's/-/./g')" |
| 69 | + VERSION_CODE="$(printf "%02d%02d%02d%04d\n" "$(echo $VERSION_NAME | cut -d . -f 1)" "$(echo $VERSION_NAME | cut -d . -f 2)" "$(echo $VERSION_NAME | cut -d . -f 3)" "$(echo $VERSION_NAME | cut -d . -f 4)")" |
| 70 | + echo "Version name: $VERSION_NAME" |
| 71 | + echo "Version code: $VERSION_CODE" |
| 72 | + sed -i "s/MultiABI=.*/MultiABI='${ARCH_LIST}'/g" project/jni/application/supertux/AndroidAppSettings.cfg |
| 73 | + sed -i "s/AppVersionName.*/AppVersionName="$VERSION_NAME"/g" project/jni/application/supertux/AndroidAppSettings.cfg |
| 74 | + sed -i "s/AppVersionCode.*/AppVersionCode=$VERSION_CODE/g" project/jni/application/supertux/AndroidAppSettings.cfg |
| 75 | +
|
| 76 | + - name: Copy precompiled libraries from cache |
| 77 | + uses: actions/cache@v2 |
| 78 | + id: cache |
| 79 | + with: |
| 80 | + # The same SDL revision will produce the same libraries |
| 81 | + key: ${{env.SDL_ANDROID_REV}} |
| 82 | + path: | |
| 83 | + build.android/project/jni/boost/include |
| 84 | + build.android/project/jni/boost/lib |
| 85 | + build.android/project/jni/iconv/include |
| 86 | + build.android/project/jni/iconv/lib |
| 87 | + build.android/project/jni/icuuc/include |
| 88 | + build.android/project/jni/icuuc/lib |
| 89 | + build.android/project/jni/openssl/include |
| 90 | + build.android/project/jni/openssl/lib |
| 91 | +
|
| 92 | + - name: Touch cached file timestamps |
| 93 | + if: steps.cache.outputs.cache-hit == 'true' |
| 94 | + working-directory: build.android |
| 95 | + run: > |
| 96 | + touch |
| 97 | + project/jni/boost/lib/*/* |
| 98 | + project/jni/iconv/lib/*/* |
| 99 | + project/jni/icuuc/lib/*/* |
| 100 | + project/jni/openssl/lib/*/* |
| 101 | + || true |
| 102 | +
|
| 103 | + - name: Build Boost, ICU, and OpenSSL |
| 104 | + working-directory: build.android |
| 105 | + run: | |
| 106 | + export PATH=$ANDROID_NDK_LATEST_HOME:$PATH |
| 107 | + ./changeAppSettings.sh |
| 108 | +
|
| 109 | + - name: Set up Gradle and Android SDK licenses |
| 110 | + working-directory: build.android/project |
| 111 | + run: | |
| 112 | + yes | sudo $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses |
| 113 | + ./gradlew assembleRelease || true |
| 114 | + yes | sudo $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses --sdk_root=`pwd` |
| 115 | + mkdir -p $HOME/.android |
| 116 | + keytool -genkey -v -keystore $HOME/.android/debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=Debug, OU=Debug, O=Debug, L=Debug, ST=Debug, C=Debug" |
| 117 | + echo "sdk.dir=$ANDROID_SDK_ROOT" > local.properties |
| 118 | + echo "proguard.config=proguard.cfg;proguard-local.cfg" >> local.properties |
| 119 | +
|
| 120 | + - name: Build |
| 121 | + working-directory: build.android |
| 122 | + run: | |
| 123 | + export PATH=$ANDROID_NDK_LATEST_HOME:$ANDROID_SDK_ROOT/build-tools/31.0.0:$PATH |
| 124 | + ./build.sh |
| 125 | +
|
| 126 | + - name: Package |
| 127 | + working-directory: build.android |
| 128 | + run: | |
| 129 | + export PATH=$ANDROID_NDK_LATEST_HOME:$ANDROID_SDK_ROOT/build-tools/31.0.0:$PATH |
| 130 | + mkdir -p upload/apk/ upload/aab/ |
| 131 | + cd project |
| 132 | + ./gradlew bundleReleaseWithDebugInfo |
| 133 | + mv app/build/outputs/bundle/releaseWithDebugInfo/app-releaseWithDebugInfo.aab ../upload/aab/SuperTux.aab |
| 134 | + cd jni/application/supertux |
| 135 | + ./create-apk-with-data.sh |
| 136 | + cd ../../../.. |
| 137 | + mv SuperTux*.apk upload/apk/ |
| 138 | + cd .. |
| 139 | +
|
| 140 | + - uses: actions/upload-artifact@v2 |
| 141 | + with: |
| 142 | + name: "SuperTux-android-aab" |
| 143 | + path: build.android/upload/aab |
| 144 | + if-no-files-found: error |
| 145 | + |
| 146 | + - uses: actions/upload-artifact@v2 |
| 147 | + with: |
| 148 | + name: "SuperTux-android-apk" |
| 149 | + path: build.android/upload/apk |
| 150 | + if-no-files-found: error |
0 commit comments