Build unienc #52
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 unienc | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| build-config: | |
| required: true | |
| default: 'release' | |
| type: choice | |
| options: | |
| - debug | |
| - release | |
| env: | |
| _RUST_BUILD_CONFIG: ${{ inputs.build-config == 'debug' && 'debug' || 'release' }} | |
| jobs: | |
| build-wasm: | |
| name: Build unienc (WebAssembly) | |
| runs-on: ubuntu-22.04 # Clang v13 | |
| strategy: | |
| matrix: | |
| emscripten: ["3.1.8-unity", "3.1.38-unity"] | |
| timeout-minutes: 30 | |
| defaults: | |
| run: | |
| working-directory: InstantReplay.Externals/unienc/crates/unienc_c | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: 'true' | |
| - run: git clone https://github.com/Unity-Technologies/emsdk.git | |
| working-directory: InstantReplay.Externals/unienc | |
| - run: | # Install Pre-built Emscripten SDK | |
| ./emsdk install latest | |
| ./emsdk activate latest | |
| ./emsdk install \ | |
| --override-repository emscripten-main-64bit@https://github.com/Unity-Technologies/emscripten/tree/${{ matrix.emscripten }} \ | |
| emscripten-main-64bit | |
| ./emsdk activate emscripten-main-64bit | |
| working-directory: InstantReplay.Externals/unienc/emsdk | |
| # - name: Cache LLVM | |
| # id: cache-llvm | |
| # uses: actions/cache@v4 | |
| # with: | |
| # path: InstantReplay.Externals/unienc/emsdk/llvm/git/build_main_64/bin | |
| # key: ${{ runner.os }}-llvm-${{ matrix.emscripten }} | |
| - run: | # Build & Install LLVM | |
| ./emsdk install \ | |
| --override-repository llvm-git-main-64bit@https://github.com/Unity-Technologies/llvm-project/tree/${{ matrix.emscripten }} \ | |
| llvm-git-main-64bit | |
| mv ./llvm/git/build_${{ matrix.emscripten }}_64 ./llvm/git/build_main_64 | |
| # if: steps.cache-llvm.outputs.cache-hit != 'true' | |
| working-directory: InstantReplay.Externals/unienc/emsdk | |
| # - name: Cache Binaryen | |
| # id: cache-binaryen | |
| # uses: actions/cache@v4 | |
| # with: | |
| # path: InstantReplay.Externals/unienc/emsdk/binaryen/main_64bit_binaryen | |
| # key: ${{ runner.os }}-binaryen-${{ matrix.emscripten }} | |
| - run: | # Build & Install Binaryen | |
| ./emsdk install \ | |
| --override-repository binaryen-main-64bit@https://github.com/Unity-Technologies/binaryen/tree/${{ matrix.emscripten }} \ | |
| binaryen-main-64bit | |
| # if: steps.cache-binaryen.outputs.cache-hit != 'true' | |
| working-directory: InstantReplay.Externals/unienc/emsdk | |
| - run: | | |
| ./emsdk activate binaryen-main-64bit | |
| ./emsdk activate llvm-git-main-64bit | |
| working-directory: InstantReplay.Externals/unienc/emsdk | |
| - run: rustup default stable | |
| - run: rustup target add wasm32-unknown-emscripten | |
| - run: | | |
| source ./emsdk/emsdk_env.sh | |
| cargo build --target wasm32-unknown-emscripten --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }}-wasm --no-default-features | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: wasm32-unknown-emscripten/${{ matrix.emscripten }} | |
| path: InstantReplay.Externals/unienc/target/wasm32-unknown-emscripten/${{ env._RUST_BUILD_CONFIG }}-wasm/libunienc_c.a | |
| retention-days: 1 | |
| update-unity-native: | |
| name: Push unienc native libraries | |
| needs: [build-wasm] | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: 'true' | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: ./Packages/jp.co.cyberagent.instant-replay/UniEnc/Plugins/ | |
| - run: | | |
| cargo install cargo-about | |
| cargo about generate about.hbs > ../../THIRD-PARTY-NOTICES.md | |
| working-directory: InstantReplay.Externals/unienc | |
| - run: | | |
| git add ./Packages/jp.co.cyberagent.instant-replay/UniEnc/Plugins | |
| git add ./THIRD-PARTY-NOTICES.md | |
| git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git commit -m "Update unienc native binaries" | |
| git push origin ${{ github.ref_name }} | |
| permissions: | |
| contents: write |