-
Notifications
You must be signed in to change notification settings - Fork 2
100 lines (89 loc) · 2.36 KB
/
ci.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
99
100
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
name: Build
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
with:
shared-key: ci-build
- name: Check code builds without warnings
run: cargo clippy --locked --verbose --workspace
lint:
runs-on: ubuntu-latest
name: Lint
needs: build
if: ${{ success() }}
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
with:
shared-key: ci-build
save-if: false
- name: Run clippy
run: cargo clippy --verbose --workspace
- name: Check formatting
run: cargo fmt --check --verbose
test:
runs-on: ubuntu-latest
name: Test
needs: build
if: ${{ success() }}
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
with:
shared-key: ci-build
save-if: false
- name: Run Cargo tests
run: cargo test --verbose
docker_publish:
runs-on: ubuntu-latest
name: Publish built container
needs:
- lint
- test
if: success() && github.ref_name == 'main' && github.event_name == 'push'
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: has_server_changed
with:
filters: |
server:
- 'dcspkg_server/**'
- name: Build and publish a Docker image for dcspkg server
if: steps.has_server_changed.outputs.server == 'true'
uses: macbre/push-to-ghcr@v12
with:
image_name: uwcs/dcspkg-server
github_token: ${{ secrets.GITHUB_TOKEN }}
cli_release:
runs-on: ubuntu-latest
name: Release CLI to crates.io
needs:
- lint
- test
if: success() && github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
with:
shared-key: ci-build
save-if: false
- uses: katyo/publish-crates@v1
with:
path: "./dcspkg"
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false