-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (84 loc) · 2.45 KB
/
build-test-release.yml
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: Build, test & release
on:
push:
branches:
- main
pull_request: {}
env:
APP_NAME: samling
jobs:
clippy:
name: Check for common code mistakes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run clippy
continue-on-error: true
run: cargo clippy -- -D warnings
fmt:
name: Check code format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run rustfmt
continue-on-error: true
run: cargo fmt --all -- --check
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test --release
cargo-deny:
runs-on: ubuntu-latest
steps:
- uses: jacobsvante/cargo-deny-action@v1
create-release-pr:
name: Conditionally create release PR
needs: [clippy, cargo-deny, test]
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
permissions:
contents: write
pull-requests: write
steps:
- name: Create a release Pull Request
uses: googleapis/release-please-action@v4
with:
skip-github-release: true
publish:
name: Conditionally publish to crates.io
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
permissions:
contents: write
pull-requests: write
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Make cargo command available
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Ensure publishable
run: cargo publish --dry-run
- uses: googleapis/release-please-action@v4
id: release
with:
skip-github-pull-request: true
token: ${{ secrets.EVENT_TRIGGERING_GITHUB_TOKEN }}
- name: Tag major and minor versions in Git
if: ${{ steps.release.outputs.release_created }}
uses: jacobsvante/tag-major-minor-action@v0
with:
major: ${{ steps.release.outputs.major }}
minor: ${{ steps.release.outputs.minor }}
- if: ${{ steps.release.outputs.release_created }}
run: cargo publish