|
2 | 2 |
|
3 | 3 | # This script is used to generate the matrix combinations for the release workflow.
|
4 | 4 |
|
| 5 | +set -euo pipefail |
| 6 | + |
| 7 | +# Slices and Variants only needed on PRs |
| 8 | +BASE_SLICES=( |
| 9 | + '{"name": "Sentry", "macho-type": "mh_dylib", "suffix": "-Dynamic", "id": "sentry-dynamic"}' |
| 10 | + '{"name": "Sentry", "macho-type": "staticlib", "id": "sentry-static"}' |
| 11 | + '{"name": "SentrySwiftUI", "macho-type": "mh_dylib", "id": "sentry-swiftui"}' |
| 12 | +) |
| 13 | +BASE_VARIANTS=( |
| 14 | + '{"scheme": "Sentry", "macho-type": "mh_dylib", "suffix": "-Dynamic", "id": "sentry-dynamic", "excluded-archs": "arm64e"}' |
| 15 | + '{"scheme": "Sentry", "macho-type": "staticlib", "id": "sentry-static"}' |
| 16 | + '{"scheme": "SentrySwiftUI", "macho-type": "mh_dylib", "id": "sentry-swiftui"}' |
| 17 | +) |
| 18 | +BASE_SDKS=( |
| 19 | + '"iphoneos"' |
| 20 | + '"iphonesimulator"' |
| 21 | + '"macosx"' |
| 22 | +) |
| 23 | + |
| 24 | +# Slices and Variants only needed on main or release |
| 25 | +ADDITIONAL_SLICES=( |
| 26 | + '{"name": "Sentry", "macho-type": "mh_dylib", "suffix": "-WithoutUIKitOrAppKit", "configuration-suffix": "WithoutUIKit", "id": "sentry-withoutuikit-dynamic"}' |
| 27 | +) |
| 28 | +ADDITIONAL_VARIANTS=( |
| 29 | + '{"scheme": "Sentry", "macho-type": "mh_dylib", "suffix": "-Dynamic", "id": "sentry-dynamic", "override-name": "Sentry-Dynamic-WithARM64e"}' |
| 30 | + '{"scheme": "Sentry", "macho-type": "mh_dylib", "suffix": "-WithoutUIKitOrAppKit", "configuration-suffix": "WithoutUIKit", "id": "sentry-withoutuikit-dynamic", "excluded-archs": "arm64e"}' |
| 31 | + '{"scheme": "Sentry", "macho-type": "mh_dylib", "suffix": "-WithoutUIKitOrAppKit", "configuration-suffix": "WithoutUIKit", "id": "sentry-withoutuikit-dynamic", "override-name": "Sentry-WithoutUIKitOrAppKit-WithARM64e"}' |
| 32 | +) |
| 33 | +ADDITIONAL_SDKS=( |
| 34 | + '"maccatalyst"' |
| 35 | + '"appletvos"' |
| 36 | + '"appletvsimulator"' |
| 37 | + '"watchos"' |
| 38 | + '"watchsimulator"' |
| 39 | + '"xros"' |
| 40 | + '"xrsimulator"' |
| 41 | +) |
| 42 | + |
| 43 | +build_json_array() { |
| 44 | + local array_name=$1 |
| 45 | + local result="[" |
| 46 | + local first=true |
| 47 | + |
| 48 | + # Get the array elements using indirect expansion |
| 49 | + local array_values |
| 50 | + eval "array_values=(\"\${${array_name}[@]}\")" |
| 51 | + |
| 52 | + for item in "${array_values[@]}"; do |
| 53 | + if [ "$first" = true ]; then |
| 54 | + first=false |
| 55 | + else |
| 56 | + result+="," |
| 57 | + fi |
| 58 | + result+="$item" |
| 59 | + done |
| 60 | + |
| 61 | + result+="]" |
| 62 | + echo "$result" |
| 63 | +} |
| 64 | + |
5 | 65 | if [ "$EVENT_NAME" = "pull_request" ]; then
|
6 |
| - SLICES_COMBINATIONS=' |
7 |
| - [ |
8 |
| - { "name": "Sentry", "macho-type": "mh_dylib", "suffix": "-Dynamic", "id": "sentry-dynamic" }, |
9 |
| - { "name": "Sentry", "macho-type": "staticlib", "id": "sentry-static" }, |
10 |
| - { "name": "SentrySwiftUI", "macho-type": "mh_dylib", "id": "sentry-swiftui" } |
11 |
| - ] |
12 |
| - ' |
13 |
| - VARIANTS_COMBINATIONS=' |
14 |
| - [ |
15 |
| - { "scheme": "Sentry", "macho-type": "mh_dylib", "suffix": "-Dynamic", "id": "sentry-dynamic", "excluded-archs": "arm64e" }, |
16 |
| - { "scheme": "Sentry", "macho-type": "staticlib", "id": "sentry-static" }, |
17 |
| - { "scheme": "SentrySwiftUI", "macho-type": "mh_dylib", "id": "sentry-swiftui" } |
18 |
| - ] |
19 |
| - ' |
20 |
| - SDK_LIST='["iphoneos", "iphonesimulator", "macosx"]' |
| 66 | + SLICES_COMBINATIONS=$(build_json_array BASE_SLICES) |
| 67 | + VARIANTS_COMBINATIONS=$(build_json_array BASE_VARIANTS) |
| 68 | + SDK_LIST=$(build_json_array BASE_SDKS) |
21 | 69 | else
|
22 |
| - SLICES_COMBINATIONS=' |
23 |
| - [ |
24 |
| - { "name": "Sentry", "macho-type": "mh_dylib", "suffix": "-Dynamic", "id": "sentry-dynamic" }, |
25 |
| - { "name": "Sentry", "macho-type": "staticlib", "id": "sentry-static" }, |
26 |
| - { "name": "SentrySwiftUI", "macho-type": "mh_dylib", "id": "sentry-swiftui" }, |
27 |
| - { "name": "Sentry", "macho-type": "mh_dylib", "suffix": "-WithoutUIKitOrAppKit", "configuration-suffix": "WithoutUIKit", "id": "sentry-withoutuikit-dynamic" } |
28 |
| - ] |
29 |
| - ' |
30 |
| - VARIANTS_COMBINATIONS=' |
31 |
| - [ |
32 |
| - { "scheme": "Sentry", "macho-type": "mh_dylib", "suffix": "-Dynamic", "id": "sentry-dynamic", "excluded-archs": "arm64e" }, |
33 |
| - { "scheme": "Sentry", "macho-type": "mh_dylib", "suffix": "-Dynamic", "id": "sentry-dynamic", "override-name": "Sentry-Dynamic-WithARM64e" }, |
34 |
| - { "scheme": "Sentry", "macho-type": "staticlib", "id": "sentry-static" }, |
35 |
| - { "scheme": "SentrySwiftUI", "macho-type": "mh_dylib", "id": "sentry-swiftui" }, |
36 |
| - { "scheme": "Sentry", "macho-type": "mh_dylib", "suffix": "-WithoutUIKitOrAppKit", "configuration-suffix": "WithoutUIKit", "id": "sentry-withoutuikit-dynamic", "excluded-archs": "arm64e" }, |
37 |
| - { "scheme": "Sentry", "macho-type": "mh_dylib", "suffix": "-WithoutUIKitOrAppKit", "configuration-suffix": "WithoutUIKit", "id": "sentry-withoutuikit-dynamic", "override-name": "Sentry-WithoutUIKitOrAppKit-WithARM64e" } |
38 |
| - ] |
39 |
| - ' |
40 |
| - SDK_LIST='["iphoneos", "iphonesimulator", "macosx", "maccatalyst", "appletvos", "appletvsimulator", "watchos", "watchsimulator", "xros", "xrsimulator"]' |
| 70 | + # shellcheck disable=SC2034 |
| 71 | + ALL_SLICES=("${BASE_SLICES[@]}" "${ADDITIONAL_SLICES[@]}") |
| 72 | + # shellcheck disable=SC2034 |
| 73 | + ALL_VARIANTS=("${BASE_VARIANTS[@]}" "${ADDITIONAL_VARIANTS[@]}") |
| 74 | + # shellcheck disable=SC2034 |
| 75 | + ALL_SDKS=("${BASE_SDKS[@]}" "${ADDITIONAL_SDKS[@]}") |
| 76 | + |
| 77 | + SLICES_COMBINATIONS=$(build_json_array ALL_SLICES) |
| 78 | + VARIANTS_COMBINATIONS=$(build_json_array ALL_VARIANTS) |
| 79 | + SDK_LIST=$(build_json_array ALL_SDKS) |
41 | 80 | fi
|
42 | 81 |
|
43 | 82 | {
|
44 |
| - echo "slices=$( echo "$SLICES_COMBINATIONS" | jq -c . )" |
45 |
| - echo "variants=$( echo "$VARIANTS_COMBINATIONS" | jq -c . )" |
46 |
| - echo "sdk-list-array=$( echo "$SDK_LIST" | jq -c . )" |
47 |
| - echo "sdk-list-string=$( echo "$SDK_LIST" | jq -r 'join(",")' )" |
| 83 | + echo "slices=$SLICES_COMBINATIONS" |
| 84 | + echo "variants=$VARIANTS_COMBINATIONS" |
| 85 | + echo "sdk-list-array=$SDK_LIST" |
| 86 | + echo "sdk-list-string=$(echo "$SDK_LIST" | jq -r 'join(",")')" |
48 | 87 | } >> "$GITHUB_OUTPUT"
|
0 commit comments