Skip to content

Commit 31e3872

Browse files
authored
Merge 9003981 into 1bf432b
2 parents 1bf432b + 9003981 commit 31e3872

File tree

3 files changed

+165
-76
lines changed

3 files changed

+165
-76
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: "Prepare Package.swift"
2+
description: "Prepares Package.swift"
3+
inputs:
4+
is-pr:
5+
description: "Whether the build is a PR"
6+
required: true
7+
default: "false"
8+
package-file:
9+
description: "The package file to prepare"
10+
required: true
11+
default: "Package.swift"
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: Remove newer package files
16+
# Remove newer package files when processing Package.swift to prevent interference
17+
if: ${{ inputs.package-file == 'Package.swift' }}
18+
shell: bash
19+
run: rm -rf Package@swift*
20+
- name: Remove Sentry-Dynamic-WithARM64e target
21+
# We don't build it on PRs, so we need to remove it from the package.swift file.
22+
if: ${{ inputs.is-pr == 'true' }}
23+
shell: bash
24+
env:
25+
PACKAGE_FILE: ${{ inputs.package-file }}
26+
run: |
27+
sed -i '' '/Sentry-Dynamic-WithARM64e/d' $PACKAGE_FILE
28+
sed -i '' '/^[[:space:]]*\.binaryTarget($/{N;/\n[[:space:]]*),$/d;}' $PACKAGE_FILE
29+
- name: Change path of the framework
30+
shell: bash
31+
env:
32+
PACKAGE_FILE: ${{ inputs.package-file }}
33+
run: |
34+
sed -i '' 's/url.*//g' $PACKAGE_FILE
35+
sed -i '' 's/checksum: ".*" \/\/Sentry-Static/path: "Sentry.xcframework.zip"/g' $PACKAGE_FILE
36+
sed -i '' 's/checksum: ".*" \/\/Sentry-Dynamic-WithARM64e/path: "Sentry-Dynamic-WithARM64e.xcframework.zip"/g' $PACKAGE_FILE
37+
sed -i '' 's/checksum: ".*" \/\/Sentry-Dynamic/path: "Sentry-Dynamic.xcframework.zip"/g' $PACKAGE_FILE

.github/workflows/release.yml

