generated from matrix-org/.github
-
Notifications
You must be signed in to change notification settings - Fork 7
196 lines (163 loc) · 6.69 KB
/
snapshot.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
name: Build & Publish snapshot
on:
workflow_dispatch:
inputs:
rust-checkout-ref:
description: 'The branch, tag or SHA to checkout on the rust sdk.'
required: true
default: 'main'
jobs:
build_native:
name: Build and generate crypto native libs
runs-on: macos-latest
strategy:
matrix:
targets: [ {value: armv7-linux-androideabi, folder: armeabi-v7a}, {value: i686-linux-android, folder: x86}, {value: aarch64-linux-android, folder: arm64-v8a}]
steps:
- name: Checkout this repo
uses: actions/checkout@v4
with:
path: main
- name: Checkout matrix rust sdk repo
uses: actions/checkout@v4
with:
repository: matrix-org/matrix-rust-sdk
path: rust-sdk
ref: '${{ github.event.inputs.rust-checkout-ref }}'
- name: Install android sdk
uses: malinskiy/action-android/install-sdk@release/0.1.4
- name: Install android ndk
uses: nttld/setup-ndk@v1
id: install-ndk
with:
ndk-version: r22b
- name: Create symlinks for buildchain
run: |
export PATH="${{ steps.install-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/darwin-x86_64/bin:$PATH"
echo $PATH
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
target: ${{ matrix.targets.value }}
toolchain: stable
override: true
- name: Create cargo config
run: |
echo [target.aarch64-linux-android] > $HOME/.cargo/config.toml
echo ar = \"${{ steps.install-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/ar\" >> $HOME/.cargo/config.toml
echo linker = \"${{ steps.install-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang\" >> $HOME/.cargo/config.toml
echo [target.i686-linux-android] >> $HOME/.cargo/config.toml
echo ar = \"${{ steps.install-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/ar\" >> $HOME/.cargo/config.toml
echo linker = \"${{ steps.install-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android30-clang\" >> $HOME/.cargo/config.toml
echo [target.armv7-linux-androideabi] >> $HOME/.cargo/config.toml
echo ar = \"${{ steps.install-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/ar\" >> $HOME/.cargo/config.toml
echo linker = \"${{ steps.install-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi30-clang\" >> $HOME/.cargo/config.toml
cat $HOME/.cargo/config.toml
- name: Cargo install uniffi_bindgen
continue-on-error: true
uses: actions-rs/cargo@v1
with:
command: install
args: uniffi_bindgen
- name: Cargo build
uses: actions-rs/cargo@v1
env:
ANDROID_NDK: ${{ steps.install-ndk.outputs.ndk-path }}
with:
command: build
args: --manifest-path rust-sdk/crates/matrix-sdk-crypto-ffi/Cargo.toml --release --target=${{ matrix.targets.value }}
- name: Rename native file
run: |
mv rust-sdk/target/${{ matrix.targets.value }}/release/libmatrix_crypto.so rust-sdk/target/${{ matrix.targets.value }}/release/libuniffi_olm.so
- name: Upload native file
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.targets.folder }}
path: rust-sdk/target/${{ matrix.targets.value }}/release/libuniffi_olm.so
build_android:
name: Build and publish android library
runs-on: macos-latest
needs: build_native
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 }}
SNAPSHOT: true
steps:
- name: Checkout this repo
uses: actions/checkout@v4
- name: Checkout matrix rust sdk repo
uses: actions/checkout@v4
with:
repository: matrix-org/matrix-rust-sdk
path: rust-sdk
- name: Create jniLibs folder
run: |
mkdir -p crypto/crypto-android/src/main/jniLibs
- name: Download all binary result
uses: actions/download-artifact@v4
with:
path: crypto/crypto-android/src/main/jniLibs
- name: set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
cache: gradle
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
target: ${{ matrix.targets.value }}
toolchain: stable
override: true
- name: Cargo install uniffi_bindgen
continue-on-error: true
uses: actions-rs/cargo@v1
with:
command: install
args: uniffi_bindgen
- name: Generate bindings
run: |
uniffi-bindgen generate rust-sdk/crates/matrix-sdk-crypto-ffi/src/olm.udl --language kotlin --out-dir crypto/crypto-android/build/generated/source/uniffi/release/java
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build crypto module
run: ./gradlew :crypto:crypto-android:assembleRelease
- name: Upload library file (aar)
uses: actions/upload-artifact@v4
with:
name: crypto-release
path: crypto/crypto-android/build/outputs/aar/crypto-android-release.aar
- name: Publish to MavenCentral
run: ./gradlew publishReleasePublicationToSonatypeRepository