android.yml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. # SuperTux
  2. # Copyright (C) 2021-2021 Sergii Pylypenko <x.pelya.x@gmail.com>
  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. name: Android
  18. on:
  19. push:
  20. branches:
  21. - master
  22. tags:
  23. - '*'
  24. pull_request: {}
  25. jobs:
  26. build-android:
  27. env:
  28. # Revision of https://github.com/pelya/commandergenius.git - SDL2 repo is a submodule
  29. # We check out a specific stable revision, so the build won't break if I modify my SDL repo
  30. SDL_ANDROID_REV: 798fd0f5e167aa6ecce33623dbf88ebc6cd647ea
  31. # It takes 35 minutes per one architecture to build SuperTux, of which 20 minutes are for building Boost and ICU libraries
  32. # Enable additional architectures when we have these libraries inside the cache, or create a separate Android script for each architecture
  33. ARCH_LIST: armeabi-v7a arm64-v8a x86 x86_64
  34. runs-on: ubuntu-latest
  35. steps:
  36. - uses: actions/checkout@v4
  37. with:
  38. fetch-depth: 0
  39. submodules: true
  40. - name: Clone SDL Android repo
  41. run: |
  42. git clone --depth=100 https://github.com/pelya/commandergenius.git build.android
  43. git -C build.android checkout ${SDL_ANDROID_REV}
  44. - name: Clone SDL Android repo submodules
  45. # There are many more submodules in this repo, we don't need them all
  46. working-directory: build.android
  47. run: >
  48. git submodule update --init --recursive --depth=1
  49. project/jni/boost/src project/jni/iconv/src
  50. project/jni/sdl2 project/jni/sdl2_image
  51. project/jni/sdl2_mixer project/jni/sdl2_ttf
  52. - name: Symlink the application dir
  53. run: |
  54. rm -rf build.android/project/jni/application/supertux/supertux
  55. ln -s `pwd` build.android/project/jni/application/supertux/supertux
  56. ln -s supertux build.android/project/jni/application/src
  57. - name: Set architectures list and version
  58. working-directory: build.android
  59. run: |
  60. VERSION_NAME="$(git -C .. describe --tags | cut -f 1,2 -d "-" | sed 's/[^0-9\\.\\-]//g' | sed 's/-/./g')"
  61. 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)")"
  62. echo "Version name: $VERSION_NAME"
  63. echo "Version code: $VERSION_CODE"
  64. sed -i "s/MultiABI=.*/MultiABI='${ARCH_LIST}'/g" project/jni/application/supertux/AndroidAppSettings.cfg
  65. sed -i "s/AppVersionName.*/AppVersionName="$VERSION_NAME"/g" project/jni/application/supertux/AndroidAppSettings.cfg
  66. sed -i "s/AppVersionCode.*/AppVersionCode=$VERSION_CODE/g" project/jni/application/supertux/AndroidAppSettings.cfg
  67. - name: Copy precompiled libraries from cache
  68. uses: actions/cache@v2
  69. id: cache
  70. with:
  71. # The same SDL revision will produce the same libraries
  72. key: ${{env.SDL_ANDROID_REV}}
  73. path: |
  74. build.android/project/jni/boost/include
  75. build.android/project/jni/boost/lib
  76. build.android/project/jni/iconv/include
  77. build.android/project/jni/iconv/lib
  78. build.android/project/jni/icuuc/include
  79. build.android/project/jni/icuuc/lib
  80. build.android/project/jni/openssl/include
  81. build.android/project/jni/openssl/lib
  82. - name: Touch cached file timestamps
  83. if: steps.cache.outputs.cache-hit == 'true'
  84. working-directory: build.android
  85. run: >
  86. touch
  87. project/jni/boost/lib/*/*
  88. project/jni/iconv/lib/*/*
  89. project/jni/icuuc/lib/*/*
  90. project/jni/openssl/lib/*/*
  91. || true
  92. - name: Build Boost, ICU, and OpenSSL
  93. working-directory: build.android
  94. run: |
  95. export PATH=$ANDROID_NDK_LATEST_HOME:$PATH
  96. ./changeAppSettings.sh
  97. - name: Set up Gradle and Android SDK licenses
  98. working-directory: build.android/project
  99. run: |
  100. yes | sudo $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses
  101. ./gradlew assembleRelease || true
  102. yes | sudo $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses --sdk_root=`pwd`
  103. mkdir -p $HOME/.android
  104. 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"
  105. echo "sdk.dir=$ANDROID_SDK_ROOT" > local.properties
  106. echo "proguard.config=proguard.cfg;proguard-local.cfg" >> local.properties
  107. - name: Build
  108. working-directory: build.android
  109. run: |
  110. export PATH=$ANDROID_NDK_LATEST_HOME:$ANDROID_SDK_ROOT/build-tools/31.0.0:$PATH
  111. ./build.sh
  112. - name: Package
  113. working-directory: build.android
  114. run: |
  115. export PATH=$ANDROID_NDK_LATEST_HOME:$ANDROID_SDK_ROOT/build-tools/31.0.0:$PATH
  116. mkdir -p upload/apk/ upload/aab/
  117. cd project
  118. ./gradlew bundleReleaseWithDebugInfo
  119. mv app/build/outputs/bundle/releaseWithDebugInfo/app-releaseWithDebugInfo.aab ../upload/aab/SuperTux.aab
  120. cd jni/application/supertux
  121. ./create-apk-with-data.sh
  122. cd ../../../..
  123. mv SuperTux*.apk upload/apk/
  124. cd ..
  125. - uses: actions/upload-artifact@v4
  126. with:
  127. name: "SuperTux-android-aab"
  128. path: build.android/upload/aab
  129. if-no-files-found: error
  130. - uses: actions/upload-artifact@v4
  131. with:
  132. name: "SuperTux-android-apk"
  133. path: build.android/upload/apk
  134. if-no-files-found: error