From 26f1f30345a0a202d1dd580d68cbd6d0972a7ac6 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 9 Oct 2024 10:38:38 -0700 Subject: [PATCH] Move Xcode 16 jobs to the macos-15 runner Xcode 16 will be removed from macos-14 to cut down on the image size: https://github.com/actions/runner-images/issues/10703 --- .github/workflows/master-push.yml | 149 +++++++++------------ build.sh | 206 +----------------------------- scripts/create-release-package.rb | 9 +- 3 files changed, 67 insertions(+), 297 deletions(-) diff --git a/.github/workflows/master-push.yml b/.github/workflows/master-push.yml index 1f4a666c78..efa2b1b196 100644 --- a/.github/workflows/master-push.yml +++ b/.github/workflows/master-push.yml @@ -6,10 +6,10 @@ on: - "master" - "release/**" env: - XCODE_VERSION: "['15.3', '15.4', '16', '16.1_beta_2']" + XCODE_VERSION: "['15.3', '15.4', '16', '16.1_beta_3']" PLATFORM: "['ios', 'osx', 'watchos', 'tvos', 'catalyst', 'visionos']" - DOC_VERSION: '15.4' RELEASE_VERSION: '15.4' + DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer jobs: prepare: runs-on: ubuntu-latest @@ -38,8 +38,6 @@ jobs: - uses: ruby/setup-ruby@v1 with: bundler-cache: true - - name: Select Xcode Version - run: sudo xcode-select -switch /Applications/Xcode_${{ env.DOC_VERSION }}.app - name: Prepare docs for packaging run: bundle exec sh -x build.sh release-package-docs - name: Upload docs to artifacts library @@ -61,15 +59,27 @@ jobs: name: realm-examples path: realm-examples.zip build-product: # Creates framework for each platform, xcode version, target and configuration - runs-on: macos-14 name: Package framework needs: prepare strategy: - max-parallel: 20 # Blocks of 20, therefore if any of the build fails, we don't get a lot of XCode Clouds builds hanging, which are expensive. + max-parallel: 20 matrix: platform: ${{ fromJSON(needs.prepare.outputs.PLATFORM_MATRIX) }} xcode-version: ${{ fromJSON(needs.prepare.outputs.XCODE_VERSIONS_MATRIX) }} configuration: [swift, static] + include: + - xcode-version: 15.3 + xcode-version-tag: 15.3 + os: macos-14 + - xcode-version: 15.4 + xcode-version-tag: 15.4 + os: macos-14 + - xcode-version: 16 + xcode-version-tag: '16.0' + os: macos-15 + - xcode-version: 16.1_beta_3 + xcode-version-tag: 16.1 + os: macos-15 exclude: - platform: osx configuration: static @@ -81,79 +91,39 @@ jobs: configuration: static - platform: catalyst configuration: static - - platform: visionos - xcode-version: 15.1 + runs-on: ${{ matrix.os }} + env: + DEVELOPER_DIR: /Applications/Xcode_${{matrix.xcode-version}}.app/Contents/Developer steps: - uses: actions/checkout@v4 - - name: Build ${{ matrix.platform }} with Xcode ${{ matrix.xcode-version }} - run: DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode-version }}.app/Contents/Developer sh build.sh ${{ matrix.platform }}-${{matrix.configuration}} - - run: rm -r build/DerivedData + - name: Download visionOS + if: matrix.platform == 'visionos' && matrix.os == 'macos-14' + run: xcodebuild -downloadPlatform visionOS + - run: sh build.sh ${{matrix.platform}}-${{matrix.configuration}} + - run: tar cf build.tar build/*/${{matrix.platform}} - name: Upload framework uses: actions/upload-artifact@v4 with: - name: build-${{ matrix.platform }}-${{ matrix.xcode-version }}-${{ matrix.configuration }} - path: build + name: build-${{matrix.platform}}-${{matrix.xcode-version-tag}}-${{matrix.configuration}} + path: build.tar compression-level: 1 - package-xcframework-platform: # Creates xcframework for each platform and xcode version - runs-on: macos-14 - name: Package xcframework for platform - needs: [build-product, prepare] - strategy: - matrix: - platform: ${{ fromJSON(needs.prepare.outputs.PLATFORM_MATRIX) }} - xcode-version: ${{ fromJSON(needs.prepare.outputs.XCODE_VERSIONS_MATRIX) }} - exclude: - - platform: visionos - xcode-version: 15.1 - steps: - - uses: actions/checkout@v4 - - name: Select Xcode Version - run: sudo xcode-select -switch /Applications/Xcode_${{ env.RELEASE_VERSION }}.app - - name: Install the Apple certificate and provisioning profile - env: - DEVELOPMENT_CERTIFICATE_BASE64: ${{ secrets.DEVELOPMENT_CERTIFICATE_BASE64 }} - P12_PASSWORD: ${{ secrets.P12_PASSWORD }} - KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} - run: | - sh -x build.sh install-apple-certificates - - name: Restore frameworks - uses: actions/download-artifact@v4 - with: - pattern: build-${{ matrix.platform }}*-${{ matrix.xcode-version }}-* - - name: Create xcframework - env: - SIGNING_IDENTITY: ${{ secrets.SIGNING_IDENTITY }} - run: | - sh -x build.sh release-create-xcframework-${{ matrix.xcode-version }} ${{ matrix.platform }} - - name: Upload xcframework - uses: actions/upload-artifact@v4 - with: - name: realm-${{ matrix.platform }}-${{ matrix.xcode-version }} - path: realm-${{ matrix.platform }}-${{ matrix.xcode-version }}.zip - package-release: # Creates xcframework for each platform and xcode version + package-release: runs-on: macos-14 name: Package release file - needs: [package-xcframework-platform, prepare] + needs: [build-product, prepare] steps: - uses: actions/checkout@v4 - - name: Select Xcode Version - run: sudo xcode-select -switch /Applications/Xcode_${{ env.RELEASE_VERSION }}.app + - uses: actions/download-artifact@v4 - name: Install the Apple certificate and provisioning profile env: DEVELOPMENT_CERTIFICATE_BASE64: ${{ secrets.DEVELOPMENT_CERTIFICATE_BASE64 }} P12_PASSWORD: ${{ secrets.P12_PASSWORD }} KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} - run: | - sh -x build.sh install-apple-certificates - - name: Restore packages xcframeworks - uses: actions/download-artifact@v4 - with: - pattern: realm-* + run: sh build.sh install-apple-certificates - name: Create release env: SIGNING_IDENTITY: ${{ secrets.SIGNING_IDENTITY }} - run: | - sh -x build.sh release-package + run: sh -x build.sh release-package - name: Upload release artifactss uses: actions/upload-artifact@v4 with: @@ -162,7 +132,7 @@ jobs: - name: Upload release for testing uses: actions/upload-artifact@v4 with: - name: realm-swift-${{ needs.prepare.outputs.VERSION }} + name: test-release-package path: pkg/realm-swift-${{ needs.prepare.outputs.VERSION }}.zip test-package-examples: runs-on: macos-14 @@ -170,12 +140,10 @@ jobs: needs: [package-release, prepare] steps: - uses: actions/checkout@v4 - - name: Select Xcode Version - run: sudo xcode-select -switch /Applications/Xcode_${{ env.RELEASE_VERSION }}.app - name: Restore release uses: actions/download-artifact@v4 with: - name: realm-swift-${{ needs.prepare.outputs.VERSION }} + name: test-release-package - name: Test examples run: sh -x build.sh release-test-examples test-ios-static: @@ -184,8 +152,6 @@ jobs: needs: package-release steps: - uses: actions/checkout@v4 - - name: Select Xcode Version - run: sudo xcode-select -switch /Applications/Xcode_${{ env.RELEASE_VERSION }}.app - name: Test ios static run: sh -x build.sh test-ios-static test-osx-static: @@ -194,8 +160,6 @@ jobs: needs: package-release steps: - uses: actions/checkout@v4 - - name: Select Xcode Version - run: sudo xcode-select -switch /Applications/Xcode_${{ env.RELEASE_VERSION }}.app - name: Test osx static run: | export REALM_DISABLE_METADATA_ENCRYPTION=1 @@ -204,10 +168,12 @@ jobs: runs-on: macos-14 name: Run installation test needs: [package-release, prepare] + env: + REALM_TEST_BRANCH: "${{github.ref_name}}" strategy: matrix: platform: ${{ fromJSON(needs.prepare.outputs.PLATFORM_MATRIX) }} - installation: [cocoapods, spm, carthage, xcframework] + installation: [cocoapods, spm, carthage] linkage: [dynamic, static] exclude: - platform: visionos @@ -215,8 +181,6 @@ jobs: installation: carthage - installation: carthage linkage: static - - installation: xcframework - linkage: static include: - platform: ios installation: xcframework @@ -226,50 +190,51 @@ jobs: - uses: ruby/setup-ruby@v1 with: bundler-cache: true - - name: Select Xcode Version - run: sudo xcode-select -switch /Applications/Xcode_${{ env.RELEASE_VERSION }}.app + - name: Download visionOS + if: matrix.platform == 'visionos' && matrix.os == 'macos-14' + run: xcodebuild -downloadPlatform visionOS - name: Restore release uses: actions/download-artifact@v4 if: ${{ matrix.installation == 'xcframework' }} with: - name: realm-${{ matrix.platform }}-${{ env.RELEASE_VERSION }} - - name: Unzip package release - if: ${{ matrix.installation == 'xcframework' }} - run: | - mkdir -p build - unzip realm-${{ matrix.platform }}-${{ env.RELEASE_VERSION }}.zip -d build + name: test-release-package - name: Run installation test run: | - echo "REALM_TEST_BRANCH=${{ github.ref_name }}" >> $GITHUB_OUTPUT + find . -name '*.zip' -depth 1 -exec mv {} examples/installation \; cd examples/installation bundle exec ./build.rb ${{ matrix.platform }} ${{ matrix.installation }} ${{ matrix.linkage }} test-installation-xcframework: - runs-on: macos-14 name: Run installation test for xcframework needs: [package-release, prepare] - env: - PLATFORM: 'osx' strategy: matrix: xcode-version: ${{ fromJSON(needs.prepare.outputs.XCODE_VERSIONS_MATRIX) }} + include: + - xcode-version: 15.3 + os: macos-14 + - xcode-version: 15.4 + os: macos-14 + - xcode-version: 16 + os: macos-15 + - xcode-version: 16.1_beta_3 + os: macos-15 + env: + PLATFORM: 'osx' + DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode-version }}.app/Contents/Developer + REALM_TEST_BRANCH: "${{github.ref_name}}" + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: bundler-cache: true - - name: Select Xcode Version - run: sudo xcode-select -switch /Applications/Xcode_${{ matrix.xcode-version }}.app - name: Restore release uses: actions/download-artifact@v4 with: - name: realm-${{ env.PLATFORM }}-${{ matrix.xcode-version }} - - name: Unzip package release - run: | - mkdir -p build - unzip realm-${{ env.PLATFORM }}-${{ matrix.xcode-version }}.zip -d build + name: test-release-package - name: Run installation test run: | - echo "REALM_TEST_BRANCH=${{ github.ref_name }}" >> $GITHUB_OUTPUT + find . -name '*.zip' -depth 1 -exec mv {} examples/installation \; cd examples/installation bundle exec ./build.rb osx xcframework dynamic diff --git a/build.sh b/build.sh index 4783b5ce5c..ec16935855 100755 --- a/build.sh +++ b/build.sh @@ -200,89 +200,12 @@ build_combined() { -framework "$os_path" "${simulator_framework[@]}" } -# To be used with Github actions runner -build_platform() { - local product="$1" - local platform="$2" - local config="$CONFIGURATION" - - local destination build_args config_suffix - case "$platform" in - osx) - config_suffix= - destination='generic/platform=macOS' - ;; - ios) - config_suffix=-iphoneos - destination='generic/platform=iOS' - ;; - watchos) - config_suffix=-watchos - destination='generic/platform=watchOS' - ;; - tvos) - config_suffix=-appletvos - destination='generic/platform=tvOS' - ;; - visionos) - config_suffix=-xros - destination='generic/platform=visionOS' - ;; - catalyst) - config_suffix=-maccatalyst - destination='generic/platform=macOS,variant=Mac Catalyst' - ;; - osx) - destination='generic/platform=macOS' - ;; - iossimulator) - config_suffix=-iphonesimulator - destination='generic/platform=iOS' - ;; - watchossimulator) - config_suffix=-watchsimulator - destination='generic/platform=watchOS' - ;; - tvossimulator) - config_suffix=-appletvsimulator - destination='generic/platform=tvOS' - ;; - visionossimulator) - config_suffix=-xrsimulator - destination='generic/platform=visionOS' - ;; - esac - - build_products_path="$DERIVED_DATA/Realm/Build/Products" - build_path="$build_products_path/$config${config_suffix}" - - build_args=(-scheme "$product" -configuration "$config" build REALM_HIDE_SYMBOLS=YES) - - if [[ "$platform" = *"simulator" ]]; then - xc -destination "$destination Simulator" "${build_args[@]}" - else - xc -destination "$destination" "${build_args[@]}" - fi - - # This is only for test, and simulates how it is packaged by XCode Cloud - number="$((10000 + $RANDOM % 99999))" - folder_name="RealmSwift Build $number Build Products for $product on iOS" - dir="$folder_name/$config${config_suffix}" - mkdir -p "$dir" - cp -a "$build_path/." "$dir" - - config_name="$(tr [A-Z] [a-z] <<< "$config")" - zip -r product.zip "$dir" - rm -rf "$folder_name" -} - create_xcframework() { local product="$1" local config="$2" - local platform="$3" - local out_path="$ROOT_WORKSPACE/$config/$platform/$product.xcframework" - find "$ROOT_WORKSPACE" -path "*/$config*/$product.framework" \ + local out_path="$ROOT_WORKSPACE/$config/$product.xcframework" + find "$ROOT_WORKSPACE"/build-*/"$config" -name "$product.framework" \ | sed 's/.*/-framework &/' \ | xargs xcodebuild -create-xcframework -allow-internal-distribution -output "$out_path" codesign --timestamp -s "$SIGNING_IDENTITY" "$out_path" @@ -1086,29 +1009,10 @@ case "$COMMAND" in zip -r docs/realm-docs.zip docs/objc_output docs/swift_output ;; - release-create-xcframework-*) - platform="$2" - xcode_version=$(echo "$COMMAND" | cut -d- -f4) - - find . -name 'build-*.zip' -exec unzip {} \; - - create_xcframework Realm Release "$platform" - create_xcframework RealmSwift Release "$platform" - - if [ "$platform" = "ios" ]; then - create_xcframework Realm Static "$platform" - else - mkdir -p "Static/$platform" - fi - - zip --symlinks -r "realm-$platform-$xcode_version.zip" "Release/$platform" "Static/$platform" - exit 0 - ;; - "release-package") version="$(sed -n 's/^VERSION=\(.*\)$/\1/p' "${source_root}/dependencies.list")" - find . -name 'realm-*-1*' -maxdepth 1 \ - | sed 's@./realm-[a-z]*-\(.*\)@\1@' \ + find . -name 'build-*-1*' -maxdepth 1 \ + | sed 's@./build-[a-z]*-\(.*\)-.*@\1@' \ | sort -u --version-sort \ | xargs ./scripts/create-release-package.rb "${ROOT_WORKSPACE}/pkg" "${version}" ;; @@ -1159,90 +1063,6 @@ case "$COMMAND" in # Release tests ###################################### - # Should select xcode version `xcode-select` first. - # Pass xcode version as argument - # This simulates what is done in XCode Cloud - "test-create-frameworks") - xcode_version="$2" - targets="Realm RealmSwift" - - platforms=("ios" "iossimulator" "osx" "tvos" "tvossimulator" "watchos" "watchossimulator" "catalyst") - if [ "$xcode_version" == "15.2" ]; then - platforms+=("visionos" "visionossimulator") - fi - - for platform in "${platforms[@]}"; do - for target in $targets; do - echo "Building $platform and $target release" - ./build.sh "release-package-$platform-$xcode_version-$target-release" - ./build.sh "release-build_$platform-$xcode_version-$target-release" - - # Only generates Realm framework for Static configuration and ios platform - if [[ "$platform" == "ios" || "$platform" == "iossimulator" ]] && [[ "$target" == "Realm" ]]; then - echo "Building $platform and $target static" - ./build.sh "release-package-$platform-$xcode_version-$target-static" - ./build.sh "release-package-build_$platform-$xcode_version-$target-static" - fi - done - done - ;; - - "test-build-product-workflow-xcode-cloud") - issuer_id="" - key_id="" - pk_path="" - - token=$(ruby ./scripts/xcode_cloud_helper.rb --issuer-id $issuer_id --key-id $key_id --pk-path $pk_path get-token) - echo "Authentication token -> $token" - - # Test parameters - platform="ios" - target="RealmSwift" - xcode_version="15.2" - configuration="release" - - workflow_id=$(ruby ./scripts/xcode_cloud_helper.rb create-workflow release-package-build $platform $xcode_version $target $configuration -t $token) - echo "Created workflow -> $workflow_id" - build_run_id=$(ruby ./scripts/xcode_cloud_helper.rb build-workflow $workflow_id dp/new_migration_branch -t $token) - echo "Build Run -> $build_run_id" - while [ "$status" != 'COMPLETE' ] - do - token=$(ruby ./scripts/xcode_cloud_helper.rb --issuer-id $issuer_id --key-id $key_id --pk-path $pk_path get-token) - status=$(ruby ./scripts/xcode_cloud_helper.rb get-build-status $build_run_id -t $token) - echo "Status $status" | ts - sleep 20 - done - completion_status=$(ruby ./scripts/xcode_cloud_helper.rb get-build-result $build_run_id -t $token) - echo "Completion Status $completion_status" | ts - if [ "$completion_status" != 'SUCCEEDED' ]; then - echo "XCode build failed" - ruby ./scripts/xcode_cloud_helper.rb print-build-logs $build_run_id -t $token - exit 1 - fi - - ruby ./scripts/xcode_cloud_helper.rb print-build-logs $build_run_id -t $token - ruby ./scripts/xcode_cloud_helper.rb download-artifact $build_run_id -t $token - ruby ./scripts/xcode_cloud_helper.rb delete-workflow $workflow_id -t $token - ;; - - # Pass xcode version as argument - # For this to work, product builds should be located in the root of the project - "test-create-platform-xcframeworks") - xcode_version="$2" - - platforms=("ios" "osx" "tvos" "watchos" "catalyst") - if [ "$xcode_version" == "15.1" ]; then - platforms+=("visionos") - fi - - for platform in "${platforms[@]}"; do - ./build.sh release-create-xcframework_$xcode_version $platform - - rm -rf "$ROOT_WORKSPACE/Release" - rm -rf "$ROOT_WORKSPACE/Static" - done - ;; - "test-package-examples") VERSION="$(sed -n 's/^VERSION=\(.*\)$/\1/p' "${source_root}/dependencies.list")" dir="realm-swift-${VERSION}" @@ -1268,22 +1088,6 @@ case "$COMMAND" in sh build.sh examples-tvos-swift ;; - # This is used for test or if we want to use Github Actions to build each framework - release-package-build_*) - filename="Configuration/Release.xcconfig" - sed -i '' "s/REALM_HIDE_SYMBOLS = NO;/REALM_HIDE_SYMBOLS = YES;/" "$filename" - - # Remove the identifier of the command, so we can obtain the parameters from the command - build_command=${COMMAND#"release-package-build_"} - parameters=(${build_command//-/ }) - - platform=${parameters[0]} - target=${parameters[1]} - - build_platform "$target" "$platform" - exit 0 - ;; - ###################################### # Publish ###################################### @@ -1363,7 +1167,7 @@ x.y.z Release notes (yyyy-MM-dd) ### Compatibility * Realm Studio: 15.0.0 or later. * APIs are backwards compatible with all previous releases in the 10.x.y series. -* Carthage release for Swift is built with Xcode 15.4.0. +* Carthage release for Swift is built with Xcode 16.0.0. * CocoaPods: 1.10 or later. * Xcode: 15.3.0-16.1 beta. diff --git a/scripts/create-release-package.rb b/scripts/create-release-package.rb index 57307c2a70..9be3dd86ee 100755 --- a/scripts/create-release-package.rb +++ b/scripts/create-release-package.rb @@ -12,7 +12,7 @@ ROOT = Pathname(__FILE__).+('../..').expand_path BUILD_SH = Pathname(__FILE__).+('../../build.sh').expand_path VERBOSE = false -OBJC_XCODE_VERSION = XCODE_VERSIONS.last +OBJC_XCODE_VERSION = XCODE_VERSIONS.reduce { |a, e| e.include?('beta') ? a : e } def sh(*args) puts "executing: #{args.join(' ')}" if VERBOSE @@ -31,7 +31,7 @@ def create_xcframework(root, xcode_version, configuration, name) signing_identity = ENV['SIGNING_IDENTITY'] prefix = "#{root}/#{xcode_version}" output = "#{prefix}/#{configuration}/#{name}.xcframework" - files = Dir.glob "#{prefix}/#{configuration}/*/#{name}.xcframework/*/#{name}.framework" + files = Dir.glob "#{prefix}/build/#{configuration}/*/#{name}.xcframework/*/#{name}.framework" sh 'xcodebuild', '-create-xcframework', '-allow-internal-distribution', '-output', output, *files.flat_map {|f| ['-framework', f]} @@ -58,8 +58,9 @@ def zip(name, *files) FileUtils.mkdir_p "#{tmp}/#{version}" Dir.chdir("#{tmp}/#{version}") do for platform in platforms(version) - sh 'unzip', "#{ROOT}/realm-#{platform}-#{version}/realm-#{platform}-#{version}.zip" + sh 'tar', 'xf', "#{ROOT}/build-#{platform}-#{version}-swift/build.tar" end + sh 'tar', 'xf', "#{ROOT}/build-ios-#{version}-static/build.tar" end end @@ -117,7 +118,7 @@ def zip(name, *files) tmp = File.realpath tmp Dir.chdir(tmp) do for platform in platforms('15.1') - sh 'unzip', "#{ROOT}/realm-#{platform}-#{OBJC_XCODE_VERSION}/realm-#{platform}-#{OBJC_XCODE_VERSION}.zip" + sh 'tar', 'xf', "#{ROOT}/build-#{platform}-#{OBJC_XCODE_VERSION}-swift/build.tar" end create_xcframework tmp, '', 'Release', 'RealmSwift' create_xcframework tmp, '', 'Release', 'Realm'