name: Rust on: push: branches: ["main"] tags: ["v*.*.*"] pull_request: branches: ["main"] workflow_dispatch: workflow_call: env: CARGO_TERM_COLOR: always jobs: test-build: strategy: fail-fast: false matrix: include: - { os: "macos-latest", target: "aarch64-apple-darwin" } - { os: "ubuntu-latest", target: "x86_64-unknown-linux-gnu" } - { os: "windows-latest", target: "x86_64-pc-windows-msvc", ext: ".exe", } - { os: "ubuntu-24.04-arm", target: "aarch64-unknown-linux-gnu" } runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v6 - name: Setup sccache if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' uses: mozilla-actions/sccache-action@v0.0.8 - name: Configure sccache if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' run: | echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV" echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV" - name: Setup rust cache action uses: swatinem/rust-cache@v2 with: cache-on-failure: true - name: install build dependencies on ubuntu and cache if: contains(matrix.os, 'ubuntu') uses: awalsh128/cache-apt-pkgs-action@latest with: packages: libfontconfig1-dev libgoogle-perftools-dev google-perftools version: latest # could be anything - name: Install clippy and fmt run: rustup component add clippy rustfmt - name: Clippy run: cargo clippy --locked -- -D warnings - name: Tests run: cargo test --locked - name: Check fmt run: cargo fmt -- --check - name: Run benchmarks as tests run: cargo test --locked --benches -- adobe_example - name: Set build mode shell: bash run: if [ "${{github.ref_type}}" == "tag" ] || [ ${{ github.event_name == 'push' && github.ref_name == 'main' }} ]; then echo "BMODE=production">>"$GITHUB_ENV"; fi - name: Build in ${{env.BMODE || 'debug'}} mode run: cargo build --verbose --locked --profile ${{env.BMODE || 'dev'}} - name: Prepare artifact shell: bash run: | mkdir -p dist cp "target/${{env.BMODE || 'debug'}}/tdf${{ matrix.ext }}" dist/tdf-${{ matrix.target }}${{ matrix.ext }} tree dist || ls -la dist - name: Upload artifacts uses: actions/upload-artifact@v5 with: name: tdf-${{ matrix.target }} path: dist/tdf* tag-release: name: Release on tag push runs-on: ubuntu-slim if: github.ref_type == 'tag' needs: test-build steps: - uses: actions/download-artifact@v6 with: pattern: "**/tdf-*" path: release-artifacts merge-multiple: true - name: What's up? run: tree release-artifacts # beautiful! - name: Create a GitHub release uses: softprops/action-gh-release@v2 with: draft: true generate_release_notes: true files: release-artifacts/* prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}