Skip to content

Build & Release

Build & Release #47

Workflow file for this run

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
- 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 importlib to out
if: runner.os == 'windows'
run: cp TypeTreeGeneratorAPI/TypeTreeGeneratorAPI/bin/Release/net9.0/win-x64/native/TypeTreeGeneratorAPI.lib ./out/
- name: Build bindings
env:
RUSTFLAGS: "-L out"
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
env:
RUSTFLAGS: "-L out"
LD_LIBRARY_PATH: "${{ github.workspace }}/out"
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: ${{ matrix.runner }}-${{ matrix.target }}${{ matrix.manylinux }}
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: Pack and Push 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/unityscenerepacker.nuspec
- name: Push to NuGet
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: nuget push unityscenerepacker.*.nupkg --skip-duplicate -Source https://api.nuget.org/v3/index.json -ApiKey $NUGET_API_KEY
release:
name: Release
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-*/*