name: Rust on: push: branches: [ "main" ] tags: - v[0-9]+.* pull_request: branches: [ "main" ] env: CARGO_TERM_COLOR: always jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Cache cargo registry uses: actions/cache@v4 with: path: ~/.cargo/registry key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} - name: Cache cargo index uses: actions/cache@v4 with: path: ~/.cargo/git key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} - name: Cache cargo build uses: actions/cache@v4 with: path: target key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} - name: Build run: cargo build --release - name: Run tests run: cargo test --release - name: Run clippy run: cargo clippy -- -D warnings - name: Check formatting run: cargo fmt -- --check create-release: if: startsWith(github.ref, 'refs/tags/') permissions: contents: write runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: taiki-e/create-gh-release-action@v1 with: token: ${{ secrets.GITHUB_TOKEN }} upload-assets: if: startsWith(github.ref, 'refs/tags/') needs: create-release permissions: contents: write strategy: matrix: include: - target: x86_64-unknown-linux-gnu os: ubuntu-latest - target: x86_64-apple-darwin os: macos-latest - target: x86_64-pc-windows-msvc os: windows-latest runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - uses: taiki-e/upload-rust-binary-action@v1.27.0 with: bin: noentropy target: ${{ matrix.target }} tar: unix zip: windows token: ${{ secrets.GITHUB_TOKEN }}