-
Notifications
You must be signed in to change notification settings - Fork 0
476 lines (416 loc) · 18.1 KB
/
update_files.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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
name: Update files
on:
pull_request:
types:
- closed
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
update_files:
if: github.event.pull_request.merged == true
name: Update files job
runs-on: [ self-hosted, macOS ]
outputs:
version: ${{ steps.read_version.outputs.VERSION }}
steps:
- uses: actions/checkout@v4
- name: Set up Node.js 18
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Switch to SSH
run: git remote set-url origin [email protected]:landamessenger/zstandard.git
- name: Install Landa Messenger CLI
run: npm install @landamessenger/landa-messenger-api -g
- name: Read version from pubspec.yml
working-directory: zstandard_platform_interface
id: read_version
run: |
VERSION=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Pre check tag
id: pre_check_tag
run: |
# Checks if the tag already exists in the remote repository
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then
echo "Error: Tag v${{ env.VERSION }} already exists."
exit 1
fi
# Check if the version was found
if [ -z "${{ env.VERSION }}" ]; then
echo "Error: No version found in pubspec.yml"
exit 1
fi
- name: Copy CHANGELOG.md
run: |
cp CHANGELOG.md "zstandard_platform_interface/CHANGELOG.md"
cp CHANGELOG.md "zstandard_android/CHANGELOG.md"
cp CHANGELOG.md "zstandard_ios/CHANGELOG.md"
cp CHANGELOG.md "zstandard_macos/CHANGELOG.md"
cp CHANGELOG.md "zstandard_windows/CHANGELOG.md"
cp CHANGELOG.md "zstandard_linux/CHANGELOG.md"
cp CHANGELOG.md "zstandard_web/CHANGELOG.md"
cp CHANGELOG.md "zstandard_cli/CHANGELOG.md"
cp CHANGELOG.md "zstandard/CHANGELOG.md"
- name: Update version in zstandard_android pubspec.yaml
working-directory: zstandard_android
run: |
sed -i '' "s/^version:.*/version: ${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_platform_interface: .*/ zstandard_platform_interface: ^${{ env.VERSION }}/" pubspec.yaml
- name: Update version in zstandard_ios pubspec.yaml
working-directory: zstandard_ios
run: |
sed -i '' "s/^version:.*/version: ${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_platform_interface: .*/ zstandard_platform_interface: ^${{ env.VERSION }}/" pubspec.yaml
- name: Update version in zstandard_macos pubspec.yaml
working-directory: zstandard_macos
run: |
sed -i '' "s/^version:.*/version: ${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_platform_interface: .*/ zstandard_platform_interface: ^${{ env.VERSION }}/" pubspec.yaml
- name: Update version in zstandard_linux pubspec.yaml
working-directory: zstandard_linux
run: |
sed -i '' "s/^version:.*/version: ${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_platform_interface: .*/ zstandard_platform_interface: ^${{ env.VERSION }}/" pubspec.yaml
- name: Update version in zstandard_windows pubspec.yaml
working-directory: zstandard_windows
run: |
sed -i '' "s/^version:.*/version: ${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_platform_interface: .*/ zstandard_platform_interface: ^${{ env.VERSION }}/" pubspec.yaml
- name: Update version in zstandard_web pubspec.yaml
working-directory: zstandard_web
run: |
sed -i '' "s/^version:.*/version: ${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_platform_interface: .*/ zstandard_platform_interface: ^${{ env.VERSION }}/" pubspec.yaml
- name: Update version in zstandard pubspec.yaml
working-directory: zstandard
run: |
sed -i '' "s/^version:.*/version: ${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_platform_interface: .*/ zstandard_platform_interface: ^${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_android: .*/ zstandard_android: ^${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_ios: .*/ zstandard_ios: ^${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_web: .*/ zstandard_web: ^${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_macos: .*/ zstandard_macos: ^${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_windows: .*/ zstandard_windows: ^${{ env.VERSION }}/" pubspec.yaml
sed -i '' "s/^ zstandard_linux: .*/ zstandard_linux: ^${{ env.VERSION }}/" pubspec.yaml
- name: Update version in zstandard_cli pubspec.yaml
working-directory: zstandard_cli
run: |
sed -i '' "s/^version:.*/version: ${{ env.VERSION }}/" pubspec.yaml
- name: Git pull --no-ff
run: |
git pull --no-ff origin master
- name: Commit and Push version updates
uses: EndBug/add-and-commit@v9
with:
add: '.'
committer_name: GitHub Actions
committer_email: [email protected]
default_author: user_info
message: 'gh-action: Bump dependencies version to ${{ env.VERSION }}'
- name: Handle job completion
if: always()
run: |
if [ "${{ job.status }}" == "failure" ]; then
landa-messenger-api chat-send \
--id "${{ secrets.CHAT_ID }}" \
--api_key "${{ secrets.CHAT_KEY }}" \
--title "🔴 Update files Failed" \
--body "${{ github.repository }}: Tag v${{ env.VERSION }}" \
--url "https://github.com/landamessenger/object/actions/workflows/update_files.yml" \
--image "https://avatars.githubusercontent.com/u/63705403?s=200&v=4" \
--background_color "#55000000" \
--text_color "#FFFFFFFF"
elif [ "${{ job.status }}" == "cancelled" ]; then
landa-messenger-api chat-send \
--id "${{ secrets.CHAT_ID }}" \
--api_key "${{ secrets.CHAT_KEY }}" \
--title "🟠 Update files Canceled" \
--body "${{ github.repository }}: Tag v${{ env.VERSION }}" \
--url "https://github.com/landamessenger/object/actions/workflows/update_files.yml" \
--image "https://avatars.githubusercontent.com/u/63705403?s=200&v=4" \
--background_color "#55000000" \
--text_color "#FFFFFFFF"
else
landa-messenger-api chat-send \
--id "${{ secrets.CHAT_ID }}" \
--api_key "${{ secrets.CHAT_KEY }}" \
--title "🟢 Update files Passed" \
--body "${{ github.repository }}: Tag v${{ env.VERSION }}" \
--url "https://github.com/landamessenger/object/actions/workflows/update_files.yml" \
--image "https://avatars.githubusercontent.com/u/63705403?s=200&v=4" \
--background_color "#55000000" \
--text_color "#FFFFFFFF"
fi
cli_build_macos_precompiled_libs:
name: macOS precompiled libraries
runs-on: [ self-hosted, macOS ]
needs: [update_files]
steps:
- uses: actions/checkout@v4
- name: Set up Node.js 18
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Switch to SSH
run: git remote set-url origin [email protected]:landamessenger/zstandard.git
- name: Install Landa Messenger CLI
run: npm install @landamessenger/landa-messenger-api -g
- name: Read version from pubspec.yml
working-directory: zstandard_platform_interface
id: read_version
run: |
VERSION=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Download source files from facebook/zstd
run: |
cd zstandard_cli
git clone https://github.com/facebook/zstd.git
mkdir src
mv zstd/lib/* src/
rm -rf zstd/
- name: List files in zstd/lib to verify
run: cd zstandard_cli && ls -R src
- name: Compile x86-x64 macos lib
run: |
cd zstandard_cli/builders/macos_intel
mkdir build && cd build
cmake ..
cmake --build . --config Release
mv libzstandard_macos.dylib ../../../lib/src/bin/libzstandard_macos_intel.dylib
cd ..
rm -rf build
- name: Compile arm64 macos lib
run: |
cd zstandard_cli/builders/macos_arm
mkdir build && cd build
cmake -DCMAKE_OSX_ARCHITECTURES=arm64 ..
cmake --build . --config Release
mv libzstandard_macos.dylib ../../../lib/src/bin/libzstandard_macos_arm.dylib
cd ..
rm -rf build
- name: Join libs
run: |
cd zstandard_cli/lib/src/bin
lipo -create -output libzstandard_macos.dylib libzstandard_macos_intel.dylib libzstandard_macos_arm.dylib
rm libzstandard_macos_arm.dylib
rm libzstandard_macos_intel.dylib
- name: Verify libs
run: |
cd zstandard_cli/lib/src/bin
lipo -info libzstandard_macos.dylib
- name: Git pull --no-ff
run: |
git pull --no-ff origin master
- name: Commit and Push Library
uses: EndBug/add-and-commit@v9
with:
add: './zstandard_cli/lib/src/bin/libzstandard_macos.dylib'
committer_name: GitHub Actions
committer_email: [email protected]
default_author: user_info
message: 'gh-action: Add precompiled macOS libraries for x86_64 and arm64'
cli_build_linux_precompiled_libs:
name: Linux precompiled libraries
runs-on: [ self-hosted, Linux ]
needs: [ update_files ]
steps:
- uses: actions/checkout@v4
- name: Set up Node.js 18
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Switch to SSH
run: git remote set-url origin [email protected]:landamessenger/zstandard.git
- name: Install Landa Messenger CLI
run: npm install @landamessenger/landa-messenger-api -g
- name: Read version from pubspec.yml
working-directory: zstandard_platform_interface
id: read_version
run: |
VERSION=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Download source files from facebook/zstd
run: |
cd zstandard_cli
git clone https://github.com/facebook/zstd.git
mkdir src
mv zstd/lib/* src/
rm -rf zstd/
- name: List files in zstd/lib to verify
run: cd zstandard_cli && ls -R src
- name: Compile x86_64 Linux lib
run: |
cd zstandard_cli/builders/linux_x64
mkdir build && cd build
cmake ..
cmake --build . --config Release
mv libzstandard_linux.so ../../../lib/src/bin/libzstandard_linux_x64.so
cd ..
rm -rf build
- name: Compile arm64 Linux lib
run: |
cd zstandard_cli/builders/linux_arm
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../arm64-toolchain.cmake ..
cmake --build . --config Release
mv libzstandard_linux.so ../../../lib/src/bin/libzstandard_linux_arm64.so
cd ..
rm -rf build
- name: Verify Linux libs
run: |
cd zstandard_cli/lib/src/bin
file libzstandard_linux_x64.so
file libzstandard_linux_arm64.so
- name: Git pull --no-ff
run: |
git pull --no-ff origin master
- name: Commit and Push Library
uses: EndBug/add-and-commit@v9
with:
add: './zstandard_cli/lib/src/bin/'
committer_name: GitHub Actions
committer_email: [email protected]
default_author: user_info
message: 'gh-action: Add precompiled Linux libraries for x86_64 and arm64'
cli_build_windows_precompiled_libs:
name: Windows precompiled libraries
runs-on: [ self-hosted, Windows ]
needs: [ update_files ]
steps:
- uses: actions/checkout@v4
- name: Set up Node.js 18
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Switch to SSH
shell: cmd
run: git remote set-url origin [email protected]:landamessenger/zstandard.git
- name: Install Landa Messenger CLI
shell: cmd
run: npm install -g @landamessenger/landa-messenger-api
- name: Download source files from facebook/zstd
shell: cmd
run: |
cd zstandard_cli
git clone https://github.com/facebook/zstd.git
mkdir src
xcopy zstd\lib src\ /E /I
rmdir /S /Q zstd
- name: List files in zstd/lib to verify
shell: cmd
run: dir zstandard_cli\src /S
- name: Compile x86_64 Windows lib
shell: cmd
run: |
cd zstandard_cli/builders/windows_x64
mkdir build && cd build
cmake -G "Visual Studio 17 2022" -A x64 ..
cmake --build . --config Release
cd Release
move zstandard_windows.dll ..\..\..\..\lib\src\bin\zstandard_windows_x64.dll
cd ..
cd ..
rmdir /S /Q build
- name: Compile arm64 Windows lib
shell: cmd
run: |
cd zstandard_cli/builders/windows_arm
mkdir build && cd build
cmake -G "Visual Studio 17 2022" -A ARM64 ..
cmake --build . --config Release
cd Release
move zstandard_windows.dll ..\..\..\..\lib\src\bin\zstandard_windows_arm64.dll
cd ..
cd ..
rmdir /S /Q build
- name: Verify Windows libs architecture
shell: cmd
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" amd64
dumpbin /headers zstandard_cli/lib/src/bin/zstandard_windows_x64.dll | findstr /c:"machine"
dumpbin /headers zstandard_cli/lib/src/bin/zstandard_windows_arm64.dll | findstr /c:"machine"
- name: Git pull --no-ff
shell: cmd
run: |
git pull --no-ff origin master
- name: Commit and Push Library
uses: EndBug/add-and-commit@v9
with:
add: './zstandard_cli/lib/src/bin/'
committer_name: GitHub Actions
committer_email: [email protected]
default_author: user_info
message: 'gh-action: Add precompiled Windows libraries for x86_64 and arm64'
tag_version:
name: Tag version and create release
runs-on: [ self-hosted, macOS ]
needs: [update_files, cli_build_windows_precompiled_libs, cli_build_linux_precompiled_libs, cli_build_macos_precompiled_libs]
steps:
- uses: actions/checkout@v4
- name: Set up Node.js 18
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Switch to SSH
run: git remote set-url origin [email protected]:landamessenger/zstandard.git
- name: Install Landa Messenger CLI
run: npm install @landamessenger/landa-messenger-api -g
- name: Create tag
id: create_tag
run: |
# Check if the tag already exists in the remote repository
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then
echo "Tag v${{needs.update_files.outputs.version}} already exists."
else
# Create and push the new tag
git tag "v${{needs.update_files.outputs.version}}"
git push origin "v${{needs.update_files.outputs.version}}"
fi
- name: Create release
if: ${{ steps.create_tag.outcome == 'success' }}
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{needs.update_files.outputs.version}}"
name: "${{ github.event.pull_request.title }}"
body: "${{ github.event.pull_request.body }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Handle job completion
if: always()
run: |
if [ "${{ job.status }}" == "failure" ]; then
landa-messenger-api chat-send \
--id "${{ secrets.CHAT_ID }}" \
--api_key "${{ secrets.CHAT_KEY }}" \
--title "🔴 Creation Tag Failed" \
--body "${{ github.repository }}: Tag v${{needs.update_files.outputs.version}}" \
--url "https://github.com/landamessenger/zstandard/actions/workflows/tag_version_and_publish.yml" \
--image "https://avatars.githubusercontent.com/u/63705403?s=200&v=4" \
--background_color "#55000000" \
--text_color "#FFFFFFFF"
elif [ "${{ job.status }}" == "cancelled" ]; then
landa-messenger-api chat-send \
--id "${{ secrets.CHAT_ID }}" \
--api_key "${{ secrets.CHAT_KEY }}" \
--title "🟠 Creation Tag Canceled" \
--body "${{ github.repository }}: Tag v${{needs.update_files.outputs.version}}" \
--url "https://github.com/landamessenger/zstandard/actions/workflows/tag_version_and_publish.yml" \
--image "https://avatars.githubusercontent.com/u/63705403?s=200&v=4" \
--background_color "#55000000" \
--text_color "#FFFFFFFF"
else
landa-messenger-api chat-send \
--id "${{ secrets.CHAT_ID }}" \
--api_key "${{ secrets.CHAT_KEY }}" \
--title "🟢 Creation Tag Passed" \
--body "${{ github.repository }}: Tag v${{needs.update_files.outputs.version}}" \
--url "https://github.com/landamessenger/zstandard/actions/workflows/tag_version_and_publish.yml" \
--image "https://avatars.githubusercontent.com/u/63705403?s=200&v=4" \
--background_color "#55000000" \
--text_color "#FFFFFFFF"
fi