|
78 | 78 | required: false |
79 | 79 | default: false |
80 | 80 | type: boolean |
| 81 | + platforms: |
| 82 | + description: 'Which platforms to build' |
| 83 | + required: true |
| 84 | + default: 'both' |
| 85 | + type: choice |
| 86 | + options: |
| 87 | + - both |
| 88 | + - windows-only |
| 89 | + - macos-only |
81 | 90 | workflow_call: |
82 | 91 | inputs: |
83 | 92 | profile: |
@@ -423,27 +432,45 @@ jobs: |
423 | 432 | run: | |
424 | 433 | set -euo pipefail |
425 | 434 |
|
426 | | - labels="${{ join(github.event.pull_request.labels.*.name, ' ') }}" |
427 | | - echo "Labels: '$labels'" |
428 | | -
|
429 | | - has_windows_only=false |
430 | | - has_macos_only=false |
431 | | - if echo "$labels" | grep -qw 'windows-only'; then has_windows_only=true; fi |
432 | | - if echo "$labels" | grep -qw 'macos-only'; then has_macos_only=true; fi |
| 435 | + # platform_build_mode: windows | macos | both |
| 436 | + platform_build_mode=both |
433 | 437 |
|
434 | | - if [ "$has_windows_only" = "true" ] && [ "$has_macos_only" = "true" ]; then |
435 | | - echo "::error::Both 'windows-only' and 'macos-only' labels are applied. Remove one — they are mutually exclusive." |
436 | | - exit 1 |
437 | | - fi |
| 438 | + dispatch_platforms="${{ github.event.inputs.platforms }}" |
| 439 | + echo "Dispatch platforms: '$dispatch_platforms'" |
438 | 440 |
|
439 | | - if [ "$has_windows_only" = "true" ]; then |
440 | | - targets='["windows64"]' |
441 | | - elif [ "$has_macos_only" = "true" ]; then |
442 | | - targets='["macos"]' |
| 441 | + if [ "$dispatch_platforms" = "windows-only" ]; then |
| 442 | + platform_build_mode=windows |
| 443 | + elif [ "$dispatch_platforms" = "macos-only" ]; then |
| 444 | + platform_build_mode=macos |
443 | 445 | else |
444 | | - targets='["windows64","macos"]' |
| 446 | + labels="${{ join(github.event.pull_request.labels.*.name, ' ') }}" |
| 447 | + echo "Labels: '$labels'" |
| 448 | +
|
| 449 | + label_match_count=0 |
| 450 | + if echo "$labels" | grep -qw 'windows-only'; then |
| 451 | + platform_build_mode=windows |
| 452 | + label_match_count=$((label_match_count + 1)) |
| 453 | + fi |
| 454 | + if echo "$labels" | grep -qw 'macos-only'; then |
| 455 | + platform_build_mode=macos |
| 456 | + label_match_count=$((label_match_count + 1)) |
| 457 | + fi |
| 458 | +
|
| 459 | + if [ "$label_match_count" -gt 1 ]; then |
| 460 | + echo "::error::Both 'windows-only' and 'macos-only' labels are applied. Remove one — they are mutually exclusive." |
| 461 | + exit 1 |
| 462 | + fi |
445 | 463 | fi |
446 | 464 |
|
| 465 | + echo "Platform build mode: $platform_build_mode" |
| 466 | +
|
| 467 | + case "$platform_build_mode" in |
| 468 | + windows) targets='["windows64"]' ;; |
| 469 | + macos) targets='["macos"]' ;; |
| 470 | + both) targets='["windows64","macos"]' ;; |
| 471 | + *) echo "::error::Unknown platform_build_mode '$platform_build_mode'"; exit 1 ;; |
| 472 | + esac |
| 473 | +
|
447 | 474 | echo "Targets: $targets" |
448 | 475 | echo "targets=$targets" >> "$GITHUB_OUTPUT" |
449 | 476 |
|
|
0 commit comments