Skip to content

CI

CI #1381

Workflow file for this run

name: CI
# Controls when the workflow will run
on:
push:
branches: [main]
paths:
- "version" # on version updates
- "Package.swift"
- "Package.resolved"
- "Tests/**"
- .github/workflows/ci.yml
- "scripts/**"
pull_request:
branches: [main]
schedule:
- cron: '0 */12 * * *' # Every 12 hours
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
TDLIB_REPO: https://github.com/tdlib/td
DEVELOPER_DIR: /Applications/Xcode_14.2.app/Contents/Developer
jobs:
Build:
runs-on: macos-12
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get latest Github release
if: github.ref == 'refs/heads/main'
id: framework_releases
uses: joutvhu/[email protected]
with:
owner: Swiftgram
repo: TDLibFramework
latest: true
throwing: true
env:
GITHUB_TOKEN: ${{ secrets.GH_RELEASES_TOKEN }}
- name: Set TDLibFramework version
if: github.ref == 'refs/heads/main'
run: python3 scripts/swift_package_generator.py "${{ steps.framework_releases.outputs.tag_name }}"
- name: Resolve Deps
run: swift package update
- name: Get commit & version
run: |
TDLIB_COMMIT=$(python3 scripts/parse_tdlib_version.py commit)
TDLIB_VERSION=$(python3 scripts/parse_tdlib_version.py version)
PACKAGE_VERSION=$(cat version | python3 -c "print(input().strip())")
RELEASE_TAG=${PACKAGE_VERSION}-tdlib-${TDLIB_VERSION}-${TDLIB_COMMIT}
TDLIB_COMMIT_URL=${{ env.TDLIB_REPO }}/tree/${TDLIB_COMMIT}
echo "TDLIB_COMMIT=$TDLIB_COMMIT" >> $GITHUB_ENV
echo "TDLIB_VERSION=$TDLIB_VERSION" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
echo "TDLIB_COMMIT_URL=$TDLIB_COMMIT_URL" >> $GITHUB_ENV
- name: Download td_api.tl
run: wget https://raw.githubusercontent.com/tdlib/td/$TDLIB_COMMIT/td/generate/scheme/td_api.tl
- name: Run Generator
working-directory: scripts/tl2swift
run: rm -rf ../../Sources/TDLibKit/Generated && swift run tl2swift ../../td_api.tl ../../Sources/TDLibKit/Generated $TDLIB_VERSION $TDLIB_COMMIT
- name: Commit Files
if: github.ref == 'refs/heads/main'
run: |
git add . || true
git commit -m "[no ci] Version ${{ env.RELEASE_TAG }}" || true
- name: Tests (iOS)
run: ./scripts/test.sh iOS-simulator "16.2" "iPhone 14"
- name: Tests (tvOS) # Dirty hack to retry step. tvOS sim can stuck for some reason
run: ./scripts/test.sh tvOS-simulator "16.1" "Apple TV 4K (3rd generation) (at 1080p)" || ./scripts/test.sh tvOS-simulator "16.1" "Apple TV 4K (3rd generation) (at 1080p)"
- name: Tests (macOS)
run: ./scripts/test.sh macOS
- name: Tests (watchOS)
run: ./scripts/test.sh watchOS-simulator "9.1" "Apple Watch Series 8 (45mm)" || ./scripts/test.sh watchOS-simulator "9.1" "Apple Watch Series 8 (45mm)"
- name: Push update
if: github.ref == 'refs/heads/main'
run: git push origin main || true
- name: Clean local files
if: github.ref != 'refs/heads/main'
run: |
git clean -nfdx
git clean -fdx
rm -rf .git
rm -rf .github
rm -rf .build
- name: Upload artifact
if: github.ref != 'refs/heads/main'
uses: actions/upload-artifact@v3
with:
name: TDLibKit-${{ github.sha }}
path: .
- name: Remove previous release
if: github.ref == 'refs/heads/main'
uses: dev-drprasad/delete-tag-and-release@7550ea180f81ca0a875ee3c135b1f72ef66ff4b1
with:
delete_release: true
tag_name: ${{ env.RELEASE_TAG }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release
if: github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@c9b46fe7aad9f02afd89b12450b780f52dacfb2d
with:
target_commitish: main
tag_name: ${{ env.RELEASE_TAG }}
files: ${{ env.ARTIFACT_PATH }}
body: "TDLibKit based on TDLib-${{ env.TDLIB_VERSION }} commit [${{ env.TDLIB_COMMIT }}](${{ env.TDLIB_COMMIT_URL }})"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}