|
| 1 | +name: Apple CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - dev |
| 8 | + tags: ['*'] |
| 9 | + paths: |
| 10 | + - '**' |
| 11 | + - '!docs/**' |
| 12 | + - '!.github/**' |
| 13 | + - '.github/workflows/apple.yml' |
| 14 | + pull_request: |
| 15 | + release: |
| 16 | + types: ['created'] |
| 17 | + workflow_dispatch: |
| 18 | + inputs: |
| 19 | + cmakeextra: |
| 20 | + description: 'Extra CMake options' |
| 21 | + required: false |
| 22 | + default: '' |
| 23 | + |
| 24 | +concurrency: |
| 25 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 26 | + cancel-in-progress: true |
| 27 | + |
| 28 | +defaults: |
| 29 | + run: |
| 30 | + shell: bash |
| 31 | + |
| 32 | +jobs: |
| 33 | + build: |
| 34 | + name: ${{ matrix.config.name }} |
| 35 | + runs-on: ${{ matrix.config.os }} |
| 36 | + strategy: |
| 37 | + fail-fast: false |
| 38 | + matrix: |
| 39 | + config: |
| 40 | + - {name: "macOS-latest", os: "macOS-latest", cmake_extra: "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DLSL_UNITTESTS=ON -DLSL_BENCHMARKS=ON -DCMAKE_OSX_ARCHITECTURES=\"x86_64;arm64\"" } |
| 41 | + - {name: "iOS", os: "macOS-latest", cmake_extra: "-DCMAKE_TOOLCHAIN_FILE=cmake/ios.toolchain.cmake -DPLATFORM=OS64" } |
| 42 | + - {name: "iOS Simulator", os: "macOS-latest", cmake_extra: "-DCMAKE_TOOLCHAIN_FILE=cmake/ios.toolchain.cmake -DPLATFORM=SIMULATOR64COMBINED -G Xcode" } |
| 43 | + |
| 44 | + steps: |
| 45 | + - uses: actions/checkout@v4 |
| 46 | + |
| 47 | + - name: Install certificates and provisioning profiles |
| 48 | + uses: ./.github/actions/install-apple-certs |
| 49 | + with: |
| 50 | + MACOS_CERTIFICATE_APP: ${{ secrets.PROD_MACOS_CERTIFICATE }} |
| 51 | + MACOS_CERTIFICATE_INST: ${{ secrets.PROD_MACOS_CERTIFICATE_INST }} |
| 52 | + MACOS_CERTIFICATE_PWD: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }} |
| 53 | + MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }} |
| 54 | + |
| 55 | + - name: Configure CMake |
| 56 | + env: |
| 57 | + APPLE_DEVELOPMENT_TEAM: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }} |
| 58 | + run: | |
| 59 | + cmake --version |
| 60 | + cmake -S . -B build \ |
| 61 | + -DCMAKE_BUILD_TYPE=Release \ |
| 62 | + -DCMAKE_INSTALL_PREFIX=${PWD}/install \ |
| 63 | + -DCPACK_PACKAGE_DIRECTORY=${PWD}/package \ |
| 64 | + -DLSL_FRAMEWORK=ON \ |
| 65 | + -Dlslgitrevision=${{ github.sha }} \ |
| 66 | + -Dlslgitbranch=${{ github.ref }} \ |
| 67 | + ${{ matrix.config.cmake_extra }} \ |
| 68 | + ${{ github.event.inputs.cmakeextra }} |
| 69 | + echo ${PWD} |
| 70 | +
|
| 71 | + - name: make |
| 72 | + run: cmake --build build --config Release -j |
| 73 | + |
| 74 | + - name: make install |
| 75 | + run: cmake --build build --config Release --target install |
| 76 | + |
| 77 | + - name: test install using examples |
| 78 | + if: matrix.config.name == 'macOS-latest' |
| 79 | + run: | |
| 80 | + # Test that the in-tree install was successful by building the examples |
| 81 | + cmake -S examples -B examples/build \ |
| 82 | + -DLSL_INSTALL_ROOT=${PWD}/install \ |
| 83 | + -DCMAKE_INSTALL_PREFIX=examples/build/install \ |
| 84 | + -DLSL_COMFY_DEFAULTS=ON \ |
| 85 | + ${{ matrix.config.cmake_extra }} \ |
| 86 | + ${{ github.event.inputs.cmakeextra }} |
| 87 | + cmake --build examples/build --target install --config Release -j |
| 88 | + ./examples/build/install/bin/HandleMetaData |
| 89 | +
|
| 90 | + - name: Codesign |
| 91 | + run: | |
| 92 | + if [[ "${{ matrix.config.name }}" == "macOS-latest" ]]; then |
| 93 | + codesign -vvv --force --deep --sign "$APPLE_CODE_SIGN_IDENTITY_APP" \ |
| 94 | + --entitlements lsl.entitlements --options runtime \ |
| 95 | + install/Frameworks/lsl.framework/Versions/A/lsl |
| 96 | + codesign -vvv --verify --deep --strict install/Frameworks/lsl.framework/Versions/A/lsl |
| 97 | + elif [[ "${{ matrix.config.name }}" == "iOS" || "${{ matrix.config.name }}" == "iOS Simulator" ]]; then |
| 98 | + codesign -vvv --force --deep --sign "$APPLE_CODE_SIGN_IDENTITY_APP" \ |
| 99 | + install/Frameworks/lsl.framework/lsl |
| 100 | + codesign -vvv --verify --deep --strict install/Frameworks/lsl.framework/lsl |
| 101 | + fi |
| 102 | + codesign -vvv --force --deep --sign "$APPLE_CODE_SIGN_IDENTITY_APP" \ |
| 103 | + --entitlements lsl.entitlements --options runtime \ |
| 104 | + install/Frameworks/lsl.framework |
| 105 | + codesign -vvv --verify --deep --strict install/Frameworks/lsl.framework |
| 106 | +
|
| 107 | + # run internal tests |
| 108 | + - name: unit tests |
| 109 | + if: matrix.config.name == 'macOS-latest' |
| 110 | + run: | |
| 111 | + mkdir -p dumps |
| 112 | + install/bin/lsl_test_internal --order rand --wait-for-keypress never --durations yes |
| 113 | + install/bin/lsl_test_exported --order rand --wait-for-keypress never --durations yes |
| 114 | + timeout-minutes: 10 |
| 115 | + |
| 116 | + - name: Package and Notarize macOS Installer |
| 117 | + if: matrix.config.name == 'macOS-latest' |
| 118 | + env: |
| 119 | + APPLE_DEVELOPMENT_TEAM: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }} |
| 120 | + APPLE_NOTARIZE_USERNAME: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }} |
| 121 | + APPLE_NOTARIZE_PASSWORD: ${{ secrets.PROD_MACOS_NOTARIZATION_PWD }} |
| 122 | + run: | |
| 123 | + # Get the version number from the framework's Info.plist |
| 124 | + LSL_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" install/Frameworks/lsl.framework/Versions/A/Resources/Info.plist) |
| 125 | + echo "LSL_VERSION=$LSL_VERSION" >> $GITHUB_ENV |
| 126 | + echo "Debug: LSL_VERSION=$LSL_VERSION" |
| 127 | +
|
| 128 | + mkdir -p package |
| 129 | + productbuild --sign "$APPLE_CODE_SIGN_IDENTITY_INST" \ |
| 130 | + --component install/Frameworks/lsl.framework \ |
| 131 | + /Library/Frameworks package/liblsl-${LSL_VERSION}-Darwin-universal.pkg |
| 132 | + # Notarize the package |
| 133 | + xcrun notarytool submit package/liblsl-${LSL_VERSION}-Darwin-universal.pkg \ |
| 134 | + --apple-id "$APPLE_NOTARIZE_USERNAME" \ |
| 135 | + --password "$APPLE_NOTARIZE_PASSWORD" \ |
| 136 | + --team-id "$APPLE_DEVELOPMENT_TEAM" \ |
| 137 | + --wait |
| 138 | + # Staple the notarization ticket to the package |
| 139 | + xcrun stapler staple package/liblsl-${LSL_VERSION}-Darwin-universal.pkg |
| 140 | +
|
| 141 | + - name: upload dump |
| 142 | + if: failure() |
| 143 | + uses: actions/upload-artifact@v4 |
| 144 | + with: |
| 145 | + name: dumps-${{ matrix.config.name }} |
| 146 | + path: dumps |
| 147 | + |
| 148 | + - name: Zip LSL Framework |
| 149 | + run: | |
| 150 | + cd install/Frameworks |
| 151 | + zip -ry lsl.framework.zip lsl.framework |
| 152 | + cd ../.. |
| 153 | +
|
| 154 | + - name: Upload macOS Package and Framework |
| 155 | + if: matrix.config.name == 'macOS-latest' |
| 156 | + uses: actions/upload-artifact@v4 |
| 157 | + with: |
| 158 | + name: build-macOS-latest |
| 159 | + path: | |
| 160 | + package/*.pkg |
| 161 | + install/Frameworks/lsl.framework.zip |
| 162 | + # Note: the artifact will preserve the folder structure up to the common root, in this case all. |
| 163 | + |
| 164 | + - name: Upload iOS Framework |
| 165 | + if: matrix.config.name == 'iOS' |
| 166 | + uses: actions/upload-artifact@v4 |
| 167 | + with: |
| 168 | + name: build-iOS |
| 169 | + path: install/Frameworks/lsl.framework.zip |
| 170 | + # Note: the artifact drops the folder structure and only keeps the zip. |
| 171 | + |
| 172 | + - name: Upload iOS Simulator Framework |
| 173 | + if: matrix.config.name == 'iOS Simulator' |
| 174 | + uses: actions/upload-artifact@v4 |
| 175 | + with: |
| 176 | + name: build-iOS-Simulator |
| 177 | + path: install/Frameworks/lsl.framework.zip |
| 178 | + |
| 179 | + xcframework_and_deploy: |
| 180 | + name: XCFramework and Deploy |
| 181 | + needs: build |
| 182 | + runs-on: macOS-latest |
| 183 | + steps: |
| 184 | + - uses: actions/checkout@v4 |
| 185 | + - uses: actions/download-artifact@v4 |
| 186 | + with: |
| 187 | + name: build-macOS-latest |
| 188 | + path: build-macOS-latest |
| 189 | + - uses: actions/download-artifact@v4 |
| 190 | + with: |
| 191 | + name: build-iOS |
| 192 | + path: build-iOS |
| 193 | + - uses: actions/download-artifact@v4 |
| 194 | + with: |
| 195 | + name: build-iOS-Simulator |
| 196 | + path: build-iOS-Simulator |
| 197 | + |
| 198 | + - name: Unzip macOS Framework |
| 199 | + run: | |
| 200 | + unzip build-macOS-latest/install/Frameworks/lsl.framework.zip -d build-macOS-latest/Frameworks |
| 201 | +
|
| 202 | + - name: Unzip iOS Framework |
| 203 | + run: | |
| 204 | + unzip build-iOS/lsl.framework.zip -d build-iOS/Frameworks |
| 205 | +
|
| 206 | + - name: Unzip iOS Simulator Framework |
| 207 | + run: | |
| 208 | + unzip build-iOS-Simulator/lsl.framework.zip -d build-iOS-Simulator/Frameworks |
| 209 | +
|
| 210 | + - name: Install certificates and provisioning profiles |
| 211 | + uses: ./.github/actions/install-apple-certs |
| 212 | + with: |
| 213 | + MACOS_CERTIFICATE_APP: ${{ secrets.PROD_MACOS_CERTIFICATE }} |
| 214 | + MACOS_CERTIFICATE_INST: ${{ secrets.PROD_MACOS_CERTIFICATE_INST }} |
| 215 | + MACOS_CERTIFICATE_PWD: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }} |
| 216 | + MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }} |
| 217 | + |
| 218 | + - name: Create and Sign XCFramework |
| 219 | + run: | |
| 220 | + xcodebuild -create-xcframework \ |
| 221 | + -framework build-macOS-latest/Frameworks/lsl.framework \ |
| 222 | + -framework build-iOS/Frameworks/lsl.framework \ |
| 223 | + -framework build-iOS-Simulator/Frameworks/lsl.framework \ |
| 224 | + -output lsl.xcframework |
| 225 | + |
| 226 | + codesign -vvv --force --deep --sign "$APPLE_CODE_SIGN_IDENTITY_APP" lsl.xcframework |
| 227 | + echo "✅ Verifying binary signatures in XCFramework..." |
| 228 | + codesign -vvv --verify --deep --strict lsl.xcframework |
| 229 | +
|
| 230 | + ditto -c -k --sequesterRsrc --keepParent lsl.xcframework lsl.xcframework.$LSL_VERSION.zip |
| 231 | +
|
| 232 | + - name: upload artifacts |
| 233 | + uses: actions/upload-artifact@v4 |
| 234 | + with: |
| 235 | + name: mac-packages |
| 236 | + path: | |
| 237 | + lsl.xcframework.*.zip |
| 238 | + package/ |
| 239 | +
|
| 240 | + - name: upload to release page |
| 241 | + if: github.event_name == 'release' |
| 242 | + env: |
| 243 | + TOKEN: "token ${{ secrets.GITHUB_TOKEN }}" |
| 244 | + TAG: ${{ github.event.release.tag_name }} |
| 245 | + UPLOAD_URL: ${{ github.event.release.upload_url }} |
| 246 | + run: | |
| 247 | + UPLOAD_URL=${UPLOAD_URL%\{*} # remove "{name,label}" suffix |
| 248 | + for pkg in lsl.xcframework.zip package/*.*; do |
| 249 | + NAME=$(basename $pkg) |
| 250 | + MIME=$(file --mime-type $pkg|cut -d ' ' -f2) |
| 251 | + curl -X POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: $TOKEN" -H "Content-Type: $MIME" --data-binary @$pkg $UPLOAD_URL?name=$NAME |
| 252 | + done |
0 commit comments