forked from firebase/firebase-cpp-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (143 loc) · 6.07 KB
/
android.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
name: Android Builds
on:
pull_request:
types: [opened, reopened, synchronize]
workflow_dispatch:
inputs:
use_expanded_matrix:
description: 'Use an expanded matrix?'
default: '0'
required: true
env:
CCACHE_DIR: ${{ github.workspace }}/ccache_dir
GITHUB_TOKEN: ${{ github.token }}
xcodeVersion: "14.1" # Only affects Mac runners, and only for prerequisites.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
prepare_matrix:
runs-on: ubuntu-20.04
outputs:
matrix_os: ${{ steps.export-result.outputs.matrix_os }}
matrix_architecture: ${{ steps.export-result.outputs.matrix_architecture }}
matrix_python_version: ${{ steps.export-result.outputs.matrix_python_version }}
steps:
- uses: actions/checkout@v3
with:
submodules: false
- name: Use expanded matrix
if: github.event.inputs.use_expanded_matrix == '1'
run: |
echo "EXPANDED_MATRIX_PARAM=-e=1" >> $GITHUB_ENV
- id: export-result
run: |
echo "matrix_os=$( python scripts/gha/print_matrix_configuration.py -w android -k os ${EXPANDED_MATRIX_PARAM} )" >> $GITHUB_OUTPUT
echo "matrix_architecture=$( python scripts/gha/print_matrix_configuration.py -w android -k architecture ${EXPANDED_MATRIX_PARAM} )" >> $GITHUB_OUTPUT
echo "matrix_python_version=$( python scripts/gha/print_matrix_configuration.py -w android -k python_version ${EXPANDED_MATRIX_PARAM} )" >> $GITHUB_OUTPUT
build:
name: android-${{ matrix.os }}-${{ matrix.architecture }}-${{ matrix.python_version }}
runs-on: ${{ matrix.os }}
needs: prepare_matrix
strategy:
fail-fast: false
matrix:
os: ${{ fromJson(needs.prepare_matrix.outputs.matrix_os) }}
architecture: ${{ fromJson(needs.prepare_matrix.outputs.matrix_architecture) }}
python_version: ${{ fromJson(needs.prepare_matrix.outputs.matrix_python_version) }}
steps:
- name: setup Xcode version (macos)
if: runner.os == 'macOS'
run: sudo xcode-select -s /Applications/Xcode_${{ env.xcodeVersion }}.app/Contents/Developer
- name: Force Java 8 (macOS)
if: startsWith(matrix.os, 'macos')
shell: bash
run: echo "JAVA_HOME=${JAVA_HOME_8_X64}" >> $GITHUB_ENV
- 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
- name: Enable Git Long-paths Support
if: runner.os == 'Windows'
run: git config --system core.longpaths true
- name: Check expanded matrix config
if: github.event.inputs.expanded_matrix == '1'
run: |
echo "Enabling expanded build and test matrix."
echo "USE_EXPANDED_MATRIX=1" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
submodules: true
- name: Set env variables for subsequent steps (all)
shell: bash
run: |
echo "MATRIX_UNIQUE_NAME=${{ matrix.os }}-${{ matrix.architecture }}" >> $GITHUB_ENV
echo "GHA_INSTALL_CCACHE=1" >> $GITHUB_ENV
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
architecture: ${{ matrix.architecture }}
- name: Add msbuild to PATH
if: startsWith(matrix.os, 'windows')
uses: microsoft/[email protected]
- name: Cache NDK
id: cache_ndk
uses: actions/cache@v3
with:
path: /tmp/android-ndk-r21e
key: android-ndk-${{ matrix.os }}-r21e
- name: Check cached NDK
shell: bash
if: steps.cache_ndk.outputs.cache-hit != 'true'
run: |
# If the NDK failed to download from the cache, but there is a
# /tmp/android-ndk-r21e directory, it's incomplete, so remove it.
if [[ -d "/tmp/android-ndk-r21e" ]]; then
echo "Removing incomplete download of NDK"
rm -rf /tmp/android-ndk-r21e
fi
- name: Install prerequisites
shell: bash
run: |
build_scripts/android/install_prereqs.sh
echo "NDK_ROOT=/tmp/android-ndk-r21e" >> $GITHUB_ENV
echo "ANDROID_NDK_HOME=/tmp/android-ndk-r21e" >> $GITHUB_ENV
- name: Add strings.exe to PATH (Windows only)
if: startsWith(matrix.os, 'windows')
shell: bash
run: |
# strings.exe was installed in repo root by install_prereqs.sh.
# There is another conflicting strings executable on Github runners.
# "C:\ProgramData\Chocolatey\lib\mingw\tools\install\mingw64\bin\strings.exe"
# Make sure to prepend the one in our repo root to the path.
echo "${{ github.workspace }}" >> $GITHUB_PATH
- name: Run strings.exe once to accept license(Windows only)
if: startsWith(matrix.os, 'windows')
shell: bash
run: |
# This invocation is just to accept the license. Otherwise the command
# fails during build process. Also, running a command with just this
# flag makes the process exit with code 127 and stops the workflow.
# We ignore the error and continue with the rest of the steps.
strings -accepteula || true
- name: Cache ccache files
id: cache_ccache
uses: actions/cache@v3
with:
path: ccache_dir
key: dev-test-ccache-${{ env.MATRIX_UNIQUE_NAME }}
- name: Build SDK
shell: bash
run: |
build_scripts/android/build.sh android_build .
- name: Stats for ccache (mac and linux)
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
run: ccache -s
- name: Print built libraries
shell: bash
run: |
find android_build -name "*.aar"
find android_build -name "*.jar"