-
Notifications
You must be signed in to change notification settings - Fork 23
274 lines (235 loc) · 10.4 KB
/
release_sdk_parallel.yml
File metadata and controls
274 lines (235 loc) · 10.4 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
name: Release SDK Library (parallel)
on:
workflow_dispatch:
inputs:
rust-checkout-ref:
description: 'The branch, tag or SHA to checkout on the rust sdk.'
required: true
default: 'main'
sdk-version:
description: 'The new version for the sdk library.'
required: true
permissions: {}
jobs:
build_targets:
strategy:
matrix:
target: [ "aarch64-linux-android", "armv7-linux-androideabi", "i686-linux-android", "x86_64-linux-android" ]
name: "Build Rust target: ${{ matrix.target }}"
runs-on: ubuntu-24.04
env:
NDK_VERSION: 29.0.14206865
# This is a workaround needed to link .so libraries with stripped debug symbols to the extracted debug symbols
RUSTFLAGS: "-Clink-args=-Wl,--build-id"
outputs:
linkable_ref: ${{ steps.set_linkable_ref.outputs.linkable_ref }}
concurrency:
group: ${{ github.ref }}-${{ github.job }}-${{ matrix.target }}
cancel-in-progress: true
steps:
- name: Checkout this repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Configure git user
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
with:
save-if: ${{ github.ref == 'refs/heads/main' || github.ref == 'main' }}
cache-on-failure: true
- name: Set up JDK 17
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
java-version: '17'
distribution: 'temurin' # See 'Supported distributions' for available options
# Note: the install android SDK step resets the `ANDROID_HOME` variable to a new folder with an update SDK but no NDK,
# so we need to set this NDK_PATH before that happens
- name: Configure android ndk
run: |
NDK_PATH=$ANDROID_HOME/ndk/$NDK_VERSION
echo $NDK_PATH
if [ -d "$NDK_PATH" ]; then
echo "ANDROID_NDK_HOME=$NDK_PATH" >> $GITHUB_ENV
echo "Using ndk $NDK_PATH"
else
echo "NDK_PATH not found, abort."
exit 1
fi
- name: Check objcopy is present
run: |
ls ${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-objcopy
echo LLVM_OBJCOPY=${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-objcopy >> $GITHUB_ENV
- name: Install android sdk
uses: malinskiy/action-android/install-sdk@fa103ef30331e95f266418a6a97e98f61f626887 # v0.1.7
- name: Install Rust
uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
- name: Install Protoc
uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Add Rust targets
run: |
rustup target add x86_64-linux-android
rustup target add aarch64-linux-android
rustup target add armv7-linux-androideabi
rustup target add i686-linux-android
- name: Install cargo-ndk
continue-on-error: true
run: cargo install cargo-ndk
- name: Set up Python 3
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.x'
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install argparse
pip install requests
- name: Run build script
run: |
python3 ./scripts/build-rust-for-target.py --module SDK --version ${GITHUB_EVENT_INPUTS_SDK_VERSION} --ref ${GITHUB_EVENT_INPUTS_RUST_CHECKOUT_REF} --target ${{ matrix.target }}
env:
GITHUB_EVENT_INPUTS_SDK_VERSION: ${{ github.event.inputs.sdk-version }}
GITHUB_EVENT_INPUTS_RUST_CHECKOUT_REF: ${{ github.event.inputs.rust-checkout-ref }}
- name: Extract debug symbols
run: |
pushd ${RUST_SDK_PATH}/target/${{ matrix.target }}/dist
echo "Original library with debug info:"
ls -lh libmatrix_sdk_ffi.so
echo "Extracting debug symbols"
${LLVM_OBJCOPY} --only-keep-debug libmatrix_sdk_ffi.so libmatrix_sdk_ffi.so.debug
ls -lh libmatrix_sdk_ffi.so.debug
echo "Stripping debug symbols from libmatrix_sdk_ffi.so"
${LLVM_OBJCOPY} --strip-debug --strip-unneeded libmatrix_sdk_ffi.so
echo "Done stripping debug symbols"
ls -lh libmatrix_sdk_ffi.so
echo "Link debug symbols to stripped binary"
${LLVM_OBJCOPY} --add-gnu-debuglink=libmatrix_sdk_ffi.so.debug libmatrix_sdk_ffi.so
popd
echo "Replacing built file with stripped one"
EXISTING_FILE=$(find sdk/sdk-android/src/main/jniLibs/ -name libmatrix_sdk_ffi.so)
cp ${RUST_SDK_PATH}/target/${{ matrix.target }}/dist/libmatrix_sdk_ffi.so $EXISTING_FILE
ls -lh $EXISTING_FILE
mkdir -p debuginfo/${{ matrix.target }}
cp ${RUST_SDK_PATH}/target/${{ matrix.target }}/dist/libmatrix_sdk_ffi.so.debug debuginfo/${{ matrix.target }}/
- name: Set linkable git ref
id: set_linkable_ref
run: |
pushd ${RUST_SDK_PATH}
COMMIT_HASH=$(git rev-parse --verify ${GITHUB_EVENT_INPUTS_RUST_CHECKOUT_REF}^{})
echo linkable_ref=$COMMIT_HASH >> $GITHUB_OUTPUT
echo "Using commit hash $COMMIT_HASH"
popd
env:
GITHUB_EVENT_INPUTS_RUST_CHECKOUT_REF: ${{ github.event.inputs.rust-checkout-ref }}
- name: Upload target artifacts
if: success() || failure()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: targets-${{ matrix.target }}
if-no-files-found: error
path: ./sdk/sdk-android/src/main/jniLibs/*/libmatrix_sdk_ffi.so
retention-days: 7
- name: Upload debug info
if: success() || failure()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: debuginfo-${{ matrix.target }}
if-no-files-found: error
path: debuginfo/
retention-days: 1
- name: Upload FFI bindings
# The FFI bindings will be identical for the 4 architectures, so upload as artifact
# only once.
if: (success() || failure()) && matrix.target == 'x86_64-linux-android'
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: ffi-bindings
if-no-files-found: error
path: ./sdk/sdk-android/src/main/kotlin/
retention-days: 7
release_library:
name: "Release SDK Library"
needs: build_targets
runs-on: ubuntu-24.04
permissions: {
contents: 'write', # Needed for creating a release
}
concurrency:
group: ${{ github.ref }}-${{ github.job }}
cancel-in-progress: true
steps:
- name: Checkout this repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: true # Needed to push the commit with the updated library
- name: Configure git user
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Download target artifacts to their right folders
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0@v7
with:
pattern: targets-*
merge-multiple: true
path: sdk/sdk-android/src/main/jniLibs/
- name: Download FFI bindings to their package
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0@v7
with:
name: ffi-bindings
path: sdk/sdk-android/src/main/kotlin/
- name: Set up JDK 17
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
java-version: '17'
distribution: 'temurin' # See 'Supported distributions' for available options
- name: Install android sdk
uses: malinskiy/action-android/install-sdk@fa103ef30331e95f266418a6a97e98f61f626887 # v0.1.7
- name: Set up Python 3
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.x'
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install argparse
pip install requests
- name: Run release script
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_EVENT_INPUTS_SDK_VERSION: ${{ github.event.inputs.sdk-version }}
NEEDS_BUILD_TARGETS_OUTPUTS_LINKABLE_REF: ${{ needs.build_targets.outputs.linkable_ref }}
run: |
python3 ./scripts/publish_release.py --module SDK --version ${GITHUB_EVENT_INPUTS_SDK_VERSION} --linkable-ref ${NEEDS_BUILD_TARGETS_OUTPUTS_LINKABLE_REF}
- name: Upload AAR results
if: success() || failure()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: sdk-android-release
if-no-files-found: error
path: ./sdk/sdk-android/build/**/*.aar
retention-days: 7
- name: Download debug info
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0@v7
with:
pattern: debuginfo-*
merge-multiple: true
path: ./debuginfo
- name: Setup Sentry CLI
uses: matbour/setup-sentry-cli@3e938c54b3018bdd019973689ef984e033b0454b # v2.0.0
with:
version: latest # optional if 'latest'
url: https://sentry.tools.element.io
token: ${{ SECRETS.SENTRY_TOKEN }} # from GitHub secrets
organization: element
project: 63 # the matrix sdk project
- name: Upload debuginfo to sentry
run: sentry-cli debug-files upload debuginfo