1- name : Release Crypto Library
1+ name : Release Crypto Library (parallel)
22
33on :
44 workflow_dispatch :
77 description : ' The branch, tag or SHA to checkout on the rust sdk.'
88 required : true
99 default : ' main'
10- crypto- sdk-version :
11- description : ' The new version for the rust- crypto library.'
10+ sdk-version :
11+ description : ' The new version for the crypto library.'
1212 required : true
1313
14-
1514jobs :
16- build_native :
17- name : Build and generate crypto native libs
15+ build_targets :
16+ strategy :
17+ matrix :
18+ target : [ "aarch64-linux-android", "armv7-linux-androideabi", "i686-linux-android", "x86_64-linux-android" ]
19+ name : " Build Rust target: ${{ matrix.target }}"
1820 runs-on : ubuntu-24.04
19- env :
20- OSSRH_USERNAME : ${{ secrets.OSSRH_USERNAME }}
21- OSSRH_PASSWORD : ${{ secrets.OSSRH_PASSWORD }}
22- SIGNING_KEY_ID : ${{ secrets.SIGNING_KEY_ID }}
23- SIGNING_PASSWORD : ${{ secrets.SIGNING_PASSWORD }}
24- SIGNING_KEY : ${{ secrets.SIGNING_KEY }}
25- SONATYPE_STAGING_PROFILE_ID : ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
21+ outputs :
22+ linkable_ref : ${{ steps.set_linkable_ref.outputs.linkable_ref }}
2623
2724 concurrency :
28- group : ${{ github.ref }}-${{ github.job }}
25+ group : ${{ github.ref }}-${{ github.job }}-${{ matrix.target }}
2926 cancel-in-progress : true
3027
3128 steps :
32-
3329 - name : Checkout this repo
3430 uses : actions/checkout@v4
3531
@@ -38,12 +34,10 @@ jobs:
3834 git config user.name github-actions
3935 git config user.email [email protected] 4036
41- - name : Checkout matrix rust sdk repo
42- uses : actions/checkout@v4
37+ - uses : Swatinem/rust-cache@v2
4338 with :
44- repository : matrix-org/matrix-rust-sdk
45- path : rust-sdk
46- ref : ' ${{ github.event.inputs.rust-checkout-ref }}'
39+ save-if : ${{ github.ref == 'refs/heads/main' || github.ref == 'main' }}
40+ cache-on-failure : true
4741
4842 - name : Set up JDK 17
4943 uses : actions/setup-java@v4
@@ -54,45 +48,13 @@ jobs:
5448 - name : Install android sdk
5549 uses : malinskiy/action-android/install-sdk@release/0.1.4
5650
57- - name : Install android ndk
58- uses : nttld/setup-ndk@v1
59- id : install-ndk
60- with :
61- ndk-version : r27
62-
63- # - name: Create symlinks for buildchain
64- # run: |
65- # export PATH="${{ steps.install-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/darwin-x86_64/bin:$PATH"
66- # echo $PATH
67-
68- - uses : actions/cache@v4
69- with :
70- path : |
71- ~/.cargo/bin/
72- ~/.cargo/registry/index/
73- ~/.cargo/registry/cache/
74- ~/.cargo/git/db
75- target/
76- key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
77-
7851 - name : Install Rust
7952 uses : dtolnay/rust-toolchain@stable
8053
81- # - name: Create cargo config
82- # run: |
83- # echo [target.aarch64-linux-android] > $HOME/.cargo/config.toml
84- # echo ar = \"${{ steps.install-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/darwin-x86_64/bin/ar\" >> $HOME/.cargo/config.toml
85- # echo linker = \"${{ steps.install-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android30-clang\" >> $HOME/.cargo/config.toml
86- #
87- # echo [target.i686-linux-android] >> $HOME/.cargo/config.toml
88- # echo ar = \"${{ steps.install-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/darwin-x86_64/bin/ar\" >> $HOME/.cargo/config.toml
89- # echo linker = \"${{ steps.install-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/darwin-x86_64/bin/i686-linux-android30-clang\" >> $HOME/.cargo/config.toml
90- #
91- # echo [target.armv7-linux-androideabi] >> $HOME/.cargo/config.toml
92- # echo ar = \"${{ steps.install-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/darwin-x86_64/bin/ar\" >> $HOME/.cargo/config.toml
93- # echo linker = \"${{ steps.install-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi30-clang\" >> $HOME/.cargo/config.toml
94- #
95- # cat $HOME/.cargo/config.toml
54+ - name : Install Protoc
55+ uses : arduino/setup-protoc@v1
56+ with :
57+ repo-token : ${{ secrets.GITHUB_TOKEN }}
9658
9759 - name : Add Rust targets
9860 run : |
@@ -105,53 +67,118 @@ jobs:
10567 continue-on-error : true
10668 run : cargo install cargo-ndk
10769
108- - name : Configure gradle
109- uses : gradle/actions/setup-gradle@v3
70+ - name : Set up Python 3
71+ uses : actions/setup-python@v5
72+ with :
73+ python-version : ' 3.x'
74+
75+ - name : Install python dependencies
76+ run : |
77+ python -m pip install --upgrade pip
78+ pip install argparse
79+ pip install requests
11080
11181 - name : Run build script
112- env :
113- ANDROID_NDK : ${{ steps.install-ndk.outputs.ndk-path }}
114- run : ./scripts/build.sh -r -m crypto -p rust-sdk
82+ run : |
83+ python3 ./scripts/build-rust-for-target.py --module CRYPTO --version ${{ github.event.inputs.sdk-version }} --ref ${{ github.event.inputs.rust-checkout-ref }} --target ${{ matrix.target }}
11584
116- - name : Find all .aar files
117- run : find . -name "*.aar"
85+ - name : Set linkable git ref
86+ id : set_linkable_ref
87+ run : |
88+ pushd ${{ env.RUST_SDK_PATH }}
89+ COMMIT_HASH=$(git rev-parse --verify ${{ github.event.inputs.rust-checkout-ref }})
90+ echo linkable_ref=$COMMIT_HASH >> $GITHUB_OUTPUT
91+ echo "Using commit hash $COMMIT_HASH"
92+ popd
93+
94+ - name : Upload target artifacts
95+ if : success() || failure()
96+ uses : actions/upload-artifact@v4
97+ with :
98+ name : targets-${{ matrix.target }}
99+ if-no-files-found : error
100+ path : ./crypto/crypto-android/src/main/jniLibs/*/libmatrix_sdk_crypto_ffi.so
101+ retention-days : 7
102+
103+ - name : Upload FFI bindings
104+ # The FFI bindings will be identical for the 4 architectures, so upload as artifact
105+ # only once.
106+ if : (success() || failure()) && matrix.target == 'x86_64-linux-android'
107+ uses : actions/upload-artifact@v4
108+ with :
109+ name : ffi-bindings
110+ if-no-files-found : error
111+ path : ./crypto/crypto-android/src/main/kotlin/
112+ retention-days : 7
113+
114+ release_library :
115+ name : " Release SDK Library"
116+ needs : build_targets
117+ runs-on : ubuntu-24.04
118+
119+ concurrency :
120+ group : ${{ github.ref }}-${{ github.job }}
121+ cancel-in-progress : true
122+
123+ steps :
124+ - name : Checkout this repo
125+ uses : actions/checkout@v4
126+
127+ - name : Configure git user
128+ run : |
129+ git config user.name github-actions
130+ git config user.email [email protected] 131+
132+ - name : Download target artifacts to their right folders
133+ uses : actions/download-artifact@v4
134+ with :
135+ pattern : targets-*
136+ merge-multiple : true
137+ path : crypto/crypto-android/src/main/jniLibs/
138+
139+ - name : Download FFI bindings to their package
140+ uses : actions/download-artifact@v4
141+ with :
142+ name : ffi-bindings
143+ path : crypto/crypto-android/src/main/kotlin/
144+
145+ - name : Set up JDK 17
146+ uses : actions/setup-java@v4
147+ with :
148+ java-version : ' 17'
149+ distribution : ' temurin' # See 'Supported distributions' for available options
150+
151+ - name : Install android sdk
152+ uses : malinskiy/action-android/install-sdk@release/0.1.4
118153
119154 - name : Set up Python 3
120155 uses : actions/setup-python@v5
121156 with :
122157 python-version : ' 3.x'
123158
124- - name : Install dependencies
159+ - name : Install python dependencies
125160 run : |
126161 python -m pip install --upgrade pip
127162 pip install argparse
128163 pip install requests
129164
130- - name : Run publish script
165+ - name : Run release script
131166 env :
132- CRYPTO_SDK_VERSION : ${{ github.event.inputs.crypto-sdk-version }}
167+ OSSRH_USERNAME : ${{ secrets.OSSRH_USERNAME }}
168+ OSSRH_PASSWORD : ${{ secrets.OSSRH_PASSWORD }}
169+ SIGNING_KEY_ID : ${{ secrets.SIGNING_KEY_ID }}
170+ SIGNING_PASSWORD : ${{ secrets.SIGNING_PASSWORD }}
171+ SIGNING_KEY : ${{ secrets.SIGNING_KEY }}
172+ SONATYPE_STAGING_PROFILE_ID : ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
133173 GITHUB_API_TOKEN : ${{ secrets.GITHUB_TOKEN }}
134174 run : |
135- python3 ./scripts/release_crypto.py --version ${{ github.event.inputs.crypto-sdk-version }} --sdk_path ./rust-sdk
136-
137- # - name: Run test python
138- # run: |
139- # python3 ./main/scripts/hello_world.py
140- #
141- # - name: Run test python 2
142- # env:
143- # ANDROID_NDK: ${{ steps.install-ndk.outputs.ndk-path }}
144- # CRYPTO_SDK_VERSION: ${{ github.event.inputs.crypto-sdk-version }}
145- # GITHUB_API_TOKEN: ${{ secrets.API_TOKEN }}
146- # RUST_LOG: "trace"
147- # run: |
148- # python3 ./main/scripts/hello_world.py
149- #
150- # - name: Run publish script
151- # env:
152- # ANDROID_NDK: ${{ steps.install-ndk.outputs.ndk-path }}
153- # CRYPTO_SDK_VERSION: ${{ github.event.inputs.crypto-sdk-version }}
154- # GITHUB_API_TOKEN: ${{ secrets.API_TOKEN }}
155- # RUST_LOG: "trace"
156- # run: |
157- # python3 ./main/scripts/release.py --version ${{ github.event.inputs.crypto-sdk-version }} --sdk_path ./rust-sdk --module CRYPTO
175+ python3 ./scripts/publish_release.py --module CRYPTO --version ${{ github.event.inputs.sdk-version }} --linkable-ref ${{ needs.build_targets.outputs.linkable_ref }}
176+
177+ - name : Upload AAR results
178+ if : success() || failure()
179+ uses : actions/upload-artifact@v4
180+ with :
181+ name : sdk-android-release
182+ if-no-files-found : error
183+ path : ./sdk/sdk-android/build/**/*.aar
184+ retention-days : 7
0 commit comments