-
Notifications
You must be signed in to change notification settings - Fork 23
133 lines (111 loc) · 4.42 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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)"
- 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 }}