-
Notifications
You must be signed in to change notification settings - Fork 0
289 lines (241 loc) · 8.6 KB
/
td-builder-tdlib-win.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
name: tdbuilder for tdlib for windows
on:
schedule:
- cron: '0 2 * * 5'
workflow_dispatch:
jobs:
prepare:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Setup Container
run: |
echo "${{ secrets.TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker pull ghcr.io/${{ github.actor }}/vstools:latest
docker save ghcr.io/${{ github.actor }}/vstools:latest -o vstools.tar
shell: pwsh
- name: Upload Image Artifact
uses: actions/[email protected]
with:
name: vstools-image
path: vstools.tar
build_release_x64:
runs-on: windows-latest
needs: [prepare]
steps:
- name: Download Image Artifact
uses: actions/[email protected]
with:
name: vstools-image
- name: Load Docker Image
run: |
docker load -i vstools.tar
shell: pwsh
- name: Build release x64
run: |
docker run --rm -v "${{ github.workspace }}:C:\app\td\tdlib\" ghcr.io/${{ github.actor }}/vstools:latest powershell.exe -c "
cd /app/td;
git fetch;
git pull;
Remove-Item -LiteralPath "build-release-x64" -Force -Recurse -ErrorAction SilentlyContinue;
New-Item -ItemType Directory -Path "build-release-x64";
cd build-release-x64;
cmake -A x64 -DCMAKE_INSTALL_PREFIX:PATH=../tdlib/x64/Release -DTD_ENABLE_DOTNET=ON -DCMAKE_TOOLCHAIN_FILE:FILEPATH=../vcpkg/scripts/buildsystems/vcpkg.cmake ..;
cmake --build . --target install --config Release;
"
shell: pwsh
- name: List folder
run: dir "${{ github.workspace }}"
shell: cmd
- name: Publish the release x64 build
uses: actions/[email protected]
with:
name: build-release-x64
path: ${{ github.workspace }}/x64/Release
build_debug_x64:
runs-on: windows-latest
needs: [prepare]
steps:
- name: Download Image Artifact
uses: actions/[email protected]
with:
name: vstools-image
- name: Load Docker Image
run: |
docker load -i vstools.tar
shell: pwsh
- name: Build debug x64
run: |
docker run --rm -v "${{ github.workspace }}:C:\app\td\tdlib\" ghcr.io/${{ github.actor }}/vstools:latest powershell.exe -c "
cd /app/td;
git fetch;
git pull;
Remove-Item -LiteralPath "build-debug-x64" -Force -Recurse -ErrorAction SilentlyContinue;
New-Item -ItemType Directory -Path "build-debug-x64";
cd build-debug-x64;
cmake -A x64 -DCMAKE_INSTALL_PREFIX:PATH=../tdlib/x64/Debug -DTD_ENABLE_DOTNET=ON -DCMAKE_TOOLCHAIN_FILE:FILEPATH=../vcpkg/scripts/buildsystems/vcpkg.cmake ..;
cmake --build . --target install --config Debug;
"
shell: pwsh
- name: List folder
run: dir "${{ github.workspace }}"
shell: cmd
- name: Publish the debug x64 build
uses: actions/[email protected]
with:
name: build-debug-x64
path: ${{ github.workspace }}/x64/Debug
build_release_x86:
runs-on: windows-latest
needs: [prepare]
steps:
- name: Download Image Artifact
uses: actions/[email protected]
with:
name: vstools-image
- name: Load Docker Image
run: |
docker load -i vstools.tar
shell: pwsh
- name: Build release x86
run: |
docker run --rm -v "${{ github.workspace }}:C:\app\td\tdlib\" ghcr.io/${{ github.actor }}/vstools:latest powershell.exe -c "
cd /app/td;
git fetch;
git pull;
Remove-Item -LiteralPath "build-release-x86" -Force -Recurse -ErrorAction SilentlyContinue;
New-Item -ItemType Directory -Path "build-release-x86";
cd build-release-x86;
cmake -A Win32 -DCMAKE_INSTALL_PREFIX:PATH=../tdlib/Win32/Release -DTD_ENABLE_DOTNET=ON -DCMAKE_TOOLCHAIN_FILE:FILEPATH=../vcpkg/scripts/buildsystems/vcpkg.cmake ..;
cmake --build . --target install --config Release;
"
shell: pwsh
- name: List folder
run: dir "${{ github.workspace }}"
shell: cmd
- name: Publish the release x86 build
uses: actions/[email protected]
with:
name: build-release-x86
path: ${{ github.workspace }}/Win32/Release
build_debug_x86:
runs-on: windows-latest
needs: [prepare]
steps:
- name: Download Image Artifact
uses: actions/[email protected]
with:
name: vstools-image
- name: Load Docker Image
run: |
docker load -i vstools.tar
shell: pwsh
- name: Build debug x86
run: |
docker run --rm -v "${{ github.workspace }}:C:\app\td\tdlib\" ghcr.io/${{ github.actor }}/vstools:latest powershell.exe -c "
cd /app/td;
git fetch;
git pull;
Remove-Item -LiteralPath "build-debug-x86" -Force -Recurse -ErrorAction SilentlyContinue;
New-Item -ItemType Directory -Path "build-debug-x86";
cd build-debug-x86;
cmake -A Win32 -DCMAKE_INSTALL_PREFIX:PATH=../tdlib/Win32/Debug -DTD_ENABLE_DOTNET=ON -DCMAKE_TOOLCHAIN_FILE:FILEPATH=../vcpkg/scripts/buildsystems/vcpkg.cmake ..;
cmake --build . --target install --config Debug;
"
shell: pwsh
- name: List folder
run: dir "${{ github.workspace }}"
shell: cmd
- name: Publish the debug x86 build
uses: actions/[email protected]
with:
name: build-debug-x86
path: ${{ github.workspace }}/Win32/Debug
final_step:
runs-on: windows-latest
needs: [build_release_x64, build_debug_x64, build_release_x86, build_debug_x86]
steps:
- name: Download release x64
uses: actions/[email protected]
with:
name: build-release-x64
path: ${{ github.workspace }}/tdlib/x64/Release
- name: Download debug x64
uses: actions/[email protected]
with:
name: build-debug-x64
path: ${{ github.workspace }}/tdlib/x64/Debug
- name: Download release x86
uses: actions/[email protected]
with:
name: build-release-x86
path: ${{ github.workspace }}/tdlib/x86/Release
- name: Download debug x86
uses: actions/[email protected]
with:
name: build-debug-x86
path: ${{ github.workspace }}/tdlib/x86/Debug
- name: Create folders and copy files from artifact
run: |
ls ${{ github.workspace }}
shell: pwsh
- name: Create docker
run: |
$dockerfileContent = @"
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
WORKDIR /app
COPY ./tdlib ./tdlib
"@
$dockerfilePath = "${{ github.workspace }}/Dockerfile"
$dockerfileContent | Out-File -FilePath $dockerfilePath
docker build -t ghcr.io/${{ github.actor }}/tdlib-win:latest .
echo "${{ secrets.TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker push ghcr.io/${{ github.actor }}/tdlib-win:latest
shell: pwsh
clean_artifacts:
runs-on: windows-latest
needs: [final_step]
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Wait for Artifacts
shell: pwsh
run: Start-Sleep -Seconds 10
- name: Clear all artifacts
run: |
for ($i = 1; $i -le 5; i++){
$ARTIFACTS = gh api repos/${{ github.repository }}/actions/artifacts | ConvertFrom-Json;
if ($ARTIFACTS.Count -gt 0) {
break
}
Write-Host "Artifacts not found, retrying ($i/5)..."
Start-Sleep -Seconds 5
}
if ($ARTIFACTS.Count -eq 0){
Write-Host "No Artifacts found."
exit 0
}
$ARTIFACTS = gh api repos/${{ github.repository }}/actions/artifacts | ConvertFrom-Json;
foreach ($ARTIFACT in $ARTIFACTS.artifacts) {
gh api -X DELETE repos/${{ github.repository }}/actions/artifacts/$($ARTIFACT.id)
Write-Host "Delete artifact: $($ARTIFACT.name) (ID: $($ARTIFACT.id))"
}
shell: pwsh
env:
GH_TOKEN: ${{ secrets.TOKEN }}
- name: Commit code
shell: bash
run: |
git fetch
git pull
echo "$(date -u)" >> tdlib-win.log
git config --global user.name "Kishan"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add tdlib-win.log
git commit -m "Update tdlib-win.log" || echo "no change to commit"
git push origin HEAD
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}