Release Build #39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Android APK | |
| on: | |
| push: | |
| tags: | |
| - '*.*.*' | |
| - '!*-*' | |
| workflow_dispatch: | |
| jobs: | |
| build-android: | |
| name: Build Android APK | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup JDK 17 | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: microsoft | |
| java-version: 17 | |
| - name: Install .NET 10.0.x | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: "10.0.x" | |
| - name: Install .NET Android workload | |
| run: dotnet workload install android | |
| - name: Ensure Android NDK and CMake are available | |
| run: | | |
| # The ubuntu-latest runner has $ANDROID_HOME pre-installed. | |
| # sdkmanager is not on PATH; use the full path. | |
| SDKMANAGER="$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" | |
| # Install latest stable NDK (r29) + CMake. | |
| yes | "$SDKMANAGER" --licenses > /dev/null 2>&1 || true | |
| "$SDKMANAGER" --install "ndk;29.0.14206865" "cmake;3.22.1" > /dev/null 2>&1 | |
| - name: Build native library (libosu_native.so) | |
| run: | | |
| NDK_HOME="$ANDROID_HOME/ndk/29.0.14206865" | |
| CMAKE_BIN="$ANDROID_HOME/cmake/3.22.1/bin/cmake" | |
| for ABI in arm64-v8a armeabi-v7a x86; do | |
| echo "::group::Building osu_native for $ABI" | |
| "$CMAKE_BIN" -B "build-native/$ABI" -S osu.Android/Native \ | |
| -DCMAKE_TOOLCHAIN_FILE="$NDK_HOME/build/cmake/android.toolchain.cmake" \ | |
| -DANDROID_ABI="$ABI" \ | |
| -DANDROID_PLATFORM=android-30 \ | |
| -DCMAKE_BUILD_TYPE=Release | |
| "$CMAKE_BIN" --build "build-native/$ABI" --config Release -j "$(nproc)" | |
| mkdir -p "osu.Android/libs/$ABI" | |
| cp "build-native/$ABI/libosu_native.so" "osu.Android/libs/$ABI/" | |
| echo "::endgroup::" | |
| done | |
| echo "Native libraries built successfully:" | |
| find osu.Android/libs -name "*.so" -exec ls -lh {} \; | |
| - name: Decode keystore | |
| id: keystore | |
| run: | | |
| if [ -n "$KEYSTORE_BASE64" ]; then | |
| echo "$KEYSTORE_BASE64" | base64 --decode > "${{ github.workspace }}/osu.Android/osu.keystore" | |
| echo "has_keystore=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has_keystore=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| env: | |
| KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} | |
| - name: Set version | |
| id: version | |
| run: | | |
| REF="${{ github.ref_name }}" | |
| if [[ "$REF" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "version=$REF" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "version=0.0.0" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Build Android APK (signed) | |
| if: steps.keystore.outputs.has_keystore == 'true' | |
| run: > | |
| dotnet publish -c Release | |
| osu.Android/osu.Android.csproj | |
| -f net10.0-android | |
| -p:Version=${{ steps.version.outputs.version }} | |
| -p:ApplicationDisplayVersion=${{ steps.version.outputs.version }} | |
| -p:ApplicationVersion=${{ github.run_number }} | |
| -p:AndroidKeyStore=true | |
| -p:AndroidSigningKeyStore=${{ github.workspace }}/osu.Android/osu.keystore | |
| -p:AndroidSigningKeyAlias=${{ secrets.ANDROID_SIGNING_KEY_ALIAS }} | |
| -p:AndroidSigningKeyPass=${{ secrets.ANDROID_SIGNING_KEY_PASSWORD }} | |
| -p:AndroidSigningStorePass=${{ secrets.ANDROID_SIGNING_STORE_PASSWORD }} | |
| - name: Build Android APK (unsigned) | |
| if: steps.keystore.outputs.has_keystore != 'true' | |
| run: > | |
| dotnet publish -c Release | |
| osu.Android/osu.Android.csproj | |
| -f net10.0-android | |
| -p:Version=${{ steps.version.outputs.version }} | |
| -p:ApplicationDisplayVersion=${{ steps.version.outputs.version }} | |
| -p:ApplicationVersion=${{ github.run_number }} | |
| -p:AndroidKeyStore=false | |
| - name: Find APK | |
| id: find_apk | |
| run: | | |
| PUBLISH_DIR="osu.Android/bin/Release/net10.0-android/publish" | |
| APK=$(find "$PUBLISH_DIR" -maxdepth 1 -name "*.apk" 2>/dev/null | head -1) | |
| if [ -z "$APK" ]; then | |
| APK=$(find osu.Android/bin/Release -name "*.apk" | head -1) | |
| fi | |
| echo "apk_path=$APK" >> "$GITHUB_OUTPUT" | |
| - name: Upload APK artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: osu-android-${{ github.ref_name }} | |
| path: ${{ steps.find_apk.outputs.apk_path }} | |
| if-no-files-found: error | |
| - name: Create GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: ${{ steps.find_apk.outputs.apk_path }} | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |