-
Notifications
You must be signed in to change notification settings - Fork 14
208 lines (170 loc) · 7.03 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
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
- uses: ./.github/actions/download-and-unpack-xcarchive
with:
platform: iOS
- uses: ./.github/actions/download-and-unpack-xcarchive
with:
platform: iOS-simulator
- uses: ./.github/actions/download-and-unpack-xcarchive
with:
platform: macOS
- uses: ./.github/actions/download-and-unpack-xcarchive
with:
platform: watchOS
- uses: ./.github/actions/download-and-unpack-xcarchive
with:
platform: watchOS-simulator
- uses: ./.github/actions/download-and-unpack-xcarchive
with:
platform: tvOS
- uses: ./.github/actions/download-and-unpack-xcarchive
with:
platform: tvOS-simulator
- uses: ./.github/actions/download-and-unpack-xcarchive
with:
platform: visionOS
- uses: ./.github/actions/download-and-unpack-xcarchive
with:
platform: visionOS-simulator
- 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.2"
device_name: "iPhone 15"
- platform: "tvOS-simulator"
os_list: "17.2"
device_name: "Apple TV 4K (3rd generation) (at 1080p)"
- platform: "watchOS-simulator"
os_list: "10.2"
device_name: "Apple Watch Series 9 (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 }}
# https://github.com/actions/runner-images/issues/10692
- uses: ./.github/actions/install-visionos-runtime
if: ${{ matrix.platform == 'visionOS' || matrix.platform == 'visionOS-simulator' }}
with:
developer_dir: ${{ env.DEVELOPER_DIR }}
- 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 }}