---
name: Run Tests & Publishing
on: push
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
profile: minimal
- name: Restore Rust Cache
uses: Swatinem/rust-cache@v1
- name: Run cargo fmt -- --check
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Run cargo clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout Project
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
profile: minimal
- name: Restore Rust Cache
uses: Swatinem/rust-cache@v1
- name: Run cargo publish
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: actions-rs/cargo@v1
with:
command: publish
args: --token ${{ secrets.CRATES_IO_TOKEN }}