|
| 1 | +name: "Build Sentry Cocoa XCFramework variant slices" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + sdk-list: |
| 7 | + description: |- |
| 8 | + 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. |
| 9 | + Possible values: iphoneos, iphonesimulator, macosx, appletvos, appletvsimulator, watchos, watchsimulator, xros, xrsimulator. |
| 10 | + required: false |
| 11 | + default: '["iphoneos", "iphonesimulator", "macosx", "maccatalyst", "appletvos", "appletvsimulator", "watchos", "watchsimulator", "xros", "xrsimulator"]' |
| 12 | + type: string |
| 13 | + |
| 14 | + name: |
| 15 | + description: |- |
| 16 | + The Sentry project target to build an XCFramework slice for. |
| 17 | + Possible values: Sentry, SentrySwiftUI. |
| 18 | + required: true |
| 19 | + type: string |
| 20 | + |
| 21 | + suffix: |
| 22 | + description: |- |
| 23 | + The suffix to add to the build product name. |
| 24 | + E.g. "-Dynamic" or "-WithoutUIKitOrAppKit". |
| 25 | + required: false |
| 26 | + type: string |
| 27 | + |
| 28 | + macho-type: |
| 29 | + description: |- |
| 30 | + The Mach-O type of the build product. |
| 31 | + Possible values: mh_dylib, staticlib. |
| 32 | + required: false |
| 33 | + type: string |
| 34 | + default: "mh_dylib" |
| 35 | + |
| 36 | + configuration-suffix: |
| 37 | + description: |- |
| 38 | + The suffix to add to the build product name to build an alternate configuration of the target. |
| 39 | + E.g. "WithoutUIKit". |
| 40 | + required: false |
| 41 | + type: string |
| 42 | + |
| 43 | + variant-id: |
| 44 | + description: |- |
| 45 | + The ID of the variant to build an XCFramework slice for. Used to collect appropriate slices for final deliverable assembly. |
| 46 | + required: true |
| 47 | + type: string |
| 48 | + |
| 49 | + release-version: |
| 50 | + description: |- |
| 51 | + For release workflows, the version to inject into the SDK. |
| 52 | + required: false |
| 53 | + type: string |
| 54 | + |
| 55 | +jobs: |
| 56 | + build-xcframework-variant-slices: |
| 57 | + name: ${{matrix.sdk}} |
| 58 | + |
| 59 | + # We must compile this on an arm64 runner, cause it's required for visionOS. macos-14 uses arm64. |
| 60 | + # 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. |
| 61 | + runs-on: macos-14 |
| 62 | + |
| 63 | + strategy: |
| 64 | + matrix: |
| 65 | + sdk: ${{ fromJson(inputs.sdk-list) }} |
| 66 | + |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + |
| 70 | + # We have to compile on Xcode 15.2 because compiling on Xcode 15.4 fails with |
| 71 | + # Data+SentryTracing.swift:21:62: error: 'ReadingOptions' aliases 'Foundation.ReadingOptions' |
| 72 | + # and cannot be used here because C++ types from imported module 'Foundation' do not support |
| 73 | + # library evolution; this is an error in the Swift 6 language mode |
| 74 | + # We also can't use Xcode 16.x because validating the XCFramework then fails with Xcode 15.x. |
| 75 | + - run: ./scripts/ci-select-xcode.sh 15.2 |
| 76 | + shell: bash |
| 77 | + |
| 78 | + - name: Get version |
| 79 | + id: get-version |
| 80 | + run: | |
| 81 | + if [ -n "${{ inputs.release-version }}" ]; then |
| 82 | + echo "VERSION=${{ inputs.release-version }}" >> $GITHUB_ENV |
| 83 | + else |
| 84 | + echo "VERSION=$(grep MARKETING_VERSION Sources/Configuration/Versioning.xcconfig | cut -d ' ' -f 3)+${{ github.sha }}" >> $GITHUB_ENV |
| 85 | + fi |
| 86 | + shell: sh |
| 87 | + |
| 88 | + - name: Bump version |
| 89 | + run: | |
| 90 | + ./scripts/ci-select-xcode.sh 15.2 |
| 91 | + make bump-version TO=${{ env.VERSION }} |
| 92 | +
|
| 93 | + - name: Build ${{inputs.name}}${{inputs.suffix}} XCFramework slice for ${{matrix.sdk}} |
| 94 | + if: startsWith(github.ref, 'refs/heads/release/') == false |
| 95 | + run: ./scripts/build-xcframework-slice.sh ${{matrix.sdk}} ${{inputs.name}} "${{inputs.suffix}}" "${{inputs.macho-type}}" "${{inputs.configuration-suffix}}" |
| 96 | + shell: bash |
| 97 | + |
| 98 | + # 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. |
| 99 | + - name: Remove Sentry.framework from SentrySwiftUI build |
| 100 | + if: inputs.name == 'SentrySwiftUI' |
| 101 | + run: | |
| 102 | + find "${{github.workspace}}/Carthage/archive" -name "Sentry.framework" -print0 | xargs -t0 rm -rf |
| 103 | + find "${{github.workspace}}/Carthage/archive" -name "Sentry.framework.dSYM" -print0 | xargs -t0 rm -rf |
| 104 | + shell: bash |
| 105 | + |
| 106 | + # the upload action broke symlinks in the mac sdk slice's xcarchive |
| 107 | + - name: Zip xcarchive |
| 108 | + run: | |
| 109 | + ditto -c -k -X --rsrc --keepParent ${{github.workspace}}/Carthage/archive/${{inputs.name}}${{inputs.suffix}}/${{matrix.sdk}}.xcarchive ${{inputs.name}}${{inputs.suffix}}.xcarchive.zip |
| 110 | + shell: bash |
| 111 | + |
| 112 | + - name: Upload xcarchive |
| 113 | + uses: actions/upload-artifact@v4 |
| 114 | + with: |
| 115 | + name: xcframework-${{inputs.variant-id}}-slice-${{matrix.sdk}} |
| 116 | + if-no-files-found: error |
| 117 | + path: | |
| 118 | + ${{inputs.name}}${{inputs.suffix}}.xcarchive.zip |
| 119 | +
|
| 120 | + - name: Upload build log if failed |
| 121 | + uses: actions/upload-artifact@v4 |
| 122 | + if: ${{ failure() || cancelled() }} |
| 123 | + with: |
| 124 | + name: raw-build-output-build-xcframework-${{inputs.variant-id}}-${{matrix.sdk}} |
| 125 | + path: | |
| 126 | + *.log |
0 commit comments