diff --git a/.github/workflows/testflight-build.yml b/.github/workflows/testflight-build.yml index 898cd17c..71d57c16 100644 --- a/.github/workflows/testflight-build.yml +++ b/.github/workflows/testflight-build.yml @@ -62,6 +62,22 @@ jobs: with: xcode-version: latest-stable + - name: Resolve Xcode cache key + id: xcode-cache + if: ${{ !inputs.dry_run }} + shell: bash + run: | + set -euo pipefail + xcode_key="$(xcodebuild -version | tr '\n' '-' | sed -E 's/[^A-Za-z0-9._-]+/-/g; s/-$//')" + echo "version=$xcode_key" >> "$GITHUB_OUTPUT" + + - name: Restore Swift package cache + if: ${{ !inputs.dry_run }} + uses: actions/cache/restore@v4 + with: + path: ${{ vars.IOS_WORKDIR || 'ios' }}/SourcePackages + key: spm-${{ runner.os }}-${{ runner.arch }}-${{ steps.xcode-cache.outputs.version }}-${{ hashFiles('ios/epac.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved') }} + - name: Set up Ruby and Bundler if: ${{ !inputs.dry_run }} uses: ruby/setup-ruby@v1 @@ -159,6 +175,7 @@ jobs: NEW_VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.version_override || steps.version.outputs.next_version }} KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }} + SPM_CLONED_SOURCE_PACKAGES_PATH: SourcePackages run: | bundle exec fastlane deploy \ scheme:${{ vars.SCHEME }} \ diff --git a/.github/workflows/warm-spm-cache.yml b/.github/workflows/warm-spm-cache.yml new file mode 100644 index 00000000..009ef599 --- /dev/null +++ b/.github/workflows/warm-spm-cache.yml @@ -0,0 +1,71 @@ +name: Warm Swift Package Cache + +on: + workflow_dispatch: + push: + branches: [main] + paths: + - 'ios/epac.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved' + - '.github/workflows/warm-spm-cache.yml' + +permissions: + contents: read + +concurrency: + group: warm-spm-cache + cancel-in-progress: true + +jobs: + warm: + name: Warm Swift package cache + runs-on: macos-15 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Select Xcode + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + + - name: Resolve Xcode cache key + id: xcode-cache + shell: bash + run: | + set -euo pipefail + xcode_key="$(xcodebuild -version | tr '\n' '-' | sed -E 's/[^A-Za-z0-9._-]+/-/g; s/-$//')" + echo "version=$xcode_key" >> "$GITHUB_OUTPUT" + + - name: Restore Swift package cache + id: spm-cache + uses: actions/cache/restore@v4 + with: + path: ios/SourcePackages + key: spm-${{ runner.os }}-${{ runner.arch }}-${{ steps.xcode-cache.outputs.version }}-${{ hashFiles('ios/epac.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved') }} + + - name: Resolve Swift packages + if: ${{ steps.spm-cache.outputs.cache-hit != 'true' }} + run: | + xcodebuild -resolvePackageDependencies \ + -project ios/epac.xcodeproj \ + -scheme epac \ + -configuration Release \ + -clonedSourcePackagesDirPath ios/SourcePackages + + - name: Save Swift package cache + if: ${{ steps.spm-cache.outputs.cache-hit != 'true' }} + uses: actions/cache/save@v4 + with: + path: ios/SourcePackages + key: spm-${{ runner.os }}-${{ runner.arch }}-${{ steps.xcode-cache.outputs.version }}-${{ hashFiles('ios/epac.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved') }} + + - name: Summary + run: | + { + echo "## Swift package cache" + echo "" + echo "- Xcode key: ${{ steps.xcode-cache.outputs.version }}" + echo "- Cache hit: ${{ steps.spm-cache.outputs.cache-hit || 'false' }}" + echo "- Path: ios/SourcePackages" + } >> "$GITHUB_STEP_SUMMARY" diff --git a/ios/fastlane/Fastfile b/ios/fastlane/Fastfile index d0a2d432..87d2fbaf 100644 --- a/ios/fastlane/Fastfile +++ b/ios/fastlane/Fastfile @@ -148,6 +148,7 @@ platform :ios do configuration: "Release", export_method: "app-store", xcargs: extra_xcargs, + cloned_source_packages_path: ENV["SPM_CLONED_SOURCE_PACKAGES_PATH"], output_directory: "build", output_name: "epac.ipa", clean: false