-
Notifications
You must be signed in to change notification settings - Fork 0
199 lines (188 loc) · 5.59 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
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
name: Rust continuous integration
on:
push:
branches:
- main
tags:
- "v*.*.*"
pull_request:
branches:
- "*"
permissions:
actions: none
checks: none
contents: read
deployments: none
id-token: none
issues: none
packages: none
pages: none
pull-requests: none
repository-projects: none
security-events: none
statuses: none
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Rust latest stable
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Rust latest stable
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Run checks
run: cargo check
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Rust latest stable
uses: dtolnay/rust-toolchain@master
with:
components: rustfmt
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Rust latest stable
uses: dtolnay/rust-toolchain@master
with:
components: clippy
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Run lints
run: cargo clippy -- -D warnings
clippy-analyze:
name: Run rust-clippy analyzing
runs-on: ubuntu-latest
continue-on-error: true
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- name: Rust latest stable
uses: dtolnay/rust-toolchain@master
with:
components: clippy
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Install required cargo
run: cargo install clippy-sarif sarif-fmt
- name: Run rust-clippy
run:
cargo clippy
--all-features
--message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
continue-on-error: true
- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: rust-clippy-results.sarif
wait-for-processing: true
build-release:
name: "Build release"
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/')
needs:
- test
- check
- fmt
- clippy
strategy:
matrix:
include:
- target: "aarch64-unknown-linux-musl"
binary: "email-view-tracker"
- target: "arm-unknown-linux-musleabihf"
binary: "email-view-tracker"
- target: "armv7-unknown-linux-musleabihf"
binary: "email-view-tracker"
- target: "x86_64-unknown-linux-musl"
binary: "email-view-tracker"
- target: "i686-unknown-linux-musl"
binary: "email-view-tracker"
- target: "x86_64-pc-windows-gnu"
binary: "email-view-tracker.exe"
steps:
- uses: actions/checkout@v4
- name: Rust latest stable
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: install cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: compile with cross
run: cross build --target ${{ matrix.target }} --release
- uses: actions/upload-artifact@v3
with:
name: "EVT_${{ matrix.target }}"
path: "target/${{ matrix.target }}/release/${{ matrix.binary }}"
retention-days: 1
if-no-files-found: error
release:
name: "Create release"
runs-on: ubuntu-latest
needs:
- "build-release"
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
id: download
with:
path: artifact-binaries
- name: Rename files
run: |
TARGETS=( \
'aarch64-unknown-linux-musl' 'arm-unknown-linux-musleabihf' \
'armv7-unknown-linux-musleabihf' 'x86_64-unknown-linux-musl' \
'i686-unknown-linux-musl' 'x86_64-pc-windows-gnu' \
)
mkdir release-binaries
for target in "${TARGETS[@]}"; do
TARGET_PATH="${{steps.download.outputs.download-path}}/EVT_$target/"
TARGET_FILE=$(find "$TARGET_PATH" -maxdepth 1 -name "email-view-tracker*" -type f)
if [[ $target == "arm-unknown-linux-musleabihf" ]]; then
# rename "arm" to "armv6" to explicitly state ARM version
mv "$TARGET_FILE" "./release-binaries/email-view-tracker_armv6-unknown-linux-musleabihf"
elif [[ $target == "x86_64-pc-windows-gnu" ]]; then
mv "$TARGET_FILE" "./release-binaries/email-view-tracker_$target.exe"
else
mv "$TARGET_FILE" "./release-binaries/email-view-tracker_$target"
fi
done
- name: Create release
uses: "softprops/action-gh-release@v1"
with:
generate_release_notes: true
draft: true
files: |
release-binaries/*