Lines changed: 41 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
- "Sources/**"
1212
- "scripts/ci-select-xcode.sh"
1313
- "scripts/ci-diagnostics.sh"
14+
- "scripts/generate_release_matrix.sh"
1415
- Sentry.xcworkspace/**
1516
- Sentry.xcodeproj/**
1617
- "Package*.swift"
@@ -48,37 +49,43 @@ concurrency:
4849
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
4950

5051
jobs:
52+
setup-matrix:
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v4
56+
- name: Setup matrix combinations
57+
id: setup-matrix-combinations
58+
run: |
59+
./scripts/generate_release_matrix.sh
60+
env:
61+
EVENT_NAME: ${{ github.event_name }}
62+
outputs:
63+
slices: ${{ steps.setup-matrix-combinations.outputs.slices }}
64+
variants: ${{ steps.setup-matrix-combinations.outputs.variants }}
65+
sdk-list-array: ${{ steps.setup-matrix-combinations.outputs.sdk-list-array }}
66+
sdk-list-string: ${{ steps.setup-matrix-combinations.outputs.sdk-list-string }}
67+
5168
build-xcframework-variant-slices:
5269
name: Build XCFramework Slices
5370
uses: ./.github/workflows/build-xcframework-variant-slices.yml
71+
needs: setup-matrix
5472
with:
5573
name: ${{matrix.variant.name}}
5674
suffix: ${{matrix.variant.suffix}}
5775
macho-type: ${{matrix.variant.macho-type}}
5876
configuration-suffix: ${{matrix.variant.configuration-suffix}}
5977
variant-id: ${{matrix.variant.id}}
6078
release-version: ${{ github.event.inputs.version }}
79+
sdk-list: ${{ needs.setup-matrix.outputs.sdk-list-array }}
6180
strategy:
6281
matrix:
63-
variant:
64-
- name: Sentry
65-
macho-type: mh_dylib
66-
suffix: "-Dynamic"
67-
id: sentry-dynamic
68-
- name: Sentry
69-
macho-type: staticlib
70-
id: sentry-static
71-
- name: SentrySwiftUI
72-
macho-type: mh_dylib
73-
id: sentry-swiftui
74-
- name: Sentry
75-
macho-type: mh_dylib
76-
suffix: "-WithoutUIKitOrAppKit"
77-
configuration-suffix: WithoutUIKit
78-
id: sentry-withoutuikit-dynamic
82+
variant: ${{ fromJson(needs.setup-matrix.outputs.slices) }}
7983

8084
assemble-xcframework-variant:
81-
needs: build-xcframework-variant-slices
85+
needs: [
86+
"build-xcframework-variant-slices",
87+
"setup-matrix",
88+
]
8289
name: Assemble XCFramework Variant
8390
uses: ./.github/workflows/assemble-xcframework-variant.yml
8491
secrets: inherit
@@ -91,37 +98,10 @@ jobs:
9198
release-version: ${{ github.event.inputs.version }}
9299
excluded-archs: ${{matrix.variant.excluded-archs}}
93100
override-name: ${{matrix.variant.override-name}}
101+
sdks: ${{ needs.setup-matrix.outputs.sdk-list-string }}
94102
strategy:
95103
matrix:
96-
variant:
97-
- scheme: Sentry
98-
macho-type: mh_dylib
99-
suffix: "-Dynamic"
100-
id: sentry-dynamic
101-
excluded-archs: arm64e
102-
- scheme: Sentry
103-
macho-type: mh_dylib
104-
suffix: "-Dynamic"
105-
id: sentry-dynamic
106-
override-name: Sentry-Dynamic-WithARM64e
107-
- scheme: Sentry
108-
macho-type: staticlib
109-
id: sentry-static
110-
- scheme: SentrySwiftUI
111-
macho-type: mh_dylib
112-
id: sentry-swiftui
113-
- scheme: Sentry
114-
macho-type: mh_dylib
115-
suffix: "-WithoutUIKitOrAppKit"
116-
configuration-suffix: WithoutUIKit
117-
id: sentry-withoutuikit-dynamic
118-
excluded-archs: arm64e
119-
- scheme: Sentry
120-
macho-type: mh_dylib
121-
suffix: "-WithoutUIKitOrAppKit"
122-
configuration-suffix: WithoutUIKit
123-
id: sentry-withoutuikit-dynamic
124-
override-name: Sentry-WithoutUIKitOrAppKit-WithARM64e
104+
variant: ${{ fromJson(needs.setup-matrix.outputs.variants) }}
125105

126106
validate-xcframework:
127107
name: Validate XCFramework
@@ -156,16 +136,11 @@ jobs:
156136
with:
157137
pattern: xcframework-${{github.sha}}-*
158138
merge-multiple: true
159-
- name: Remove newer package files
160-
if: ${{ matrix.package-file.name == 'Package.swift' }}
161-
run: rm -rf Package@swift*
162-
- name: Change path of the framework
163-
run: |
164-
sed -i '' 's/url.*//g' ${{matrix.package-file.name}}
165-
sed -i '' 's/checksum: ".*" \/\/Sentry-Static/path: "Sentry.xcframework.zip"/g' ${{matrix.package-file.name}}
166-
sed -i '' 's/checksum: ".*" \/\/Sentry-Dynamic-WithARM64e/path: "Sentry-Dynamic-WithARM64e.xcframework.zip"/g' ${{matrix.package-file.name}}
167-
sed -i '' 's/checksum: ".*" \/\/Sentry-Dynamic/path: "Sentry-Dynamic.xcframework.zip"/g' ${{matrix.package-file.name}}
168-
shell: bash
139+
- name: Prepare Package.swift
140+
uses: ./.github/actions/prepare-package.swift
141+
with:
142+
is-pr: ${{ github.event_name == 'pull_request' }}
143+
package-file: ${{matrix.package-file.name}}
169144
- run: swift build
170145
working-directory: Samples/macOS-SPM-CommandLine
171146
- name: Run CI Diagnostics
@@ -187,16 +162,11 @@ jobs:
187162
with:
188163
pattern: xcframework-${{github.sha}}-*
189164
merge-multiple: true
190-
- name: Remove newer package files
191-
if: ${{ matrix.package-file.name == 'Package.swift' }}
192-
run: rm -rf Package@swift*
193-
- name: Change path of the framework
194-
run: |
195-
sed -i '' 's/url.*//g' ${{matrix.package-file.name}}
196-
sed -i '' 's/checksum: ".*" \/\/Sentry-Static/path: "Sentry.xcframework.zip"/g' ${{matrix.package-file.name}}
197-
sed -i '' 's/checksum: ".*" \/\/Sentry-Dynamic-WithARM64e/path: "Sentry-Dynamic-WithARM64e.xcframework.zip"/g' ${{matrix.package-file.name}}
198-
sed -i '' 's/checksum: ".*" \/\/Sentry-Dynamic/path: "Sentry-Dynamic.xcframework.zip"/g' ${{matrix.package-file.name}}
199-
shell: bash
165+
- name: Prepare Package.swift
166+
uses: ./.github/actions/prepare-package.swift
167+
with:
168+
is-pr: ${{ github.event_name == 'pull_request' }}
169+
package-file: ${{matrix.package-file.name}}
200170
- run: swift build
201171
working-directory: Samples/SPM-Dynamic
202172
- name: Run CI Diagnostics
@@ -218,16 +188,11 @@ jobs:
218188
with:
219189
pattern: xcframework-${{github.sha}}-*
220190
merge-multiple: true
221-
- name: Remove newer package files
222-
if: ${{ matrix.package-file.name == 'Package.swift' }}
223-
run: rm -rf Package@swift*
224-
- name: Change path of the framework
225-
run: |
226-
sed -i '' 's/url.*//g' ${{matrix.package-file.name}}
227-
sed -i '' 's/checksum: ".*" \/\/Sentry-Static/path: "Sentry.xcframework.zip"/g' ${{matrix.package-file.name}}
228-
sed -i '' 's/checksum: ".*" \/\/Sentry-Dynamic-WithARM64e/path: "Sentry-Dynamic-WithARM64e.xcframework.zip"/g' ${{matrix.package-file.name}}
229-
sed -i '' 's/checksum: ".*" \/\/Sentry-Dynamic/path: "Sentry-Dynamic.xcframework.zip"/g' ${{matrix.package-file.name}}
230-
shell: bash
191+
- name: Prepare Package.swift
192+
uses: ./.github/actions/prepare-package.swift
193+
with:
194+
is-pr: ${{ github.event_name == 'pull_request' }}
195+
package-file: ${{matrix.package-file.name}}
231196
- run: swift build
232197
- name: Run CI Diagnostics
233198
if: failure()

