|
6 | 6 | tags: [ "v*" ] |
7 | 7 | pull_request: |
8 | 8 | branches: [ "main", "master", "rust_new" ] |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + features: |
| 12 | + description: 'Features to enable (comma-separated, e.g. sqlite-bundled,mysql-bundled)' |
| 13 | + required: false |
| 14 | + default: 'sqlite-bundled' |
| 15 | + target_platforms: |
| 16 | + description: 'Target platforms to build (comma-separated, e.g. linux,windows,macos)' |
| 17 | + required: false |
| 18 | + default: 'linux,windows,macos' |
| 19 | + build_cli: |
| 20 | + description: 'Build CLI binary' |
| 21 | + type: boolean |
| 22 | + default: true |
| 23 | + build_webapi: |
| 24 | + description: 'Build WebAPI binary' |
| 25 | + type: boolean |
| 26 | + default: true |
9 | 27 |
|
10 | 28 | env: |
11 | 29 | CARGO_TERM_COLOR: always |
@@ -140,32 +158,56 @@ jobs: |
140 | 158 | run: | |
141 | 159 | sudo apt-get update |
142 | 160 | sudo apt-get install -y libsqlite3-dev |
| 161 | + - name: Prepare features |
| 162 | + run: | |
| 163 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 164 | + FEATURES="${{ github.event.inputs.features }}" |
| 165 | + else |
| 166 | + FEATURES="sqlite-bundled" |
| 167 | + fi |
| 168 | + echo "FEATURES=$FEATURES" >> $GITHUB_ENV |
143 | 169 | - name: Build for Android |
| 170 | + if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }} |
144 | 171 | run: | |
145 | | - cargo build --target aarch64-linux-android --release --bin file_classification_cli --verbose |
| 172 | + if [ -n "$FEATURES" ]; then |
| 173 | + cargo build --target aarch64-linux-android --release --bin file_classification_cli --features "$FEATURES" --verbose |
| 174 | + else |
| 175 | + cargo build --target aarch64-linux-android --release --bin file_classification_cli --verbose |
| 176 | + fi |
146 | 177 | - name: Build for other Android targets |
| 178 | + if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }} |
147 | 179 | run: | |
148 | | - cargo build --target armv7-linux-androideabi --release --bin file_classification_cli --verbose |
149 | | - cargo build --target x86_64-linux-android --release --bin file_classification_cli --verbose |
150 | | - cargo build --target i686-linux-android --release --bin file_classification_cli --verbose |
| 180 | + if [ -n "$FEATURES" ]; then |
| 181 | + cargo build --target armv7-linux-androideabi --release --bin file_classification_cli --features "$FEATURES" --verbose |
| 182 | + cargo build --target x86_64-linux-android --release --bin file_classification_cli --features "$FEATURES" --verbose |
| 183 | + cargo build --target i686-linux-android --release --bin file_classification_cli --features "$FEATURES" --verbose |
| 184 | + else |
| 185 | + cargo build --target armv7-linux-androideabi --release --bin file_classification_cli --verbose |
| 186 | + cargo build --target x86_64-linux-android --release --bin file_classification_cli --verbose |
| 187 | + cargo build --target i686-linux-android --release --bin file_classification_cli --verbose |
| 188 | + fi |
151 | 189 | - name: Set Android binary name |
152 | 190 | run: echo "ANDROID_BINARY_NAME=file_classification_cli" >> $GITHUB_ENV |
153 | 191 | - name: Upload Android artifacts |
| 192 | + if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }} |
154 | 193 | uses: actions/upload-artifact@v4 |
155 | 194 | with: |
156 | 195 | name: file_classification_cli-android-aarch64 |
157 | 196 | path: target/aarch64-linux-android/release/file_classification_cli |
158 | 197 | - name: Upload other Android artifacts |
| 198 | + if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }} |
159 | 199 | uses: actions/upload-artifact@v4 |
160 | 200 | with: |
161 | 201 | name: file_classification_cli-android-armv7 |
162 | 202 | path: target/armv7-linux-androideabi/release/file_classification_cli |
163 | 203 | - name: Upload other Android artifacts |
| 204 | + if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }} |
164 | 205 | uses: actions/upload-artifact@v4 |
165 | 206 | with: |
166 | 207 | name: file_classification_cli-android-x86_64 |
167 | 208 | path: target/x86_64-linux-android/release/file_classification_cli |
168 | 209 | - name: Upload other Android artifacts |
| 210 | + if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }} |
169 | 211 | uses: actions/upload-artifact@v4 |
170 | 212 | with: |
171 | 213 | name: file_classification_cli-android-i686 |
@@ -224,20 +266,40 @@ jobs: |
224 | 266 | echo '' >> .cargo/config.toml |
225 | 267 | echo '[target.riscv64gc-unknown-linux-gnu]' >> .cargo/config.toml |
226 | 268 | echo 'linker = "riscv64-linux-gnu-gcc"' >> .cargo/config.toml |
| 269 | + - name: Prepare features |
| 270 | + run: | |
| 271 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 272 | + FEATURES="${{ github.event.inputs.features }}" |
| 273 | + else |
| 274 | + FEATURES="sqlite-bundled" |
| 275 | + fi |
| 276 | + echo "FEATURES=$FEATURES" >> $GITHUB_ENV |
227 | 277 | - name: Build CLI release binary |
| 278 | + if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }} |
228 | 279 | run: | |
229 | | - cargo build --target ${{ matrix.target }} --release --bin file_classification_cli --verbose |
| 280 | + if [ -n "$FEATURES" ]; then |
| 281 | + cargo build --target ${{ matrix.target }} --release --bin file_classification_cli --features "$FEATURES" --verbose |
| 282 | + else |
| 283 | + cargo build --target ${{ matrix.target }} --release --bin file_classification_cli --verbose |
| 284 | + fi |
230 | 285 | - name: Build WebAPI release binary |
| 286 | + if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_webapi == 'true' }} |
231 | 287 | run: | |
232 | | - cargo build --target ${{ matrix.target }} --release --bin file_classification_webapi --verbose |
| 288 | + if [ -n "$FEATURES" ]; then |
| 289 | + cargo build --target ${{ matrix.target }} --release --bin file_classification_webapi --features "$FEATURES" --verbose |
| 290 | + else |
| 291 | + cargo build --target ${{ matrix.target }} --release --bin file_classification_webapi --verbose |
| 292 | + fi |
233 | 293 | - name: Set binary name |
234 | 294 | run: echo "BINARY_NAME=file_classification_cli" >> $GITHUB_ENV |
235 | 295 | - name: Upload CLI artifacts |
| 296 | + if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }} |
236 | 297 | uses: actions/upload-artifact@v4 |
237 | 298 | with: |
238 | 299 | name: file_classification_cli-${{ matrix.target }} |
239 | 300 | path: target/${{ matrix.target }}/release/file_classification_cli |
240 | 301 | - name: Upload WebAPI artifacts |
| 302 | + if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_webapi == 'true' }} |
241 | 303 | uses: actions/upload-artifact@v4 |
242 | 304 | with: |
243 | 305 | name: file_classification_webapi-${{ matrix.target }} |
@@ -283,20 +345,40 @@ jobs: |
283 | 345 | echo "VCPKG_ROOT=$env:GITHUB_WORKSPACE\vcpkg" >> $env:GITHUB_ENV |
284 | 346 | echo "$env:GITHUB_WORKSPACE\vcpkg\installed\x64-windows\lib" >> $env:GITHUB_PATH |
285 | 347 | echo "$env:GITHUB_WORKSPACE\vcpkg\installed\x64-windows-static\lib" >> $env:GITHUB_PATH |
| 348 | + - name: Prepare features |
| 349 | + run: | |
| 350 | + if ("${{ github.event_name }}" -eq "workflow_dispatch") { |
| 351 | + $env:FEATURES="${{ github.event.inputs.features }}" |
| 352 | + } else { |
| 353 | + $env:FEATURES="sqlite-bundled" |
| 354 | + } |
| 355 | + echo "FEATURES=$env:FEATURES" >> $env:GITHUB_ENV |
286 | 356 | - name: Build CLI release binary |
| 357 | + if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }} |
287 | 358 | run: | |
288 | | - cargo build --target ${{ matrix.target }} --release --bin file_classification_cli --verbose |
| 359 | + if ( "${env:FEATURES}" -ne "" ) { |
| 360 | + cargo build --target ${{ matrix.target }} --release --bin file_classification_cli --features "${env:FEATURES}" --verbose |
| 361 | + } else { |
| 362 | + cargo build --target ${{ matrix.target }} --release --bin file_classification_cli --verbose |
| 363 | + } |
289 | 364 | - name: Build WebAPI release binary |
| 365 | + if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_webapi == 'true' }} |
290 | 366 | run: | |
291 | | - cargo build --target ${{ matrix.target }} --release --bin file_classification_webapi --verbose |
| 367 | + if ( "${env:FEATURES}" -ne "" ) { |
| 368 | + cargo build --target ${{ matrix.target }} --release --bin file_classification_webapi --features "${env:FEATURES}" --verbose |
| 369 | + } else { |
| 370 | + cargo build --target ${{ matrix.target }} --release --bin file_classification_webapi --verbose |
| 371 | + } |
292 | 372 | - name: Set binary name |
293 | | - run: echo "BINARY_NAME=file_classification_cli.exe" >> $GITHUB_ENV |
| 373 | + run: echo "BINARY_NAME=file_classification_cli.exe" >> $env:GITHUB_ENV |
294 | 374 | - name: Upload CLI artifacts |
| 375 | + if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }} |
295 | 376 | uses: actions/upload-artifact@v4 |
296 | 377 | with: |
297 | 378 | name: file_classification_cli-${{ matrix.target }} |
298 | 379 | path: target/${{ matrix.target }}/release/file_classification_cli.exe |
299 | 380 | - name: Upload WebAPI artifacts |
| 381 | + if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_webapi == 'true' }} |
300 | 382 | uses: actions/upload-artifact@v4 |
301 | 383 | with: |
302 | 384 | name: file_classification_webapi-${{ matrix.target }} |
@@ -330,20 +412,40 @@ jobs: |
330 | 412 | - name: Install dependencies (macOS) |
331 | 413 | run: | |
332 | 414 | brew install sqlite3 |
| 415 | + - name: Prepare features |
| 416 | + run: | |
| 417 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 418 | + FEATURES="${{ github.event.inputs.features }}" |
| 419 | + else |
| 420 | + FEATURES="sqlite-bundled" |
| 421 | + fi |
| 422 | + echo "FEATURES=$FEATURES" >> $GITHUB_ENV |
333 | 423 | - name: Build CLI release binary |
| 424 | + if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }} |
334 | 425 | run: | |
335 | | - cargo build --target ${{ matrix.target }} --release --bin file_classification_cli --verbose |
| 426 | + if [ -n "$FEATURES" ]; then |
| 427 | + cargo build --target ${{ matrix.target }} --release --bin file_classification_cli --features "$FEATURES" --verbose |
| 428 | + else |
| 429 | + cargo build --target ${{ matrix.target }} --release --bin file_classification_cli --verbose |
| 430 | + fi |
336 | 431 | - name: Build WebAPI release binary |
| 432 | + if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_webapi == 'true' }} |
337 | 433 | run: | |
338 | | - cargo build --target ${{ matrix.target }} --release --bin file_classification_webapi --verbose |
| 434 | + if [ -n "$FEATURES" ]; then |
| 435 | + cargo build --target ${{ matrix.target }} --release --bin file_classification_webapi --features "$FEATURES" --verbose |
| 436 | + else |
| 437 | + cargo build --target ${{ matrix.target }} --release --bin file_classification_webapi --verbose |
| 438 | + fi |
339 | 439 | - name: Set binary name |
340 | 440 | run: echo "BINARY_NAME=file_classification_cli" >> $GITHUB_ENV |
341 | 441 | - name: Upload CLI artifacts |
| 442 | + if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_cli == 'true' }} |
342 | 443 | uses: actions/upload-artifact@v4 |
343 | 444 | with: |
344 | 445 | name: file_classification_cli-${{ matrix.target }} |
345 | 446 | path: target/${{ matrix.target }}/release/file_classification_cli |
346 | 447 | - name: Upload WebAPI artifacts |
| 448 | + if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.build_webapi == 'true' }} |
347 | 449 | uses: actions/upload-artifact@v4 |
348 | 450 | with: |
349 | 451 | name: file_classification_webapi-${{ matrix.target }} |
|
0 commit comments