-
Notifications
You must be signed in to change notification settings - Fork 21
222 lines (204 loc) · 6.24 KB
/
rust.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
name: Test and Build Rust
on:
push:
pull_request:
workflow_dispatch:
env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
jobs:
rustfmt:
runs-on: ubuntu-latest
steps:
- name: Setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt
- uses: actions/checkout@v4
- run: cargo fmt --check --verbose
clippy:
name: Clippy ${{ matrix.toolchain }}
runs-on: ubuntu-latest
continue-on-error: ${{ (matrix.toolchain == 'beta') || (matrix.toolchain == 'nightly') }}
strategy:
fail-fast: false
matrix:
toolchain:
- stable
- beta
- nightly
env:
RUSTFLAGS: --deny warnings
steps:
- name: Setup Rust
id: rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
components: clippy
- uses: actions/checkout@v4
- run: cargo fetch
- uses: actions/cache@v4
with:
key: clippy-${{ steps.rust.outputs.cachekey }}-${{ hashFiles('**/Cargo.*') }}
path: target/
- run: cargo clippy --offline --all-targets
- run: cargo doc --offline --no-deps
msrv: # minimum supported Rust version
name: MSRV ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
env:
RUSTFLAGS: --allow unknown-lints --deny warnings
steps:
- name: Install cargo-hack
uses: taiki-e/install-action@v2
with:
tool: cargo-hack
- uses: actions/checkout@v4
- run: cargo fetch --locked
- uses: actions/cache@v4
with:
key: msrv-${{ matrix.os }}-${{ hashFiles('**/Cargo.*') }}
path: target/
- run: cargo hack --keep-going --feature-powerset --no-dev-deps --rust-version check --offline
test:
name: Test ${{ matrix.toolchain }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
strategy:
fail-fast: false
matrix:
toolchain:
- stable
- beta
- nightly
os:
- ubuntu-latest
- macos-latest
- windows-latest
steps:
- name: Setup Rust
id: rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
- uses: actions/checkout@v4
- run: cargo fetch
- uses: actions/cache@v4
with:
key: test-${{ matrix.os }}-${{ steps.rust.outputs.cachekey }}-${{ hashFiles('**/Cargo.*') }}
path: target/
- run: cargo build --offline --all-targets
- run: cargo test --offline --no-fail-fast
release:
name: Release ${{ matrix.triple }}
runs-on: ${{ matrix.os }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- triple: x86_64-unknown-linux-gnu
os: ubuntu-latest
rpm: true
- triple: aarch64-unknown-linux-gnu
os: ubuntu-latest
rpm: true
- triple: armv7-unknown-linux-gnueabihf
os: ubuntu-latest
rpm: true
- triple: arm-unknown-linux-gnueabihf
os: ubuntu-latest
- triple: riscv64gc-unknown-linux-gnu
os: ubuntu-latest
- triple: x86_64-apple-darwin
os: macos-latest
- triple: aarch64-apple-darwin
os: macos-latest
- triple: x86_64-pc-windows-msvc
os: windows-latest
- triple: aarch64-pc-windows-msvc
os: windows-latest
env:
RUSTFLAGS: --deny warnings
steps:
- name: Setup Rust
id: rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: ${{ matrix.triple }}
- name: Install cargo tools
if: runner.os == 'Linux'
uses: taiki-e/install-action@v2
with:
tool: cross,cargo-deb,cargo-generate-rpm
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set artifact name
shell: bash
run: |
version="$(git describe --tags --match "v*.*.*" --always)"
echo "version: $version"
echo "GIT_TAG_VERSION=$version" >> $GITHUB_ENV
name="mqttui-$version-${{ matrix.triple }}"
echo "artifact: $name"
echo "ARTIFACT_NAME=$name" >> $GITHUB_ENV
- run: cargo fetch --locked
- uses: actions/cache@v4
with:
key: release-${{ matrix.triple }}-${{ steps.rust.outputs.cachekey }}-${{ hashFiles('**/Cargo.*') }}
path: target/
- name: Build
run: ${{ runner.os == 'Linux' && 'cross' || 'cargo' }} build --release --offline --target ${{ matrix.triple }}
- name: Package tar.gz (*nix)
if: runner.os != 'Windows'
run: >
tar -cv
CHANGELOG.md LICENSE README.md
-C target/ completions/ -C ../
-C target/ manpages/ -C ../
-C target/${{ matrix.triple }}/release/ mqttui
| gzip --best > ${{ env.ARTIFACT_NAME }}.tar.gz
- name: Package zip (Windows)
if: runner.os == 'Windows'
run: >
7z a ${{ env.ARTIFACT_NAME }}.zip
CHANGELOG.md LICENSE README.md
./target/completions/
./target/manpages/
./target/${{ matrix.triple }}/release/mqttui.exe
- name: Package deb
if: runner.os == 'Linux'
run: cargo deb --no-build --no-strip --target ${{ matrix.triple }} --output ${{ env.ARTIFACT_NAME }}.deb
- name: Package rpm
if: matrix.rpm
run: cargo generate-rpm --auto-req disabled --target ${{ matrix.triple }} --output ${{ env.ARTIFACT_NAME }}.rpm
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.triple }}
path: |
*.deb
*.rpm
*.tar.gz
*.zip
- name: Create GitHub release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: |
*.deb
*.rpm
*.tar.gz
*.zip