From f9bc3e4995341ff696abbed089325d73a5028d92 Mon Sep 17 00:00:00 2001 From: Alexis He Date: Tue, 17 Aug 2021 10:04:52 +0200 Subject: [PATCH] Add: Github action for Android nightly build --- ...-patch-simutrans-122.0-compatibility.patch | 47 ++++++ .github/workflows/nightly-android.yml | 145 ++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 .github/android/0001-ADD-patch-simutrans-122.0-compatibility.patch create mode 100644 .github/workflows/nightly-android.yml diff --git a/.github/android/0001-ADD-patch-simutrans-122.0-compatibility.patch b/.github/android/0001-ADD-patch-simutrans-122.0-compatibility.patch new file mode 100644 index 000000000..566107542 --- /dev/null +++ b/.github/android/0001-ADD-patch-simutrans-122.0-compatibility.patch @@ -0,0 +1,47 @@ +From f89bdf6f8ba9c45c8fad5f15ca891f7a324d3e0b Mon Sep 17 00:00:00 2001 +From: Alexis He +Date: Mon, 16 Aug 2021 15:16:40 +0200 +Subject: [PATCH] ADD: patch simutrans 122.0 compatibility + +--- + project/jni/application/simutrans/AndroidAppSettings.cfg | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/project/jni/application/simutrans/AndroidAppSettings.cfg b/project/jni/application/simutrans/AndroidAppSettings.cfg +index 3dbf10872..f31dfa8b2 100644 +--- a/project/jni/application/simutrans/AndroidAppSettings.cfg ++++ b/project/jni/application/simutrans/AndroidAppSettings.cfg +@@ -7,10 +7,10 @@ AppName="Simutrans" + AppFullName=com.simutrans + + # Application version code (integer) +-AppVersionCode=1210 ++AppVersionCode=1220 + + # Application user-visible version name (string) +-AppVersionName="121.0" ++AppVersionName="122.0" + + # Specify path to download application data in zip archive in the form "Description|URL|MirrorURL^Description2|URL2|MirrorURL2^..." + # If you'll start Description with '!' symbol it will be enabled by default, '!!' will also hide the entry from the menu, so it cannot be disabled +@@ -74,7 +74,7 @@ UseGl4es= + SwVideoMode=y + + # Application video output will be resized to fit into native device screen (y)/(n) +-SdlVideoResize=n ++SdlVideoResize=y + + # Application resizing will keep 4:3 aspect ratio, with black bars at sides (y)/(n) + SdlVideoResizeKeepAspect=n +@@ -314,7 +314,7 @@ AppSubdirsBuild='' + AppBuildExclude='' + + # Application command line parameters, including app name as 0-th param +-AppCmdline='simutrans -use_workdir -screensize 800x600 -fullscreen' ++AppCmdline='simutrans -use_workdir -screensize 800x480 -fullscreen' + + # Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens + # Minimum screen size that application supports: (s)mall / (m)edium / (l)arge +-- +2.28.0.windows.1 + diff --git a/.github/workflows/nightly-android.yml b/.github/workflows/nightly-android.yml new file mode 100644 index 000000000..502af8f86 --- /dev/null +++ b/.github/workflows/nightly-android.yml @@ -0,0 +1,145 @@ +name: Nightly build Android + +env: + DEFAULT_PAKSETLINK: 'https://downloads.sourceforge.net/project/simutrans/pak64/122-0/simupak64-122-0.zip' + DEFAULT_PAKSETFILE: 'simupak64-122-0.zip' + +on: + push: + + workflow_dispatch: + inputs: + revision: + description: 'Target revision number (SVN), empty for latest' + required: true + default: '9274' + paksetLink: + description: 'Link to embedded default pakset' + default: 'https://downloads.sourceforge.net/project/simutrans/pak64/122-0/simupak64-122-0.zip' + paksetFile: + description: 'Matching pakset file name' + default: 'simupak64-122-0.zip' + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Install dependencies + run: | + sudo dpkg --add-architecture i386 + sudo apt-get -yqq update + sudo apt-get -ym install curl expect git libc6:i386 libgcc1:i386 libncurses5:i386 libstdc++6:i386 zlib1g:i386 openjdk-8-jdk wget unzip vim make subversion zip + + - name: Setup Android SDK environment variables + run: | + echo "ANDROID_HOME=/opt/android-sdk-linux" >> $GITHUB_ENV + echo "ANDROID_SDK_HOME=/opt/android-sdk-linux" >> $GITHUB_ENV + echo "ANDROID_SDK_ROOT=/opt/android-sdk-linux" >> $GITHUB_ENV + echo "ANDROID_SDK=/opt/android-sdk-linux" >> $GITHUB_ENV + + - name: Create working directory for next steps + run: | + sudo mkdir /opt/android-sdk-linux + sudo mkdir /android-sdl + sudo chown -R runner /opt/android-sdk-linux + sudo chgrp -R docker /opt/android-sdk-linux + sudo chown -R runner /android-sdl + sudo chgrp -R docker /android-sdl + + - name: Install Android SDK tools + working-directory: /opt/android-sdk-linux + run: | + wget https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip + unzip commandlinetools-linux-7583922_latest.zip + rm commandlinetools-linux-7583922_latest.zip + mv cmdline-tools latest + mkdir cmdline-tools + mv latest cmdline-tools/latest + echo "$ANDROID_HOME/cmdline-tools/latest/bin" >> $GITHUB_PATH + + # licenses required for Android SDK must be found somewhere; them being rather simple they are hardcoded here, but they could also be stored as files + - name: Setup licenses files for Android SDK + working-directory: /opt/android-sdk-linux + run: | + mkdir licenses + echo "\n8933bad161af4178b1185d1a37fbf41ea5269c55\n24333f8a63b6825ea9c5514f83c2829b004d1fee" >> licenses/android-sdk-license + echo "\n84831b9409646a918e30573bab4c9c91346d8abd" >> licenses/android-sdk-preview-license + + - name: Install Android SDK dependencies + working-directory: /opt/android-sdk-linux + run: | + yes | sdkmanager --install "platform-tools" + echo "$ANDROID_HOME/platform-tools" >> $GITHUB_PATH + yes | sdkmanager --install "build-tools;30.0.3" + echo "$ANDROID_HOME/build-tools/30.0.3" >> $GITHUB_PATH + yes | sdkmanager --install "cmake;3.18.1" + echo "$ANDROID_HOME/cmake/3.18.1/bin" >> $GITHUB_PATH + yes | sdkmanager --install "ndk;23.0.7599858" + echo "$ANDROID_HOME/ndk/23.0.7599858" >> $GITHUB_PATH + echo "$ANDROID_HOME/ndk/23.0.7599858/toolchains/llvm/prebuilt/linux-x86_64/bin/" >> $GITHUB_PATH + ln -s llvm-objdump ${ANDROID_HOME}/ndk/23.0.7599858/toolchains/llvm/prebuilt/linux-x86_64/bin/objdump + + - name: Install keystore for Android APK signing + run: | + mkdir /home/runner/.android/ + keytool -genkey -v -keystore /home/runner/.android/debug.keystore -alias androiddebugkey -keyalg RSA -keysize 2048 -validity 10000 -keypass android -storepass android -dname "cn=example.com,ou=exampleou,dc=example,dc=com" + + - name: Checkout lib Android SDL by pelya (hard coded version) + working-directory: /android-sdl + run: | + git init && git remote add origin https://github.com/pelya/commandergenius.git && git fetch origin c470f348c4d7afdbdffce4cfebe5265bd798f699 && git reset --hard FETCH_HEAD + + - name: Setup licenses for Gradle + working-directory: /android-sdl + run: | + ln -s $ANDROID_HOME/licenses project/licenses + + # pelya building script expects that 1/ simutrans is found inside /android-sdl/project/jni/application/simutrans/simutrans and 2/ that it is a svn repo, as revision.h is populated by svn command line + # the content of actions/checkout is a git repo so it is not compatible + - name: Setup Android SDL working folder to host Simutrans (latest) + working-directory: /android-sdl + if: ${{ github.event.inputs.revision == '' }} + run: | + svn checkout svn://servers.simutrans.org/simutrans/trunk project/jni/application/simutrans/simutrans + + - name: Setup Android SDL working folder to host Simutrans (target revision) + working-directory: /android-sdl + if: ${{ github.event.inputs.revision != '' }} + run: | + svn checkout -r ${{ github.event.inputs.revision }} svn://servers.simutrans.org/simutrans/trunk project/jni/application/simutrans/simutrans + + # End of environment setup (dependencies installed, source code at correct location) + # Start of package customization + - name: Add default pakset + working-directory: /android-sdl + run: | + wget ${{ github.event.inputs.paksetLink || env.DEFAULT_PAKSETLINK }} + unzip ./${{ github.event.inputs.paksetFile || env.DEFAULT_PAKSETFILE }} -d project/jni/application/simutrans/simutrans/ + + # some temporary changes to Android SDL are stored in /.github/android + - name: (Temporary) Patch Android SDL and replace version + working-directory: /android-sdl + run: | + cp -r $GITHUB_WORKSPACE/.github/android/*.patch . + git apply *.patch + sed -i "s/^AppVersionCode=[0-9]\+/AppVersionCode=$(svnversion project/jni/application/simutrans/simutrans)/" ./project/jni/application/simutrans/AndroidAppSettings.cfg + sed -i "s/^AppVersionName=\"[0-9]\+.[0-9]\+\"/AppVersionName=\"r$(svnversion project/jni/application/simutrans/simutrans)\"/" ./project/jni/application/simutrans/AndroidAppSettings.cfg + + - name: Build Simutrans + working-directory: /android-sdl + run: | + ./build.sh simutrans + mv /android-sdl/project/app/build/outputs/apk/release/app-release.apk $GITHUB_WORKSPACE/simuandroid-multi-nightly.apk + + - name: Update binaries of Nightly Release + uses: svenstaro/upload-release-action@v1-release + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./simuandroid-multi-nightly.apk + asset_name: simuandroid-multi-nightly.apk + tag: Nightly + overwrite: true \ No newline at end of file -- 2.28.0.windows.1