Build & Release #58
Workflow file for this run
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 & Release | |
| on: | |
| push: | |
| tags: | |
| - "*" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| matrix: | |
| include: | |
| # Linux manylinux | |
| - runner: ubuntu-22.04 | |
| target: x86_64 | |
| rid: linux-x64 | |
| manylinux: manylinux_2_34 | |
| # - runner: ubuntu-22.04 # disabled: lz c dep doesn't build | |
| # target: aarch64 | |
| # rid: linux-arm64 | |
| # manylinux: manylinux_2_34 | |
| # # Linux musllinux # disabled: dotnet still references glibc | |
| # - runner: ubuntu-22.04 | |
| # target: x86_64 | |
| # rid: linux-musl-x64 | |
| # manylinux: musllinux_1_2 | |
| # - runner: ubuntu-22.04 | |
| # target: aarch64 | |
| # rid: linux-musl-arm64 | |
| # manylinux: musllinux_1_2 | |
| # Windows | |
| - runner: windows-latest | |
| target: x64 | |
| rid: win-x64 | |
| manylinux: "" | |
| # MacOS | |
| - runner: macos-13 | |
| target: x86_64 | |
| rid: osx-x64 | |
| manylinux: "" | |
| - runner: macos-14 | |
| target: aarch64 | |
| rid: osx-arm64 | |
| manylinux: "" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v6 | |
| - uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: "9.x" | |
| - name: Clone TypeTreeGeneratorAPI | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: jakobhellermann/TypeTreeGeneratorAPI | |
| submodules: true | |
| ref: wip | |
| path: TypeTreeGeneratorAPI | |
| - name: Publish TypeTreeGeneratorAPI with dotnet | |
| run: dotnet publish TypeTreeGeneratorAPI/TypeTreeGeneratorAPI -o out --runtime ${{ matrix.rid }} -p:EnableAssetRipper=false -p:EnableAssetStudio=false -p:EnableAssetsTools=true -p:EnableIL2CPP=false | |
| - name: Copy | |
| shell: bash | |
| run: | | |
| if [[ "${{ runner.os }}" == "Windows" ]]; then | |
| cp out/TypeTreeGeneratorAPI.dll data/purelib/unity_scene_repacker.libs | |
| elif [[ "${{ runner.os }}" == "macOS" ]]; then | |
| cp out/libTypeTreeGeneratorAPI.dylib data/purelib/unity_scene_repacker.libs | |
| else | |
| cp out/libTypeTreeGeneratorAPI.so data/purelib/unity_scene_repacker.libs | |
| fi | |
| - name: Build bindings | |
| run: cargo build --release -p bindings | |
| - name: Copy artifacts | |
| shell: bash # todo: replace this with --artifact-dir when finally stable | |
| run: | | |
| if [[ "${{ runner.os }}" == "Windows" ]]; then | |
| cp target/release/unityscenerepacker.dll out/unityscenerepacker.dll | |
| elif [[ "${{ runner.os }}" == "macOS" ]]; then | |
| cp target/release/libunityscenerepacker.dylib out/libunityscenerepacker.dylib | |
| else | |
| cp target/release/libunityscenerepacker.so out/libunityscenerepacker.so | |
| fi | |
| - name: Upload bindings | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bindings-${{ matrix.rid }} | |
| path: out/* | |
| - name: Build cli wheels | |
| uses: jakobhellermann/maturin-action@allow-ld-env | |
| with: | |
| target: ${{ matrix.target }} | |
| args: --release --out dist | |
| sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
| manylinux: ${{ matrix.manylinux }} | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.rid }} | |
| path: dist | |
| sdist: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build sdist | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| command: sdist | |
| args: --out dist | |
| - name: Upload sdist | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-sdist | |
| path: dist | |
| nuget: | |
| name: Build & Publish nuget package | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: sudo apt install mono-devel # https://github.com/NuGet/setup-nuget/issues/168 | |
| - uses: nuget/setup-nuget@v2 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: bindings-* | |
| path: out | |
| - name: List built files | |
| run: ls -R out | |
| - name: Pack NuGet package | |
| run: nuget pack ./bindings/nuget/unityscenerepacker.nuspec | |
| - name: Push to NuGet | |
| env: | |
| NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
| run: nuget push unityscenerepacker.*.nupkg -SkipDuplicate -Source https://api.nuget.org/v3/index.json -ApiKey $NUGET_API_KEY | |
| release: | |
| name: Build & Publish PyPI wheels | |
| runs-on: ubuntu-latest | |
| if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }} | |
| needs: [build, sdist] | |
| permissions: | |
| # Use to sign the release artifacts | |
| id-token: write | |
| # Used to upload release artifacts | |
| contents: write | |
| # Used to generate artifact attestation | |
| attestations: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: wheels-* | |
| - name: Generate artifact attestation | |
| uses: actions/attest-build-provenance@v2 | |
| with: | |
| subject-path: "wheels-*/*" | |
| - name: Publish to PyPI | |
| if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| uses: PyO3/maturin-action@v1 | |
| env: | |
| MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | |
| with: | |
| command: upload | |
| args: --non-interactive --skip-existing wheels-*/* |