Skip to content

Commit 5cfc768

Browse files
authored
ci: cache xcframework builds (#5449)
1 parent 2b02431 commit 5cfc768

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

.github/workflows/assemble-xcframework-variant.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,48 @@ jobs:
7070
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
7171
MATCH_USERNAME: ${{ secrets.MATCH_USERNAME }}
7272

73+
- name: Compute cache key
74+
run: |
75+
sdks_string=${{inputs.sdks}}
76+
sdks_string_slugified=${sdks_string//,/_}
77+
echo "SENTRY_XCFRAMEWORK_CACHE_KEY=${{runner.os}}-xcframework-${{inputs.variant-id}}-$sdks_string_slugified-${{inputs.signed}}-${{hashFiles('Sources/**')}}-${{hashFiles('Sentry.xcodeproj/**')}}" >> $GITHUB_ENV
78+
79+
- name: Restore XCFramework cache
80+
id: cache-xcframework
81+
uses: actions/cache@v4
82+
with:
83+
key: ${{env.SENTRY_XCFRAMEWORK_CACHE_KEY}}
84+
path: ${{inputs.name}}${{inputs.suffix}}.xcframework.zip
85+
7386
- name: Download ${{inputs.variant-id}} Slices
87+
if: steps.cache-xcframework.outputs.cache-hit != 'true'
7488
uses: actions/download-artifact@v4
7589
with:
7690
pattern: xcframework-${{inputs.variant-id}}-slice-*
7791
path: xcframework-slices
7892

7993
- name: Unzip slice artifact ZIP archives
94+
if: steps.cache-xcframework.outputs.cache-hit != 'true'
8095
run: |
8196
find xcframework-slices -type f -print0 | xargs -t0I @ unzip @ -d xcframework-slices
8297
shell: bash
8398

8499
- name: Assemble XCFramework
100+
if: steps.cache-xcframework.outputs.cache-hit != 'true'
85101
run: ./scripts/assemble-xcframework.sh "${{inputs.name}}" "${{inputs.suffix}}" "${{inputs.configuration-suffix}}" "${{inputs.sdks}}" "/Users/runner/work/sentry-cocoa/sentry-cocoa/xcframework-slices/SDK_NAME.xcarchive"
86102
shell: bash
87103

88104
- name: Zip XCFramework
105+
if: steps.cache-xcframework.outputs.cache-hit != 'true'
89106
run: ./scripts/compress-xcframework.sh ${{inputs.signed && '--sign' || '--not-signed'}} ${{inputs.name}}${{inputs.suffix}}
90107
shell: bash
91108

109+
- name: Cache XCFramework
110+
uses: actions/cache@v4
111+
with:
112+
key: ${{env.SENTRY_XCFRAMEWORK_CACHE_KEY}}
113+
path: ${{inputs.name}}${{inputs.suffix}}.xcframework.zip
114+
92115
- name: Upload XCFramework
93116
uses: actions/upload-artifact@v4
94117
with:

.github/workflows/build-xcframework-variant-slices.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,29 +85,50 @@ jobs:
8585
fi
8686
shell: sh
8787

88+
- name: Compute cache key
89+
run: |
90+
echo "SENTRY_XCFRAMEWORK_CACHE_KEY=${{ runner.os }}-xcframework-${{inputs.variant-id}}-slice-${{matrix.sdk}}-${{ env.VERSION }}-${{hashFiles('Sources/**')}}-${{hashFiles('Sentry.xcodeproj/**')}}" >> $GITHUB_ENV
91+
92+
- name: Restore xcarchive cache
93+
id: cache-xcarchive
94+
uses: actions/cache@v4
95+
with:
96+
key: ${{env.SENTRY_XCFRAMEWORK_CACHE_KEY}}
97+
path: ${{inputs.name}}${{inputs.suffix}}.xcarchive.zip
98+
8899
- name: Bump version
100+
if: steps.cache-xcarchive.outputs.cache-hit != 'true'
89101
run: |
90102
./scripts/ci-select-xcode.sh 15.2
91103
make bump-version TO=${{ env.VERSION }}
92104
93105
- name: Build ${{inputs.name}}${{inputs.suffix}} XCFramework slice for ${{matrix.sdk}}
106+
if: steps.cache-xcarchive.outputs.cache-hit != 'true'
94107
run: ./scripts/build-xcframework-slice.sh ${{matrix.sdk}} ${{inputs.name}} "${{inputs.suffix}}" "${{inputs.macho-type}}" "${{inputs.configuration-suffix}}"
95108
shell: bash
96109

97110
# The SentrySwiftUI archive build also builds Sentry.framework as a byproduct of the dependency. We need to remove that to avoid downstream assembly tasks from tripping on these extra files. In the future we could investigate using this byproduct instead of running a separate task for Sentry.framework, or use the one already built by that other task instead of rebuilding it here.
98111
- name: Remove Sentry.framework from SentrySwiftUI build
99-
if: inputs.name == 'SentrySwiftUI'
112+
if: steps.cache-xcarchive.outputs.cache-hit != 'true' && inputs.name == 'SentrySwiftUI'
100113
run: |
101114
find "${{github.workspace}}/Carthage/archive" -name "Sentry.framework" -print0 | xargs -t0 rm -rf
102115
find "${{github.workspace}}/Carthage/archive" -name "Sentry.framework.dSYM" -print0 | xargs -t0 rm -rf
103116
shell: bash
104117

105118
# the upload action broke symlinks in the mac sdk slice's xcarchive
106119
- name: Zip xcarchive
120+
if: steps.cache-xcarchive.outputs.cache-hit != 'true'
107121
run: |
108122
ditto -c -k -X --rsrc --keepParent ${{github.workspace}}/Carthage/archive/${{inputs.name}}${{inputs.suffix}}/${{matrix.sdk}}.xcarchive ${{inputs.name}}${{inputs.suffix}}.xcarchive.zip
109123
shell: bash
110124

125+
- name: Cache xcarchive
126+
if: steps.cache-xcarchive.outputs.cache-hit != 'true'
127+
uses: actions/cache@v4
128+
with:
129+
key: ${{env.SENTRY_XCFRAMEWORK_CACHE_KEY}}
130+
path: ${{inputs.name}}${{inputs.suffix}}.xcarchive.zip
131+
111132
- name: Upload xcarchive
112133
uses: actions/upload-artifact@v4
113134
with:

0 commit comments

Comments
 (0)