This repository was archived by the owner on May 8, 2025. It is now read-only.
forked from firebase/firebase-cpp-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
508 lines (454 loc) · 19.2 KB
/
Copy pathcpp-packaging.yml
File metadata and controls
508 lines (454 loc) · 19.2 KB
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
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
name: CPP binary SDK packaging
on:
push:
branches:
# Run a full packaging step any time a new branch is merged into main.
- main
schedule:
- cron: "0 8 * * *" # 8am UTC = 12am PST / 1am PDT
workflow_dispatch:
inputs:
preserveIntermediateArtifacts:
description: "preserve intermediate artifacts?"
default: "0"
verboseBuild:
description: "verbose build?"
default: "0"
skipIntegrationTests:
description: "skip integration tests?"
default: "0"
downloadPublicVersion:
description: "public version # to test against"
downloadPreviousRun:
description: "previous run # to test against"
use_expanded_matrix:
description: "Use an expanded matrix?"
default: "0"
required: true
env:
# Packaging prerequisites
# Demumble version from March 22, 2022
demumbleVer: "df938e45c2b0e064fb5323d88b692d03b451d271"
# Use SHA256 for hashing files.
hashCommand: "sha256sum"
# Xcode version 15.1 is the version we build the SDK with.
# Our MacOS runners will use the version in /Applications/Xcode_${xcodeVersion}.app
xcodeVersion: "15.1"
# LLVM version with ARM MachO support has no version number yet.
llvmVer: "5f187f0afaad33013ba03454c4749d99b1362534"
GITHUB_TOKEN: ${{ github.token }}
jobs:
log_inputs:
name: log-inputs
runs-on: ubuntu-latest
steps:
- name: log run inputs
run: |
if [[ -n "${{ github.event.inputs.downloadPublicVersion }}" ]]; then
echo "::warning ::Downloading public SDK package from https://dl.google.com/firebase/sdk/cpp/firebase_cpp_sdk_${{ github.event.inputs.downloadPublicVersion }}.zip"
elif [[ -n "${{ github.event.inputs.downloadPreviousRun }}" ]]; then
echo "::warning ::Downloading SDK package from previous run at https://github.com/firebase/firebase-cpp-sdk/actions/runs/${{ github.event.inputs.downloadPreviousRun }}"
fi
- name: log if skipping integration tests
if: |
github.event.inputs.skipIntegrationTests != 0 && github.event.inputs.skipIntegrationTests != ''
run: echo "::warning ::Skipping integration tests."
- name: log if preserving intermediate artifacts
if: |
github.event.inputs.preserveIntermediateArtifacts != 0 && github.event.inputs.preserveIntermediateArtifacts != '' &&
github.event.inputs.downloadPublicVersion == '' && github.event.inputs.downloadPreviousRun == ''
run: echo "::warning ::Intermediate artifacts will be preserved."
- name: log if verbose build enabled
if: |
github.event.inputs.verboseBuild != 0 && github.event.inputs.verboseBuild != '' &&
github.event.inputs.downloadPublicVersion == '' && github.event.inputs.downloadPreviousRun == ''
run: echo "::warning ::Verbose build enabled."
- name: log if expanded matrix enabled
if: github.event_name == 'schedule' || github.event.inputs.use_expanded_matrix == '1'
run: echo "::warning ::Expanded test matrix enabled."
build_tools:
name: build-tools-${{ matrix.tools_platform }}
runs-on: ${{ matrix.os }}
if: ${{ github.event.inputs.downloadPublicVersion == '' && github.event.inputs.downloadPreviousRun == '' }}
strategy:
matrix:
os: [ubuntu-latest]
include:
- os: ubuntu-latest
tools_platform: linux
# Binutils 2.35.1 released Sep 19, 2020
binutils_version: "2.35.1"
steps:
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Fetch and build binutils
run: |
set +e
# Retry up to 10 times because Curl has a tendency to timeout on
# Github runners.
for retry in {1..10} error; do
if [[ $retry == "error" ]]; then exit 5; fi
curl -L https://ftpmirror.gnu.org/binutils/binutils-${{ matrix.binutils_version }}.tar.xz --output binutils.tar.xz && break
sleep 300
done
set -e
tar -xf binutils.tar.xz
mv ./binutils-${{ matrix.binutils_version }} ./binutils-src
mkdir /tmp/binutils-output
cd binutils-src
./configure --enable-targets=all --prefix=/tmp/binutils-output
make -j2
make install
cd -
mkdir -p packaging-tools
cp -af /tmp/binutils-output/bin/* packaging-tools
- name: fetch demumble
uses: actions/checkout@v3
with:
repository: nico/demumble
path: demumble-src
ref: ${{ env.demumbleVer }}
- name: build demumble
run: |
cd demumble-src
cmake .
cmake --build .
python demumble_test.py
cd -
mkdir -p packaging-tools
cp -af demumble-src/demumble packaging-tools
- name: archive tools
run: |
cd packaging-tools
ls
tar -czhf ../packaging-tools.tgz .
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: packaging-tools-${{ matrix.tools_platform }}
path: packaging-tools.tgz
build_desktop:
name: build-${{ matrix.sdk_platform }}-${{ matrix.architecture }}-${{ matrix.build_type }}-${{ matrix.msvc_runtime }}-${{ matrix.linux_abi }}
runs-on: ${{ matrix.os }}
if: ${{ github.event.inputs.downloadPublicVersion == '' && github.event.inputs.downloadPreviousRun == '' }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04-arm]
# build_type: ["Release", "Debug"]
build_type: ["Release"]
# architecture: ["x64", "armv7"]
architecture: ["armv7"]
linux_abi: ["c++11"]
python_version: [3.8]
include:
# Find way to only build app and auth
# - os: ubuntu-latest
# vcpkg_triplet_suffix: "linux"
# additional_build_flags: ""
# sdk_platform: "linux"
- os: ubuntu-24.04-arm
vcpkg_triplet_suffix: ""
additional_build_flags: ""
sdk_platform: "linux"
architecture: "armv7"
linux_abi: "c++11"
exclude:
- os: ubuntu-latest-arm
build_type: "Debug"
steps:
- name: Store git credentials for all git commands
# Forces all git commands to use authenticated https, to prevent throttling.
shell: bash
run: |
git config --global credential.helper 'store --file /tmp/git-credentials'
echo 'https://${{ github.token }}@github.com' > /tmp/git-credentials
- uses: actions/checkout@v3
with:
submodules: true
- name: Set env variables for subsequent steps (all)
shell: bash
run: |
echo "VCPKG_RESPONSE_FILE=external/vcpkg_${{ matrix.vcpkg_triplet }}_response_file.txt" >> $GITHUB_ENV
echo "MATRIX_UNIQUE_NAME=${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.architecture }}-${{ matrix.python_version }}-${{ matrix.msvc_runtime }}-${{ matrix.linux_abi }}" >> $GITHUB_ENV
echo "SDK_NAME=${{ matrix.sdk_platform }}-${{ matrix.architecture }}-${{ matrix.build_type }}-${{ matrix.msvc_runtime }}-${{ matrix.linux_abi }}" >> $GITHUB_ENV
- name: Cache vcpkg C++ dependencies
id: cache_vcpkg
uses: actions/cache@v3
with:
path: external/vcpkg/installed
key: dev-vcpkg-${{ matrix.architecture }}-${{ matrix.vcpkg_triplet_suffix }}-${{ matrix.msvc_runtime }}-${{ matrix.linux_abi }}-${{ hashFiles(format('{0}', env.VCPKG_RESPONSE_FILE)) }}-${{ hashFiles('.git/modules/external/vcpkg/HEAD') }}${{env.VCPKG_EXTRA_HASH}}
- name: Cache ccache files
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
id: cache_ccache
uses: actions/cache@v3
with:
path: ccache_dir
key: dev-test-ccache-${{ env.MATRIX_UNIQUE_NAME }}
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
- name: Install Desktop SDK prerequisites
uses: nick-invision/retry@v2
with:
timeout_minutes: 15
max_attempts: 3
command: |
python scripts/gha/install_prereqs_desktop.py --gha_build --arch '${{ matrix.architecture }}' --ssl boringssl
- name: Export verbose flag
shell: bash
run: |
verbose_flag=
if [[ -n "${{ github.event.inputs.verboseBuild }}" && "${{ github.event.inputs.verboseBuild }}" -ne 0 ]]; then
verbose_flag=--verbose
fi
echo "VERBOSE_FLAG=${verbose_flag}" >> $GITHUB_ENV
- uses: fawazahmed0/action-debug-vscode@main
# Run the build in the host OS default shell since Windows can't handle long path names in bash.
- name: Build desktop SDK
run: |
python scripts/gha/build_desktop.py --arch "${{ matrix.architecture }}" \
--config "${{ matrix.build_type }}" \
--msvc_runtime_library "${{ matrix.msvc_runtime }}" \
--linux_abi "${{ matrix.linux_abi }}" \
--build_dir out-sdk \
${VERBOSE_FLAG} \
${{ matrix.additional_build_flags }} \
--gha_build
- name: Archive SDK
shell: bash
run: |
cd out-sdk
find .. -type f -print > src_file_list.txt
# Remove intermediate build files (.o and .obj) files to save space.
find . -type f -name '*.o' -or -name '*.obj' -print0 | xargs -0 rm -f --
tar -czhf ../firebase-cpp-sdk-${{ env.SDK_NAME }}-build.tgz .
- name: Print built libraries
shell: bash
run: |
find out-* -name "*.lib"
find out-* -name "*.dll"
find out-* -name "*.dylib"
find out-* -name "*.a"
find out-* -name "*.so"
find out-* -name "*.framework"
- name: Inspect firebase libraries for cpu arch and msvc runtime.
shell: bash
run: |
python scripts/gha/inspect_built_libraries.py out-sdk/
continue-on-error: true
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: firebase-cpp-sdk-${{ env.SDK_NAME }}-build
path: firebase-cpp-sdk-${{ env.SDK_NAME }}-build.tgz
package_desktop:
name: package-${{ matrix.sdk_platform }}${{ matrix.suffix }}
runs-on: ubuntu-latest
needs: [build_tools, build_desktop]
if: ${{ github.event.inputs.downloadPublicVersion == '' && github.event.inputs.downloadPreviousRun == '' }}
strategy:
fail-fast: false
matrix:
sdk_platform: [linux]
suffix: [""]
steps:
- name: fetch SDK
uses: actions/checkout@v3
with:
path: sdk-src
- name: download artifact
uses: actions/download-artifact@v4
with:
# download-artifact doesn't support wildcards, but by default
# will download all artifacts. Sadly this is what we must do.
path: artifacts
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install prerequisites
run: |
cd sdk-src
python scripts/gha/install_prereqs_desktop.py --ssl boringssl
cd ..
if [[ $(uname) == "Darwin"* ]]; then
brew install parallel
fi
- name: postprocess and package built SDK
run: |
mkdir -p bin
tools_platform=linux
verbose_flag=
if [[ -n "${{ github.event.inputs.verboseBuild }}" && "${{ github.event.inputs.verboseBuild }}" -ne 0 ]]; then
verbose_flag=-v
fi
declare -a additional_flags
tar -xvzf artifacts/packaging-tools-${tools_platform}/packaging-tools.tgz -C bin
chmod -R u+x bin
# To save space, delete any artifacts that we don't need for packaging.
for pkg in artifacts/firebase-cpp-sdk-*; do
if [[ "${pkg}" != "artifacts/firebase-cpp-sdk-${{ matrix.sdk_platform }}${{ matrix.suffix }}"* ]]; then
echo "Deleting unneeded artifact: ${pkg}"
rm -rf "${pkg}"
fi
done
for pkg in artifacts/firebase-cpp-sdk-${{ matrix.sdk_platform }}${{ matrix.suffix }}*-build/*.tgz; do
variant=$(sdk-src/build_scripts/desktop/get_variant.sh "${pkg}")
additional_flags=(${verbose_flag})
sdk-src/build_scripts/desktop/package.sh -b ${pkg} -o firebase-cpp-sdk-${{ matrix.sdk_platform }}${{ matrix.suffix }}-package -p ${{ matrix.sdk_platform }} -t bin -d ${variant} -P python3 -j ${additional_flags[*]}
# Extract the contents of the package
temp_dir=$(mktemp -d)
tar -xzf ${pkg} -C ${temp_dir}
# Copy .so files to the package directory
find ${temp_dir} -name '*.so' -type f -exec cp {} firebase-cpp-sdk-${{ matrix.sdk_platform }}${{ matrix.suffix }}-package/libs/${{ matrix.sdk_platform }}/x86_64/cxx11 \;
# Clean up
rm -rf ${temp_dir}
done
cd firebase-cpp-sdk-${{ matrix.sdk_platform }}${{ matrix.suffix }}-package
tar -czhf ../firebase-cpp-sdk-${{ matrix.sdk_platform }}${{ matrix.suffix }}-package.tgz .
- name: Print package contents
shell: bash
run: |
find firebase-cpp-sdk-*-package -type f
- name: upload SDK zip
uses: actions/upload-artifact@v4
with:
name: firebase-cpp-sdk-${{ matrix.sdk_platform }}${{ matrix.suffix}}-package
path: firebase-cpp-sdk-${{ matrix.sdk_platform }}${{ matrix.suffix}}-package.tgz
- name: cleanup build artifacts
if: |
(
(github.event.inputs.preserveIntermediateArtifacts == 0 || github.event.inputs.preserveIntermediateArtifacts == '')
&& github.event.inputs.downloadPublicVersion == ''
&& github.event.inputs.downloadPreviousRun == ''
)
# Remove the build artifacts that were consumed during this step of packaging.
uses: geekyeggo/delete-artifact@v2
with:
name: |
firebase-cpp-sdk-${{ matrix.sdk_platform }}${{ matrix.suffix }}*-build
failOnError: false
useGlob: true
# TODO : Check if removeable or not
download_sdk_package:
name: download-sdk-package
runs-on: ubuntu-latest
needs: [log_inputs]
if: ${{ github.event.inputs.downloadPublicVersion != '' || github.event.inputs.downloadPreviousRun != '' }}
steps:
- name: fetch artifact from previous run
uses: dawidd6/action-download-artifact@v2
if: ${{ github.event.inputs.downloadPreviousRun != '' }}
with:
name: "firebase_cpp_sdk.zip"
workflow: "cpp-packaging.yml"
run_id: ${{ github.event.inputs.downloadPreviousRun }}
- name: fetch public SDK package from web
if: ${{ github.event.inputs.downloadPublicVersion != '' && github.event.inputs.downloadPreviousRun == '' }}
run: |
if [[ ! "${{ github.event.inputs.downloadPublicVersion }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo Invalid version number: "${{ github.event.inputs.downloadPublicVersion }}"
exit 1
fi
set +e
# Retry up to 10 times because Curl has a tendency to timeout on
# Github runners.
for retry in {1..10} error; do
if [[ $retry == "error" ]]; then exit 5; fi
curl -L https://dl.google.com/firebase/sdk/cpp/firebase_cpp_sdk_${{ github.event.inputs.downloadPublicVersion }}.zip --output firebase_cpp_sdk.zip && break
sleep 300
done
set -e
- name: compute SDK hash
shell: bash
run: |
${{ env.hashCommand }} --tag firebase_cpp_sdk.zip > firebase_cpp_sdk_hash.txt
echo "::warning ::$(cat firebase_cpp_sdk_hash.txt)"
- name: upload hash
uses: actions/upload-artifact@v4
with:
name: firebase_cpp_sdk_hash.txt
path: firebase_cpp_sdk_hash.txt
- name: upload SDK zip
uses: actions/upload-artifact@v4
with:
name: firebase_cpp_sdk.zip
path: firebase_cpp_sdk.zip
merge_packages:
name: final-merge-packages
runs-on: ubuntu-latest
if: ${{ github.event.inputs.downloadPublicVersion == '' && github.event.inputs.downloadPreviousRun == '' }}
needs: [package_desktop, log_inputs]
steps:
- name: fetch SDK
uses: actions/checkout@v3
with:
path: sdk-src
- name: download artifact
uses: actions/download-artifact@v4
with:
# download-artifact doesn't support wildcards, but by default
# will download all artifacts. Sadly this is what we must do.
path: artifacts
- name: merge SDK packages
shell: bash
run: |
set -ex
mkdir -p firebase-cpp-sdk-final/firebase_cpp_sdk
for pkg in artifacts/firebase-cpp-sdk-*-package/*.tgz; do
tar -xzf "${pkg}" -C firebase-cpp-sdk-final/firebase_cpp_sdk
done
# Add the final files.
sdk-src/build_scripts/other/package.sh sdk-src firebase-cpp-sdk-final/firebase_cpp_sdk
# Zip up the package and grab a hash of the result.
cd firebase-cpp-sdk-final
# Save the hash of every file into the SDK package.
find firebase_cpp_sdk -type f -print0 | xargs -0 ${{ env.hashCommand }} --tag > file_hashes.txt
mv file_hashes.txt firebase_cpp_sdk/
# Zip up the SDK package recursively, preserving symlinks.
zip -9 -r -y ../firebase_cpp_sdk.zip firebase_cpp_sdk
cd ..
- name: compute SDK hash
shell: bash
run: |
${{ env.hashCommand }} --tag firebase_cpp_sdk.zip > firebase_cpp_sdk_hash.txt
echo "::warning ::$(cat firebase_cpp_sdk_hash.txt)"
- name: Print final package contents
shell: bash
run: |
cd firebase-cpp-sdk-final
find firebase_cpp_sdk -type f
- name: upload hash
uses: actions/upload-artifact@v4
with:
name: firebase_cpp_sdk_hash.txt
path: firebase_cpp_sdk_hash.txt
- name: upload SDK zip
uses: actions/upload-artifact@v4
with:
name: firebase_cpp_sdk.zip
path: firebase_cpp_sdk.zip
cleanup_packaging_artifacts:
# Clean up intermediate artifacts from packaging step.
# This can happen after the final package merge is finished.
name: cleanup-packaging-artifacts
runs-on: ubuntu-latest
needs: [merge_packages]
if: |
(
(github.event.inputs.preserveIntermediateArtifacts == 0 || github.event.inputs.preserveIntermediateArtifacts == '')
&& github.event.inputs.downloadPublicVersion == ''
&& github.event.inputs.downloadPreviousRun == ''
)
steps:
- uses: geekyeggo/delete-artifact@v2
with:
name: |
packaging-tools-*
firebase-cpp-sdk-*-package
failOnError: false
useGlob: true