Initial ebitengine android project #17
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 APK | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: "1.21" | |
| - name: Set up Android SDK | |
| uses: android-actions/setup-android@v2 | |
| with: | |
| ndk-version: "27.2.12479018" | |
| sdk-platform: "android-34" | |
| sdk-build-tools: "34.0.0" | |
| - name: Build ARM libraries | |
| run: | | |
| cd $GITHUB_WORKSPACE | |
| # ARMv7 (32-bit) | |
| GOOS=android GOARCH=arm GOARM=7 CGO_ENABLED=1 \ | |
| CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi34-clang \ | |
| CXX=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi34-clang++ \ | |
| go build -tags=android -ldflags="-s -w" -o=libgame_arm.so ./cmd/game | |
| # ARM64 (64-bit) | |
| GOOS=android GOARCH=arm64 CGO_ENABLED=1 \ | |
| CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android34-clang \ | |
| CXX=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android34-clang++ \ | |
| go build -tags=android -ldflags="-s -w" -o=libgame_arm64.so ./cmd/game | |
| - name: Package APK | |
| run: | | |
| cd $GITHUB_WORKSPACE | |
| # Create proper APK structure | |
| mkdir -p apk/lib/armeabi-v7a apk/lib/arm64-v8a | |
| cp libgame_arm.so apk/lib/armeabi-v7a/libgame.so | |
| cp libgame_arm64.so apk/lib/arm64-v8a/libgame.so | |
| # Verify files exist | |
| ls -la apk/lib/*/* | |
| # Package | |
| $ANDROID_HOME/build-tools/34.0.0/aapt package -f -M android/AndroidManifest.xml \ | |
| -S android/res \ | |
| -I $ANDROID_HOME/platforms/android-34/android.jar \ | |
| -F game.unsigned.apk | |
| # Add libraries (using full paths) | |
| $ANDROID_HOME/build-tools/34.0.0/aapt add game.unsigned.apk \ | |
| lib/armeabi-v7a/libgame.so \ | |
| lib/arm64-v8a/libgame.so | |
| - name: Sign APK | |
| run: | | |
| cd $GITHUB_WORKSPACE | |
| keytool -genkeypair -v -keystore debug.keystore -storepass android -alias androiddebugkey \ | |
| -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=Android Debug" | |
| $ANDROID_HOME/build-tools/34.0.0/apksigner sign \ | |
| --ks debug.keystore \ | |
| --ks-pass pass:android \ | |
| game.unsigned.apk \ | |
| -o game.apk | |
| - name: Upload APK | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: game-apk | |
| path: game.apk |