Skip to content

Commit fee2b24

Browse files
authored
ci: refactor xcframework build workflows (#5277)
1 parent bebaf76 commit fee2b24

7 files changed

+251
-146
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: 'Assemble Sentry Cocoa XCFramework variant'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
7+
name:
8+
description: |-
9+
The Sentry project target to build an XCFramework slice for.
10+
Possible values: Sentry, SentrySwiftUI.
11+
required: true
12+
type: string
13+
14+
suffix:
15+
description: |-
16+
The suffix to add to the build product name.
17+
E.g. "-Dynamic" or "-WithoutUIKitOrAppKit".
18+
required: false
19+
type: string
20+
21+
variant-id:
22+
description: |-
23+
The ID of the variant to build an XCFramework slice for. Used to collect appropriate slices for final deliverable assembly.
24+
required: true
25+
type: string
26+
27+
jobs:
28+
assemble-xcframework-variant:
29+
name: Assemble ${{inputs.name}}${{inputs.suffix}} XCFramework Variant
30+
31+
runs-on: macos-14
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- name: Download ${{inputs.variant-id}} Slices
36+
uses: actions/download-artifact@v4
37+
with:
38+
pattern: xcframework-${{inputs.variant-id}}-slice-*
39+
path: xcframework-slices
40+
41+
- name: Assemble XCFramework
42+
run: ./scripts/assemble-xcframework.sh "${{github.workspace}}/xcframework-slices" "${{inputs.name}}${{inputs.suffix}}"
43+
shell: bash
44+
45+
- name: Archive XCFramework
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: xcframework-${{github.sha}}-${{inputs.variant-id}}
49+
if-no-files-found: error
50+
path: ${{inputs.name}}${{inputs.suffix}}.xcframework.zip

.github/workflows/benchmarking.yml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ on:
1515
- ".sauce/benchmarking-config.yml"
1616
- "fastlane/**"
1717
- "scripts/ci-select-xcode.sh"
18-
- "scripts/build-xcframework.sh"
1918
- "Samples/iOS-Swift/iOS-Swift.yml"
2019
- "Samples/iOS-Swift/iOS-Swift.xcconfig"
2120
- "Samples/iOS-Swift/iOS-SwiftClilp.xcconfig"
2221
- "Samples/iOS-Swift/iOS-Benchmarking.xcconfig"
22+
- "scripts/build-xcframework-slice.sh"
23+
- "scripts/assemble-xcframework.sh"
24+
- ".github/workflows/build-xcframework-variant-slices.yml"
25+
- ".github/workflows/assemble-xcframework-variant.yml"
2326

2427
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
2528
concurrency:
@@ -169,9 +172,27 @@ jobs:
169172
--tags benchmark \
170173
--verbose
171174
175+
build-xcframework-variant-slices:
176+
uses: ./.github/workflows/build-xcframework-variant-slices.yml
177+
with:
178+
name: Sentry
179+
suffix: "-Dynamic"
180+
variant-id: sentry-dynamic
181+
sdk-list: '["iphoneos", "iphonesimulator"]'
182+
include-maccatalyst: "false"
183+
184+
assemble-xcframework-variant:
185+
needs: build-xcframework-variant-slices
186+
uses: ./.github/workflows/assemble-xcframework-variant.yml
187+
with:
188+
name: Sentry
189+
suffix: "-Dynamic"
190+
variant-id: sentry-dynamic
191+
172192
app-metrics:
173193
name: Collect app metrics
174194
runs-on: macos-15
195+
needs: assemble-xcframework-variant
175196
steps:
176197
- name: Git checkout
177198
uses: actions/checkout@v4
@@ -195,17 +216,11 @@ jobs:
195216
MATCH_GIT_PRIVATE_KEY: ${{ secrets.MATCH_GIT_PRIVATE_KEY }}
196217
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
197218
MATCH_USERNAME: ${{ secrets.MATCH_USERNAME }}
198-
- name: Build Framework
199-
run: ./scripts/build-xcframework.sh iOSOnly
200-
201-
- name: Archive build log if failed
202-
uses: actions/upload-artifact@v4
203-
if: ${{ failure() || cancelled() }}
219+
- uses: actions/download-artifact@v4
204220
with:
205-
name: raw-build-output-build-xcframework
206-
path: |
207-
build-xcframework.log
208-
221+
pattern: xcframework-${{github.sha}}-sentry-dynamic
222+
path: Carthage/
223+
- run: find Carthage -name "Sentry-Dynamic.xcframework.zip" -print0 | xargs -t0I @ unzip @ -d Carthage
209224
- name: Build test app with sentry
210225
run: bundle exec fastlane build_perf_test_app_sentry
211226
env:
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: 'Build Sentry Cocoa XCFramework variant slices'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
7+
sdk-list:
8+
description: |-
9+
The list of Apple platform SDKs for which to build slices and assemble into an XCFramework. This must be a JSON array of strings, itself in a string since GitHub Actions doesn't support arrays as inputs.
10+
Possible values: iphoneos, iphonesimulator, macosx, appletvos, appletvsimulator, watchos, watchsimulator, xros, xrsimulator.
11+
required: false
12+
default: '["iphoneos", "iphonesimulator", "macosx", "appletvos", "appletvsimulator", "watchos", "watchsimulator", "xros", "xrsimulator"]'
13+
type: string
14+
15+
name:
16+
description: |-
17+
The Sentry project target to build an XCFramework slice for.
18+
Possible values: Sentry, SentrySwiftUI.
19+
required: true
20+
type: string
21+
22+
suffix:
23+
description: |-
24+
The suffix to add to the build product name.
25+
E.g. "-Dynamic" or "-WithoutUIKitOrAppKit".
26+
required: false
27+
type: string
28+
29+
macho-type:
30+
description: |-
31+
The Mach-O type of the build product.
32+
Possible values: mh_dylib, staticlib.
33+
required: false
34+
type: string
35+
default: "mh_dylib"
36+
37+
configuration-suffix:
38+
description: |-
39+
The suffix to add to the build product name to build an alternate configuration of the target.
40+
E.g. "WithoutUIKit".
41+
required: false
42+
type: string
43+
44+
variant-id:
45+
description: |-
46+
The ID of the variant to build an XCFramework slice for. Used to collect appropriate slices for final deliverable assembly.
47+
required: true
48+
type: string
49+
50+
include-maccatalyst:
51+
description: |-
52+
Directs whether or not to build a Mac Catalyst compatible slice.
53+
required: false
54+
type: string
55+
default: "false"
56+
57+
jobs:
58+
build-xcframework-variant-slices:
59+
name: Build ${{inputs.name}}${{inputs.suffix}} XCFramework Variant Slice for ${{matrix.sdk}}
60+
61+
# We must compile this on an arm64 runner, cause it's required for visionOS. macos-14 uses arm64.
62+
# To see the available runners see https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories.
63+
runs-on: macos-14
64+
65+
strategy:
66+
matrix:
67+
sdk: ${{ fromJson(inputs.sdk-list) }}
68+
69+
steps:
70+
- uses: actions/checkout@v4
71+
72+
# We have to compile on Xcode 15.2 because compiling on Xcode 15.4 fails with
73+
# Data+SentryTracing.swift:21:62: error: 'ReadingOptions' aliases 'Foundation.ReadingOptions'
74+
# and cannot be used here because C++ types from imported module 'Foundation' do not support
75+
# library evolution; this is an error in the Swift 6 language mode
76+
# We also can't use Xcode 16.x because validating the XCFramework then fails with Xcode 15.x.
77+
- run: ./scripts/ci-select-xcode.sh 15.2
78+
shell: bash
79+
80+
- name: Build ${{inputs.name}}${{inputs.suffix}} XCFramework slice for ${{matrix.sdk}}
81+
if: startsWith(github.ref, 'refs/heads/release/') == false
82+
run: ./scripts/build-xcframework-slice.sh ${{matrix.sdk}} ${{inputs.name}} "${{inputs.suffix}}" ${{inputs.macho-type}} ${{inputs.include-maccatalyst}} ${{inputs.configuration-suffix}}
83+
shell: bash
84+
85+
- name: Remove Sentry.framework from SentrySwiftUI build
86+
if: inputs.name == 'SentrySwiftUI'
87+
run: |
88+
find "${{github.workspace}}/Carthage/archive" -name "Sentry.framework" -print0 | xargs -t0 rm -rf
89+
find "${{github.workspace}}/Carthage/archive" -name "Sentry.framework.dSYM" -print0 | xargs -t0 rm -rf
90+
shell: bash
91+
92+
- name: Archiving xcarchive
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: xcframework-${{inputs.variant-id}}-slice-${{matrix.sdk}}
96+
if-no-files-found: error
97+
path: |
98+
${{github.workspace}}/Carthage/archive/${{inputs.name}}${{inputs.suffix}}/${{matrix.sdk}}.xcarchive
99+
100+
- name: Archive build log if failed
101+
uses: actions/upload-artifact@v4
102+
if: ${{ failure() || cancelled() }}
103+
with:
104+
name: raw-build-output-build-xcframework-${{inputs.variant-id}}-${{matrix.sdk}}
105+
path: |
106+
*.log

.github/workflows/build-xcframework.yml

Lines changed: 24 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build
1+
name: "Build Sentry XCFramework"
22
on:
33
push:
44
branches:
@@ -15,6 +15,8 @@ on:
1515
- "Package.swift"
1616
- "scripts/build-xcframework-slice.sh"
1717
- "scripts/assemble-xcframework.sh"
18+
- ".github/workflows/build-xcframework-variant-slices.yml"
19+
- ".github/workflows/assemble-xcframework-variant.yml"
1820
- Samples/macOS-SPM-CommandLine/**
1921
- Samples/SPM-Dynamic/**
2022

@@ -25,18 +27,22 @@ concurrency:
2527

2628
jobs:
2729

28-
build-xcframework-slices:
29-
name: Build ${{matrix.variant.name}}${{matrix.variant.suffix}} XCFramework Slice for ${{matrix.sdk}}
30-
# We must compile this on an arm64 runner, cause it's required for visionOS. macos-14 uses arm64.
31-
# To see the available runners see https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories.
32-
runs-on: macos-14
30+
build-xcframework-variant-slices:
31+
uses: ./.github/workflows/build-xcframework-variant-slices.yml
32+
with:
33+
name: ${{matrix.variant.name}}
34+
suffix: ${{matrix.variant.suffix}}
35+
macho-type: ${{matrix.variant.macho-type}}
36+
configuration-suffix: ${{matrix.variant.configuration-suffix}}
37+
variant-id: ${{matrix.variant.id}}
38+
include-maccatalyst: ${{matrix.include-maccatalyst}}
3339
strategy:
3440
matrix:
35-
sdk: [iphoneos, iphonesimulator, macosx, appletvos, appletvsimulator, watchos, watchsimulator, xros, xrsimulator]
3641
variant:
3742
- name: Sentry
3843
suffix: "-Dynamic"
3944
id: sentry-dynamic
45+
include-maccatalyst: "true"
4046
- name: Sentry
4147
macho-type: staticlib
4248
id: sentry-static
@@ -47,81 +53,32 @@ jobs:
4753
macho-type: mh_dylib
4854
configuration-suffix: WithoutUIKit
4955
id: sentry-withoutuikit-dynamic
50-
steps:
51-
- uses: actions/checkout@v4
52-
53-
# We have to compile on Xcode 15.2 because compiling on Xcode 15.4 fails with
54-
# Data+SentryTracing.swift:21:62: error: 'ReadingOptions' aliases 'Foundation.ReadingOptions'
55-
# and cannot be used here because C++ types from imported module 'Foundation' do not support
56-
# library evolution; this is an error in the Swift 6 language mode
57-
# We also can't use Xcode 16.x because validating the XCFramework then fails with Xcode 15.x.
58-
- run: ./scripts/ci-select-xcode.sh 15.2
5956

60-
- name: Build xcframework
61-
if: startsWith(github.ref, 'refs/heads/release/') == false
62-
run: ./scripts/build-xcframework-slice.sh ${{matrix.sdk}} ${{matrix.variant.name}} "${{matrix.variant.suffix}}" ${{matrix.variant.macho-type}} ${{matrix.variant.configuration-suffix}}
63-
shell: sh
64-
- name: Remove Sentry.framework from SentrySwiftUI build
65-
if: matrix.variant.name == 'SentrySwiftUI'
66-
run: |
67-
find "${{github.workspace}}/Carthage/archive" -name "Sentry.framework" -print0 | xargs -t0 rm -rf
68-
find "${{github.workspace}}/Carthage/archive" -name "Sentry.framework.dSYM" -print0 | xargs -t0 rm -rf
69-
- name: Archiving xcarchive
70-
uses: actions/upload-artifact@v4
71-
with:
72-
name: xcframework-${{matrix.variant.id}}-slice-${{matrix.sdk}}
73-
if-no-files-found: error
74-
path: |
75-
${{github.workspace}}/Carthage/archive/${{matrix.variant.name}}${{matrix.variant.suffix}}/${{matrix.sdk}}.xcarchive
76-
- name: Archive build log if failed
77-
uses: actions/upload-artifact@v4
78-
if: ${{ failure() || cancelled() }}
79-
with:
80-
name: raw-build-output-build-xcframework-${{matrix.variant.id}}-${{matrix.sdk}}
81-
path: |
82-
*.log
83-
84-
assemble-xcframeworks:
85-
name: Assemble ${{matrix.variant.name}}${{matrix.variant.suffix}}.xcframework
86-
runs-on: macos-14
87-
needs: build-xcframework-slices
57+
assemble-xcframework-variant:
58+
needs: build-xcframework-variant-slices
59+
uses: ./.github/workflows/assemble-xcframework-variant.yml
60+
with:
61+
name: ${{matrix.variant.name}}
62+
suffix: ${{matrix.variant.suffix}}
63+
variant-id: ${{matrix.variant.id}}
8864
strategy:
8965
matrix:
9066
variant:
9167
- name: Sentry
9268
suffix: "-Dynamic"
9369
id: sentry-dynamic
9470
- name: Sentry
95-
macho-type: staticlib
9671
id: sentry-static
9772
- name: SentrySwiftUI
9873
id: sentryswiftui
9974
- name: Sentry
10075
suffix: "-WithoutUIKitOrAppKit"
101-
macho-type: dylib
102-
configuration-suffix: WithoutUIKit
10376
id: sentry-withoutuikit-dynamic
104-
steps:
105-
- uses: actions/checkout@v4
106-
- name: Download ${{matrix.variant.id}} Slices
107-
uses: actions/download-artifact@v4
108-
with:
109-
pattern: xcframework-${{matrix.variant.id}}-slice-*
110-
path: xcframework-slices
111-
- name: Assemble XCFramework
112-
run: ./scripts/assemble-xcframework.sh "${{github.workspace}}/xcframework-slices" "${{matrix.variant.name}}${{matrix.variant.suffix}}"
113-
- name: Archive XCFramework
114-
uses: actions/upload-artifact@v4
115-
with:
116-
name: xcframework-${{github.sha}}-${{matrix.variant.id}}
117-
if-no-files-found: error
118-
path: ${{matrix.variant.name}}${{matrix.variant.suffix}}.xcframework.zip
11977

12078
validate-xcframework:
12179
name: Validate XCFramework
12280
runs-on: macos-13
123-
needs:
124-
- assemble-xcframeworks
81+
needs: assemble-xcframework-variant
12582
steps:
12683
- uses: actions/checkout@v4
12784
- uses: actions/download-artifact@v4
@@ -143,7 +100,7 @@ jobs:
143100
validate-spm:
144101
name: Validate Swift Package Manager
145102
runs-on: macos-13
146-
needs: assemble-xcframeworks
103+
needs: assemble-xcframework-variant
147104
steps:
148105
- uses: actions/checkout@v4
149106
- uses: actions/download-artifact@v4
@@ -163,7 +120,7 @@ jobs:
163120
validate-spm-dynamic:
164121
name: Validate Swift Package Manager Dynamic
165122
runs-on: macos-13
166-
needs: assemble-xcframeworks
123+
needs: assemble-xcframework-variant
167124
steps:
168125
- uses: actions/checkout@v4
169126
- uses: actions/download-artifact@v4
@@ -183,7 +140,7 @@ jobs:
183140
swift-build:
184141
name: Build with Swift
185142
runs-on: macos-13
186-
needs: assemble-xcframeworks
143+
needs: assemble-xcframework-variant
187144
steps:
188145
- uses: actions/checkout@v4
189146
- uses: actions/download-artifact@v4

0 commit comments

Comments
 (0)