generated from matrix-org/.github
-
Notifications
You must be signed in to change notification settings - Fork 7
189 lines (158 loc) · 5.94 KB
/
release_sdk_parallel.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
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
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
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@v4
- name: Configure git user
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Install libc6-dev
run: |
sudo apt-get update
sudo apt-get install -y libc6
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' || github.ref == 'main' }}
cache-on-failure: true
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin' # See 'Supported distributions' for available options
- name: Install android sdk
uses: malinskiy/action-android/install-sdk@release/0.1.4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install Protoc
uses: arduino/setup-protoc@v1
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@v5
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 }}
- name: Set linkable git ref
id: set_linkable_ref
run: |
pushd ${{ env.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
- name: Upload target artifacts
if: success() || failure()
uses: actions/upload-artifact@v4
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 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@v4
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
concurrency:
group: ${{ github.ref }}-${{ github.job }}
cancel-in-progress: true
steps:
- name: Checkout this repo
uses: actions/checkout@v4
- name: Configure git user
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Download target artifacts to their right folders
uses: actions/download-artifact@v4
with:
pattern: targets-*
merge-multiple: true
path: sdk/sdk-android/src/main/jniLibs/
- name: Download FFI bindings to their package
uses: actions/download-artifact@v4
with:
name: ffi-bindings
path: sdk/sdk-android/src/main/kotlin/
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin' # See 'Supported distributions' for available options
- name: Install android sdk
uses: malinskiy/action-android/install-sdk@release/0.1.4
- name: Set up Python 3
uses: actions/setup-python@v5
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 }}
run: |
python3 ./scripts/release_sdk.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@v4
with:
name: sdk-android-release
if-no-files-found: error
path: ./sdk/sdk-android/build/**/*.aar
retention-days: 7