Repository navigation
Add unity debug symbols generation for Android #30
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: Unity IL2CPP Build | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| branches: [master] | |
| release: | |
| types: [published] | |
| jobs: | |
| build: | |
| name: Build (Unity ${{ matrix.unity }} / ${{ matrix.target }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # - unity: "2019.4.28f1" | |
| # target: "StandaloneWindows64" | |
| # os: "windows-latest" | |
| # - unity: "2019.4.28f1" | |
| # target: "StandaloneLinux64" | |
| # os: "ubuntu-latest" | |
| # - unity: "2019.4.28f1" | |
| # target: "Android" | |
| # os: "ubuntu-latest" | |
| - unity: "2022.3.33f1" | |
| target: "StandaloneWindows64" | |
| os: "windows-latest" | |
| - unity: "2022.3.33f1" | |
| target: "StandaloneLinux64" | |
| os: "ubuntu-latest" | |
| - unity: "2022.3.33f1" | |
| target: "Android" | |
| os: "ubuntu-latest" | |
| - unity: "6000.0.40f1" | |
| target: "StandaloneWindows64" | |
| os: "windows-latest" | |
| - unity: "6000.0.40f1" | |
| target: "StandaloneLinux64" | |
| os: "ubuntu-latest" | |
| - unity: "6000.0.40f1" | |
| target: "Android" | |
| os: "ubuntu-latest" | |
| - unity: "6000.3.21f1" | |
| target: "StandaloneWindows64" | |
| os: "windows-latest" | |
| - unity: "6000.3.21f1" | |
| target: "StandaloneLinux64" | |
| os: "ubuntu-latest" | |
| - unity: "6000.3.21f1" | |
| target: "Android" | |
| os: "ubuntu-latest" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| # - name: Cache Library | |
| # uses: actions/cache@v4 | |
| # with: | |
| # path: Library | |
| # key: ${{ runner.os }}-unity-${{ matrix.unity }}-${{ matrix.target }}-library-${{ hashFiles('**/Packages/manifest.json') }} | |
| - name: Setup Unity | |
| uses: game-ci/unity-builder@v4 | |
| with: | |
| unityVersion: ${{ matrix.unity }} | |
| targetPlatform: ${{ matrix.target }} | |
| buildsPath: build | |
| androidSymbolType: ${{ matrix.target == 'Android' && 'debugging' || 'none' }} | |
| gitPrivateToken: ${{ secrets.GITHUB_TOKEN }} | |
| env: | |
| UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
| UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
| UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
| # - name: Run Unity build | |
| # run: | | |
| # outdir="$GITHUB_WORKSPACE/build/${{ matrix.unity }}/${{ matrix.target }}" | |
| # # If a file named 'build' exists it blocks directory creation — remove it | |
| # mkdir -p "$outdir" | |
| # chmod -R u+rwX "$GITHUB_WORKSPACE/build" | |
| # # Replace `BuildScript.PerformBuild` with your project's build method. | |
| # /opt/unity/Editor/Unity -batchmode -nographics -quit -projectPath "$GITHUB_WORKSPACE" -buildTarget ${{ matrix.target }} -executeMethod BuildScript.PerformBuild -logFile "$outdir/build.log" || true | |
| # game-ci/unity-builder runs the build in a root-owned Docker container on Linux, | |
| # leaving build/ owned by root — reclaim it for the runner user before writing into it below. | |
| - name: Fix build output permissions | |
| if: runner.os != 'Windows' | |
| run: sudo chown -R "$(id -u):$(id -g)" build | |
| # libunity.so equivalents get copied into build/<target>/ so the archive | |
| # and artifact/release upload steps below pick them up automatically. | |
| - name: "Add libunity.so (Android: patch + extract)" | |
| if: matrix.target == 'Android' | |
| shell: bash | |
| run: | | |
| apk=$(find "build/${{ matrix.target }}" -maxdepth 1 -name '*.apk' | head -n1) | |
| unzip -p "$apk" lib/arm64-v8a/libunity.so > "build/${{ matrix.target }}/libunity-unpatched.so" | |
| symbols_zip=$(find "build/${{ matrix.target }}" -name '*.symbols.zip' | head -n1) | |
| symbol_entry=$(unzip -Z1 "$symbols_zip" | grep -E '(^|/)arm64-v8a/libunity(\.so|\.(sym|dbg)\.so|\.so\.(sym|dbg))$') | |
| unzip -p "$symbols_zip" "$symbol_entry" > "build/${{ matrix.target }}/libunity.sym.so" | |
| curl -L -o patcher.zip "https://security-patches.unity.com/bc0977e0-21a9-4f6e-9414-4f44b242110a/unity-patcher/UnityApplicationPatcher-1.3.3-Linux.zip" | |
| mkdir -p unity-application-patcher | |
| unzip -q patcher.zip -d unity-application-patcher | |
| chmod +x unity-application-patcher/UnityApplicationPatcherCLI | |
| export LD_LIBRARY_PATH="$GITHUB_WORKSPACE/unity-application-patcher/Data/StreamingAssets/Android/SDK/platform-tools/lib64" | |
| # The patcher CLI is itself a Unity-built binary and segfaults without a display to open a window against | |
| sudo apt-get update && sudo apt-get install -y xvfb | |
| # versionCode 0 means ignore | |
| xvfb-run -a unity-application-patcher/UnityApplicationPatcherCLI -android -versionCode 0 -applicationPath "$apk" | |
| patched="${apk%.apk}.patched.apk" | |
| unzip -p "$patched" lib/arm64-v8a/libunity.so > "build/${{ matrix.target }}/libunity.so" | |
| - name: "Add libunity.so (Windows: UnityPlayer.dll)" | |
| if: matrix.target == 'StandaloneWindows64' | |
| shell: bash | |
| run: | | |
| player=$(find "build/${{ matrix.target }}" -iname 'UnityPlayer.dll' | head -n1) | |
| cp "$player" "build/${{ matrix.target }}/libunity.so" | |
| - name: "Add libunity.so (Linux: UnityPlayer.so)" | |
| if: matrix.target == 'StandaloneLinux64' | |
| shell: bash | |
| run: | | |
| player=$(find "build/${{ matrix.target }}" -iname 'UnityPlayer.so' | head -n1) | |
| cp "$player" "build/${{ matrix.target }}/libunity.so" | |
| - name: Archive build (Linux/macOS) | |
| if: runner.os != 'windows' | |
| run: | | |
| zip -r build-${{ matrix.unity }}-${{ matrix.target }}.zip ./build | |
| - name: Archive build (Windows) | |
| if: runner.os == 'windows' | |
| shell: pwsh | |
| run: | | |
| Compress-Archive -Path build -DestinationPath build-${{ matrix.unity }}-${{ matrix.target }}.zip -Force | |
| - name: Upload to GitHub Release | |
| if: github.event_name == 'release' | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ github.event.release.upload_url }} | |
| asset_path: build-${{ matrix.unity }}-${{ matrix.target }}.zip | |
| asset_name: build-${{ matrix.unity }}-${{ matrix.target }}.zip | |
| asset_content_type: application/zip | |
| - name: Upload build artifact | |
| if: github.event_name != 'release' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-${{ matrix.unity }}-${{ matrix.target }} | |
| path: build/ |