|
1 | 1 | name: build
|
2 | 2 |
|
3 |
| -on: [push] |
| 3 | +on: [push, pull_request] |
4 | 4 |
|
5 | 5 | jobs:
|
6 | 6 | test:
|
| 7 | + runs-on: ubuntu-latest |
| 8 | + |
| 9 | + env: |
| 10 | + RUSTFLAGS: --deny warnings |
| 11 | + |
7 | 12 | strategy:
|
8 | 13 | matrix:
|
9 | 14 | toolchain: [stable, beta, nightly]
|
10 | 15 |
|
11 |
| - runs-on: ubuntu-latest |
12 |
| - |
13 | 16 | steps:
|
14 |
| - - uses: actions/checkout@v2 |
| 17 | + - uses: actions/checkout@v3 |
15 | 18 |
|
16 |
| - - uses: actions-rs/toolchain@v1 |
| 19 | + - uses: dtolnay/rust-toolchain@master |
17 | 20 | with:
|
18 | 21 | toolchain: ${{ matrix.toolchain }}
|
19 |
| - components: rustfmt, clippy |
20 |
| - override: true |
| 22 | + components: clippy, rustfmt |
21 | 23 |
|
22 | 24 | - name: Rustfmt
|
23 | 25 | run: cargo fmt -- --check
|
24 | 26 |
|
25 | 27 | - name: Clippy
|
26 |
| - run: cargo clippy -- -D warnings -D clippy::use-self -D clippy::items-after-statements -D clippy::if-not-else |
| 28 | + run: cargo clippy --workspace --all-targets -- -D warnings -D clippy::use-self -D clippy::items-after-statements -D clippy::if-not-else |
27 | 29 |
|
28 | 30 | - name: Test
|
29 |
| - run: cargo test --workspace --locked |
| 31 | + run: cargo test --workspace |
| 32 | + |
| 33 | + publish: |
| 34 | + needs: [test] |
| 35 | + if: startsWith(github.ref, 'refs/tags/') |
| 36 | + |
| 37 | + runs-on: ubuntu-latest |
| 38 | + |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v3 |
| 41 | + - uses: dtolnay/rust-toolchain@stable |
| 42 | + |
| 43 | + - name: Calculate version from tag |
| 44 | + id: version |
| 45 | + run: echo "value=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 46 | + |
| 47 | + - name: Check tag against package version |
| 48 | + run: grep '^version = "${{ steps.version.outputs.value }}"$' Cargo.toml |
| 49 | + |
| 50 | + - name: Publish |
| 51 | + env: |
| 52 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} |
| 53 | + run: cargo publish |
0 commit comments