Repository navigation
83 lines (83 loc) · 2.8 KB
/
Copy pathrelease.yml
File metadata and controls
83 lines (83 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Check and release Rust crate
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
inputs:
publish:
description: Publish the checked version to crates.io
type: boolean
default: false
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
MSRV: '1.85.0'
STABLE: '1.99.1'
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master
with:
toolchain: ${{ env.STABLE }}
components: rustfmt
- run: cargo fmt --check
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master
with:
toolchain: ${{ env.STABLE }}
components: clippy
- run: cargo clippy --locked --all-targets -- -D warnings
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [msrv, stable]
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master
with:
toolchain: ${{ matrix.rust == 'msrv' && env.MSRV || env.STABLE }}
- run: cargo test --locked
- run: python3 .ci/check.py
- run: cargo publish --dry-run --locked
if: matrix.rust == 'stable'
publish:
if: github.event_name == 'workflow_dispatch' && inputs.publish && github.ref == 'refs/heads/main'
needs: [format, lint, test]
runs-on: ubuntu-latest
environment: crates-io
permissions:
contents: read
id-token: write
env:
# First release only. crates.io trusted publishing needs a crate that already exists,
# so 0.1.0 uses a CARGO_REGISTRY_TOKEN repository secret. After it is published, add the
# trusted publisher on crates.io, delete the secret and revoke the token.
BOOTSTRAP_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master
with:
toolchain: ${{ env.STABLE }}
- uses: rust-lang/crates-io-auth-action@3268eb413133e2960fa4ae0e963ca76380c54cd9 # v1.0.6
if: env.BOOTSTRAP_TOKEN == ''
id: auth
- run: cargo publish --locked
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token || env.BOOTSTRAP_TOKEN }}