name: CI # Controls when the workflow will run on: push: branches: [main] paths: - "td" # on TDLib updates - ".github/workflows/**" # on CI updates pull_request: branches: [main] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: env: TDLIB_REPO: https://github.com/tdlib/td ARTIFACT_NAME: TDLibFramework.zip ARTIFACT_DIR: ./builder/build DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer jobs: build: if: ${{ github.actor != 'dependabot[bot]' }} strategy: fail-fast: false matrix: platform: [iOS, iOS-simulator, macOS, watchOS, watchOS-simulator, tvOS, tvOS-simulator, visionOS, visionOS-simulator] uses: ./.github/workflows/build.yml with: platform: ${{ matrix.platform }} developer-dir: "/Applications/Xcode_15.2.app/Contents/Developer" # Merge frameworks merge-xcframework: if: ${{ github.actor != 'dependabot[bot]' }} runs-on: macos-14 needs: [build] steps: - name: Checkout uses: actions/checkout@v4 - name: Download iOS Framework uses: actions/download-artifact@v4 with: name: xcarchive-iOS path: ./builder/build/iOS.xcarchive - name: Download iOS-simulator Framework uses: actions/download-artifact@v4 with: name: xcarchive-iOS-simulator path: ./builder/build/iOS-simulator.xcarchive - name: Download macOS Framework uses: actions/download-artifact@v4 with: name: xcarchive-macOS path: ./builder/build/macOS.xcarchive - name: Download watchOS Framework uses: actions/download-artifact@v4 with: name: xcarchive-watchOS path: ./builder/build/watchOS.xcarchive - name: Download watchOS-simulator Framework uses: actions/download-artifact@v4 with: name: xcarchive-watchOS-simulator path: ./builder/build/watchOS-simulator.xcarchive - name: Download tvOS Framework uses: actions/download-artifact@v4 with: name: xcarchive-tvOS path: ./builder/build/tvOS.xcarchive - name: Download tvOS-simulator Framework uses: actions/download-artifact@v4 with: name: xcarchive-tvOS-simulator path: ./builder/build/tvOS-simulator.xcarchive - name: Download visionOS Framework uses: actions/download-artifact@v4 with: name: xcarchive-visionOS path: ./builder/build/visionOS.xcarchive - name: Download visionOS-simulator Framework uses: actions/download-artifact@v4 with: name: xcarchive-visionOS-simulator path: ./builder/build/visionOS-simulator.xcarchive - name: Merge Frameworks working-directory: ./builder run: ./merge-frameworks.sh "iOS iOS-simulator macOS watchOS watchOS-simulator tvOS tvOS-simulator visionOS visionOS-simulator" - name: Archive XCFramework working-directory: ./builder/build run: zip --symlinks -r TDLibFramework.zip TDLibFramework.xcframework - name: Upload Artifacts uses: actions/upload-artifact@v4 with: name: TDLibFramework.zip path: ./builder/build/TDLibFramework.zip if-no-files-found: error # Tests tests: if: ${{ github.actor != 'dependabot[bot]' }} runs-on: macos-14 needs: [merge-xcframework] strategy: matrix: include: # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#installed-sdks # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#installed-simulators - platform: "macOS" - platform: "iOS-simulator" os_list: "17.0.1" device_name: "iPhone 14" - platform: "tvOS-simulator" os_list: "17.0" device_name: "Apple TV 4K (3rd generation) (at 1080p)" - platform: "watchOS-simulator" os_list: "9.4" device_name: "Apple Watch Series 8 (45mm)" - platform: "visionOS-simulator" os_list: "1.0" device_name: "Apple Vision Pro" steps: - name: Checkout uses: actions/checkout@v4 - name: Download XCFramework uses: actions/download-artifact@v4 with: name: TDLibFramework.zip path: ${{ env.ARTIFACT_DIR }} - name: Unpack framework working-directory: ${{ env.ARTIFACT_DIR }} run: unzip ${{ env.ARTIFACT_NAME }} - name: Update Package.swift with local .xcframework run: python3 scripts/swift_package_generator.py --path ${{ env.ARTIFACT_DIR }}/TDLibFramework.xcframework - name: Run Tests for ${{ matrix.platform }} run: ./scripts/test.sh ${{ matrix.platform }} "${{ matrix.os_list }}" "${{ matrix.device_name }}" || ./scripts/test.sh ${{ matrix.platform }} "${{ matrix.os_list }}" "${{ matrix.device_name }}" create-release: if: ${{ github.actor != 'dependabot[bot]' }} runs-on: macos-14 needs: [tests] steps: - name: Checkout uses: actions/checkout@v4 with: submodules: recursive - name: Set Envs run: | ARTIFACT_PATH="./builder/build/${{ env.ARTIFACT_NAME }}" echo "ARTIFACT_PATH=$ARTIFACT_PATH" >> $GITHUB_ENV RELEASES_DOWNLOAD_URL=https://github.com/$GITHUB_REPOSITORY/releases/download echo "RELEASES_DOWNLOAD_URL=$RELEASES_DOWNLOAD_URL" >> $GITHUB_ENV TDLIB_COMMIT=$(cd td && git rev-parse --short=8 HEAD) echo "TDLIB_COMMIT=$TDLIB_COMMIT" >> $GITHUB_ENV TDLIB_VERSION=$(python3 scripts/extract_td_version.py td/CMakeLists.txt) echo "TDLIB_VERSION=$TDLIB_VERSION" >> $GITHUB_ENV TDLIB_COMMIT_URL=${{ env.TDLIB_REPO }}/tree/$TDLIB_COMMIT echo "TDLIB_COMMIT_URL=$TDLIB_COMMIT_URL" >> $GITHUB_ENV RELEASE_TAG=$TDLIB_VERSION-$TDLIB_COMMIT echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV - name: Download XCFramework uses: actions/download-artifact@v4 with: name: TDLibFramework.zip path: ${{ env.ARTIFACT_DIR }} - name: Get Checksum run: | ARTIFACT_CHECKSUM=$(swift package compute-checksum ${{ env.ARTIFACT_PATH }}) echo "ARTIFACT_CHECKSUM=$ARTIFACT_CHECKSUM" >> $GITHUB_ENV - name: Update Package.swift if: github.ref == 'refs/heads/main' run: | python3 scripts/swift_package_generator.py --url "${{ env.RELEASES_DOWNLOAD_URL }}/${{ env.RELEASE_TAG }}/${{ env.ARTIFACT_NAME }}" --checksum ${{ env.ARTIFACT_CHECKSUM }} git add Package.swift || true git commit -m "[no ci] Bump TDLib ${{ env.RELEASE_TAG }}" || true git push origin main || true - name: Remove previous release if: github.ref == 'refs/heads/main' run: gh release delete ${{ env.RELEASE_TAG }} --cleanup-tag || true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Release if: github.ref == 'refs/heads/main' run: | echo -e "XCFramework based on TDLib-${{ env.TDLIB_VERSION }} commit [${{ env.TDLIB_COMMIT }}](${{ env.TDLIB_COMMIT_URL }})\n\nZIP Checksum \`${{ env.ARTIFACT_CHECKSUM }}\`" > release.md gh release create ${{ env.RELEASE_TAG }} ${{ env.ARTIFACT_PATH }} --target main --notes-file release.md rm release.md env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}