Skip to content

Release SDK Library (parallel) #108

Release SDK Library (parallel)

Release SDK Library (parallel) #108

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-latest
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]
- 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 android ndk
uses: nttld/setup-ndk@v1
id: install-ndk
with:
ndk-version: r25c
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
# This value should be updated to the `NIGHTLY` value in: https://github.com/matrix-org/matrix-rust-sdk/blob/main/xtask/src/main.rs
toolchain: nightly-2024-02-06
- 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-latest
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