name: Rust
on:
push:
branches: [ "master" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
prefix-key: "v0-rust"
shared-key: "build"
key: "ci"
env-vars: "CARGO CC CFLAGS CXX CMAKE RUST"
workspaces: ". -> target"
cache-targets: "true"
cache-on-failure: "false"
cache-all-crates: "false"
save-if: ${{ github.ref == 'refs/heads/master' }}
lookup-only: "false"
cache-provider: "github"
cache-bin: "false"
- name: Check format
run: cargo fmt --all --check
- name: Run tests
run: cargo test --all-features --doc --verbose
publish:
runs-on: ubuntu-latest
needs: ['build']
environment: cargo
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
prefix-key: "v0-rust"
shared-key: "publish"
key: "ci"
env-vars: "CARGO CC CFLAGS CXX CMAKE RUST"
workspaces: ". -> target"
cache-targets: "true"
cache-on-failure: "false"
cache-all-crates: "false"
save-if: ${{ github.ref == 'refs/heads/master' }}
lookup-only: "false"
cache-provider: "github"
cache-bin: "false"
- name: Build
run: cargo build --release --verbose
- name: Publish
uses: tu6ge/publish-action@v0.4.13
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}