Skip to content

Release Crypto Library #48

Release Crypto Library

Release Crypto Library #48

name: Release Crypto Library
on:
workflow_dispatch:
inputs:
rust-checkout-ref:
description: 'The branch, tag or SHA to checkout on the rust sdk.'
required: true
default: 'main'
crypto-sdk-version:
description: 'The new version for the rust-crypto library.'
required: true
jobs:
build_native:
name: Build and generate crypto native libs
runs-on: macos-latest
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 }}
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: 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: 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: 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: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-05-09
# - 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/darwin-x86_64/bin/ar\" >> $HOME/.cargo/config.toml
# echo linker = \"${{ steps.install-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/darwin-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/darwin-x86_64/bin/ar\" >> $HOME/.cargo/config.toml
# echo linker = \"${{ steps.install-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/darwin-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/darwin-x86_64/bin/ar\" >> $HOME/.cargo/config.toml
# echo linker = \"${{ steps.install-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi30-clang\" >> $HOME/.cargo/config.toml
#
# cat $HOME/.cargo/config.toml
- 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: Configure gradle
uses: gradle/actions/setup-gradle@v3
- name: Run build script
env:
ANDROID_NDK: ${{ steps.install-ndk.outputs.ndk-path }}
run: ./scripts/build.sh -r -m crypto -p rust-sdk
- name: Find all .aar files
run: find . -name "*.aar"
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install argparse
pip install requests
- name: Run publish script
env:
CRYPTO_SDK_VERSION: ${{ github.event.inputs.crypto-sdk-version }}
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python3 ./scripts/release_crypto.py --version ${{ github.event.inputs.crypto-sdk-version }} --sdk_path ./rust-sdk
# - name: Run test python
# run: |
# python3 ./main/scripts/hello_world.py
#
# - name: Run test python 2
# env:
# ANDROID_NDK: ${{ steps.install-ndk.outputs.ndk-path }}
# CRYPTO_SDK_VERSION: ${{ github.event.inputs.crypto-sdk-version }}
# GITHUB_API_TOKEN: ${{ secrets.API_TOKEN }}
# RUST_LOG: "trace"
# run: |
# python3 ./main/scripts/hello_world.py
#
# - name: Run publish script
# env:
# ANDROID_NDK: ${{ steps.install-ndk.outputs.ndk-path }}
# CRYPTO_SDK_VERSION: ${{ github.event.inputs.crypto-sdk-version }}
# GITHUB_API_TOKEN: ${{ secrets.API_TOKEN }}
# RUST_LOG: "trace"
# run: |
# python3 ./main/scripts/release.py --version ${{ github.event.inputs.crypto-sdk-version }} --sdk_path ./rust-sdk --module CRYPTO