russimp-sys 2.0.0

Raw Assimp bindings for Rust
name: Release

on:
  push:
    tags:
      - 'v*'

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    name: Build
    runs-on: ${{ matrix.target.os }}
    strategy:
      matrix:
        target:
          - os: ubuntu-latest
            triple: x86_64-unknown-linux-gnu
          - os: macos-latest
            triple: x86_64-apple-darwin
          - os: windows-latest
            triple: x86_64-pc-windows-msvc
        features: [ 'build-assimp', 'static-link' ]
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: true

      # LLVM comes preinstalled on Windows and macOS runners.
      - name: Install LLVM
        if: runner.os == 'Linux'
        uses: KyleMayes/install-llvm-action@v1
        with:
          directory: ${{ runner.temp }}/llvm
          cached: true
          version: '14.0'

      # CMake and Rust are preinstalled on all runners.

      - name: Update Rust
        run: |
          rustup default stable

      - name: Cache Rust
        uses: Swatinem/rust-cache@v2

      - name: Build
        run: cargo build --target ${{ matrix.target.triple }} --features ${{ matrix.features }}

      - name: Package Assimp
        run: cargo run --bin package --target ${{ matrix.target.triple }} --bin package --features ${{ matrix.features }}
        env:
          RUSSIMP_PACKAGE_DIR: ./russimp-package

      - name: Upload artifacts
        uses: actions/upload-artifact@v3
        with:
          name: russimp-packages
          path: ${{ env.RUSSIMP_PACKAGE_DIR }}/*
        env:
          RUSSIMP_PACKAGE_DIR: ./russimp-package

  publish:
    name: Publish Release
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: true

      - name: Download artifacts
        uses: actions/download-artifact@v3
        with:
          name: russimp-packages
          path: ${{ runner.temp }}/russimp-package

      - name: List artifacts
        run: |
          echo "Received artifacts:"
          ls -l $RUSSIMP_PACKAGE_DIR
        env:
          RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp-package

      - name: Publish release on GitHub
        uses: softprops/action-gh-release@v1
        with:
          generate_release_notes: true
          body: |
            This release was automatically created by GitHub Actions.
          files: |
            ${{ env.RUSSIMP_PACKAGE_DIR }}/*
          token: ${{ secrets.ACCESS_TOKEN }}
        env:
          RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp-package

      - name: Publish release on crates.io
        run: cargo publish --features prebuilt --token $CRATES_IO_TOKEN
        env:
          CRATES_IO_TOKEN: ${{ secrets.CRATESIO_TOKEN }}
          RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp-package