scripts/generate_release_matrix.sh

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
3+
# This script is used to generate the matrix combinations for the release workflow.
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+
'"maccatalyst"'
23+
'"appletvos"'
24+
'"watchos"'
25+
'"xros"'
26+
)
27+
28+
# Slices and Variants only needed on main or release
29+
ADDITIONAL_SLICES=(
30+
'{"name": "Sentry", "macho-type": "mh_dylib", "suffix": "-WithoutUIKitOrAppKit", "configuration-suffix": "WithoutUIKit", "id": "sentry-withoutuikit-dynamic"}'
31+
)
32+
ADDITIONAL_VARIANTS=(
33+
'{"scheme": "Sentry", "macho-type": "mh_dylib", "suffix": "-Dynamic", "id": "sentry-dynamic", "override-name": "Sentry-Dynamic-WithARM64e"}'
34+
'{"scheme": "Sentry", "macho-type": "mh_dylib", "suffix": "-WithoutUIKitOrAppKit", "configuration-suffix": "WithoutUIKit", "id": "sentry-withoutuikit-dynamic", "excluded-archs": "arm64e"}'
35+
'{"scheme": "Sentry", "macho-type": "mh_dylib", "suffix": "-WithoutUIKitOrAppKit", "configuration-suffix": "WithoutUIKit", "id": "sentry-withoutuikit-dynamic", "override-name": "Sentry-WithoutUIKitOrAppKit-WithARM64e"}'
36+
)
37+
ADDITIONAL_SDKS=(
38+
'"appletvsimulator"'
39+
'"watchsimulator"'
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+
65+
if [ "$EVENT_NAME" = "pull_request" ]; then
66+
SLICES_COMBINATIONS=$(build_json_array BASE_SLICES)
67+
VARIANTS_COMBINATIONS=$(build_json_array BASE_VARIANTS)
68+
SDK_LIST=$(build_json_array BASE_SDKS)
69+
else
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)
80+
fi
81+
82+
{
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(",")')"
87+
} >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)