1
- name : Build Release
1
+ name : main
2
2
3
3
on :
4
4
push :
5
- branches : [main, "release-*"]
6
5
pull_request :
7
- branches : ["main"]
6
+ workflow_call :
8
7
9
8
env :
10
9
CARGO_TERM_COLOR : always
13
12
FILE_RAYHUNTER_DAEMON_TPLINK : ../../rayhunter-daemon-tplink/rayhunter-daemon
14
13
15
14
jobs :
15
+ files_changed :
16
+ name : Detect file changes
17
+ runs-on : ubuntu-latest
18
+ permissions :
19
+ contents : read
20
+ outputs :
21
+ code_changed : ${{ steps.files_changed.outputs.code_count }}
22
+ daemon_changed : ${{ steps.files_changed.outputs.daemon_count }}
23
+ docs_changed : ${{ steps.files_changed.outputs.docs_count }}
24
+ installer_changed : ${{ steps.files_changed.outputs.installer_count }}
25
+ rootshell_changed : ${{ steps.files_changed.outputs.rootshell_count }}
26
+ steps :
27
+ - uses : actions/checkout@v4
28
+ with :
29
+ fetch-depth : 0
30
+ - name : detect file changes
31
+ id : files_changed
32
+ run : |
33
+ lcommit=${{ github.event.pull_request.base.sha || 'origin/main' }}
34
+ if [ ${{ github.ref }} = 'refs/heads/main' ]
35
+ then
36
+ echo "building everything"
37
+ echo code_count=forced >> "$GITHUB_OUTPUT"
38
+ echo daemon_count=forced >> "$GITHUB_OUTPUT"
39
+ echo docs_count=forced >> "$GITHUB_OUTPUT"
40
+ echo installer_count=forced >> "$GITHUB_OUTPUT"
41
+ echo rootshell_count=forced >> "$GITHUB_OUTPUT"
42
+ else
43
+ echo "code_count=$(git diff --name-only $lcommit...HEAD | grep -e ^bin -e ^installer -e ^lib -e ^rootshell -e ^telcom-parser | wc -l)" >> "$GITHUB_OUTPUT"
44
+ echo "daemon_count=$(git diff --name-only $lcommit...HEAD | grep -e ^bin -e ^lib -e ^telcom-parser | wc -l)" >> "$GITHUB_OUTPUT"
45
+ echo "docs_count=$(git diff --name-only $lcommit...HEAD | grep -e ^book.toml -e ^doc | wc -l)" >> "$GITHUB_OUTPUT"
46
+ echo "installer_count=$(git diff --name-only $lcommit...HEAD | grep -e ^installer | wc -l)" >> "$GITHUB_OUTPUT"
47
+ echo "rootshell_count=$(git diff --name-only $lcommit...HEAD | grep -e ^rootshell | wc -l)" >> "$GITHUB_OUTPUT"
48
+ fi
49
+
50
+ mdbook_test :
51
+ name : Test mdBook Documentation builds
52
+ needs : files_changed
53
+ if : needs.files_changed.outputs.docs_changed != '0'
54
+ runs-on : ubuntu-latest
55
+ permissions :
56
+ contents : read
57
+ steps :
58
+ - uses : actions/checkout@v4
59
+ - name : Install mdBook
60
+ run : |
61
+ cargo install mdbook --no-default-features --features search --vers "^0.4" --locked
62
+ - name : Test mdBook
63
+ run : mdbook test
64
+
65
+ mdbook_publish :
66
+ name : Publish mdBook to Github Pages
67
+ needs : mdbook_test
68
+ if : ${{ github.event_name != 'pull_request' }}
69
+ permissions :
70
+ pages : write
71
+ contents : write
72
+ id-token : write
73
+ runs-on : ubuntu-latest
74
+ steps :
75
+ - uses : actions/checkout@v4
76
+ - name : Install mdBook
77
+ run : |
78
+ cargo install mdbook --no-default-features --features search --vers "^0.4" --locked
79
+
80
+ - name : Build mdBook
81
+ run : mdbook build
82
+
83
+ - name : Setup Pages
84
+ uses : actions/configure-pages@v4
85
+ - name : Upload artifact
86
+ uses : actions/upload-pages-artifact@v3
87
+ with :
88
+ path : book
89
+ - name : Deploy to Github Pages
90
+ uses : actions/deploy-pages@v4
91
+
92
+ check_and_test :
93
+ needs : files_changed
94
+ if : needs.files_changed.outputs.code_changed != '0'
95
+ strategy :
96
+ matrix :
97
+ device :
98
+ - name : tplink
99
+ - name : orbic
100
+ runs-on : ubuntu-latest
101
+ permissions :
102
+ contents : read
103
+ env :
104
+ NO_FIRMWARE_BIN=true
105
+ steps :
106
+ - uses : actions/checkout@v4
107
+ - name : Check formatting
108
+ run : cargo fmt --all --check
109
+ - name : Check
110
+ run : |
111
+ pushd bin/web
112
+ npm install
113
+ npm run build
114
+ popd
115
+ cargo check --verbose --no-default-features --features=${{ matrix.device.name }}
116
+ - name : Run tests
117
+ run : |
118
+ cargo test --verbose --no-default-features --features=${{ matrix.device.name }}
119
+ - name : Run clippy
120
+ run : |
121
+ cargo clippy --verbose --no-default-features --features=${{ matrix.device.name }}
122
+
123
+ windows_installer_check_and_test :
124
+ needs : files_changed
125
+ if : needs.files_changed.outputs.installer_changed != '0'
126
+ runs-on : windows-latest
127
+ permissions :
128
+ contents : read
129
+ env :
130
+ NO_FIRMWARE_BIN=true
131
+ steps :
132
+ - uses : actions/checkout@v4
133
+ - name : cargo check
134
+ shell : bash
135
+ run : |
136
+ cd installer
137
+ cargo check --verbose
138
+ - name : cargo test
139
+ shell : bash
140
+ run : |
141
+ cd installer
142
+ cargo test --verbose --no-default-features
143
+
16
144
build_rayhunter_check :
145
+ if : needs.files_changed.outputs.daemon_changed != '0'
146
+ needs :
147
+ - check_and_test
148
+ - files_changed
149
+ permissions :
150
+ contents : read
151
+ packages : write
17
152
strategy :
18
153
matrix :
19
154
platform :
@@ -42,8 +177,15 @@ jobs:
42
177
name : rayhunter-check-${{ matrix.platform.name }}
43
178
path : target/release/rayhunter-check${{ matrix.platform.os == 'windows-latest' && '.exe' || '' }}
44
179
if-no-files-found : error
180
+
45
181
build_rootshell :
182
+ if : needs.files_changed.outputs.rootshell_changed != '0'
183
+ needs :
184
+ - check_and_test
185
+ - files_changed
46
186
runs-on : ubuntu-latest
187
+ permissions :
188
+ contents : read
47
189
steps :
48
190
- uses : actions/checkout@v4
49
191
- uses : dtolnay/rust-toolchain@stable
@@ -56,7 +198,15 @@ jobs:
56
198
name : rootshell
57
199
path : target/armv7-unknown-linux-musleabihf/firmware/rootshell
58
200
if-no-files-found : error
201
+
59
202
build_rayhunter :
203
+ if : needs.files_changed.outputs.daemon_changed != '0'
204
+ needs :
205
+ - check_and_test
206
+ - files_changed
207
+ permissions :
208
+ contents : read
209
+ packages : write
60
210
strategy :
61
211
matrix :
62
212
device :
@@ -88,9 +238,17 @@ jobs:
88
238
name : rayhunter-daemon-${{ matrix.device.name }}
89
239
path : target/armv7-unknown-linux-musleabihf/firmware/rayhunter-daemon
90
240
if-no-files-found : error
241
+
91
242
build_rust_installer :
243
+ if : needs.files_changed.outputs.installer_changed != '0'
244
+ permissions :
245
+ contents : read
246
+ packages : write
92
247
needs :
93
248
- build_rayhunter
249
+ - build_rootshell
250
+ - files_changed
251
+ - windows_installer_check_and_test
94
252
strategy :
95
253
matrix :
96
254
platform :
@@ -124,6 +282,9 @@ jobs:
124
282
if-no-files-found : error
125
283
126
284
build_release_zip :
285
+ permissions :
286
+ contents : read
287
+ packages : write
127
288
needs :
128
289
- build_rayhunter_check
129
290
- build_rootshell
0 commit comments