name: rust on: push: branches: [main] pull_request: branches: [main] workflow_dispatch: env: CARGO_TERM_COLOR: always jobs: build: name: Build ${{ matrix.target }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: include: - target: x86_64-unknown-linux-gnu artifact: unixtract-linux bin: unixtract - target: x86_64-pc-windows-gnu artifact: unixtract-windows.exe bin: unixtract.exe steps: - name: Checkout uses: actions/checkout@v4 - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.target }} - name: Install mingw-w64 (Windows target) if: matrix.target == 'x86_64-pc-windows-gnu' run: sudo apt-get update && sudo apt-get install -y gcc-mingw-w64-x86-64 - name: Cache cargo uses: actions/cache@v4 with: path: | ~/.cargo/registry ~/.cargo/git target key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} - name: Build run: cargo build --release --target ${{ matrix.target }} - name: Rename binary run: cp "target/${{ matrix.target }}/release/${{ matrix.bin }}" "${{ matrix.artifact }}" - name: Upload artifact uses: actions/upload-artifact@v4 with: name: ${{ matrix.artifact }} path: ${{ matrix.artifact }} if-no-files-found: error