Release SDK Library (parallel) #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ] | |
# fail-fast: true | |
name: "Build Rust target: ${{ matrix.target }}" | |
runs-on: ubuntu-latest | |
concurrency: | |
group: ${{ github.ref }}-${{ github.job }}-${{ matrix.target }} | |
cancel-in-progress: true | |
steps: | |
- name: Checkout this repo | |
uses: actions/checkout@v3 | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
save-if: ${{ github.ref == 'refs/heads/main' || github.ref == 'main' }} | |
cache-on-failure: true | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
- name: Install android sdk | |
uses: malinskiy/action-android/install-sdk@release/0.1.2 | |
- name: Install android ndk | |
uses: nttld/setup-ndk@v1 | |
id: install-ndk | |
with: | |
ndk-version: r25c | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@nightly | |
- 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@v2 | |
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 | |
run: | | |
pushd ${{ env.RUST_SDK_PATH }} | |
echo LINKABLE_REF=$(git show-ref --verify refs/heads/${{ github.event.inputs.rust-checkout-ref }}) >> $GITHUB_OUTPUT | |
popd | |
- name: Upload target artifacts | |
if: success() || failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: targets | |
if-no-files-found: error | |
path: ./sdk/sdk-android/src/main/jniLibs/*/libmatrix_sdk_ffi.so | |
retention-days: 1 | |
- name: Upload FFI bindings | |
if: success() || failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ffi-bindings | |
if-no-files-found: error | |
path: ./sdk/sdk-android/src/main/kotlin/ | |
retention-days: 1 | |
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@v3 | |
- name: Download target artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: targets | |
path: targets | |
- name: Copy artifacts to their right folders | |
run: | | |
pushd targets | |
cp -R . ../sdk/sdk-android/src/main/jniLibs/ | |
popd | |
- name: Download FFI bindings | |
uses: actions/download-artifact@v3 | |
with: | |
name: ffi-bindings | |
path: ffi-bindings | |
- name: Copy FFI bindings to their package | |
run: | | |
pushd ffi-bindings | |
cp -R . ../sdk/sdk-android/src/main/kotlin/ | |
popd | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
- name: Install android sdk | |
uses: malinskiy/action-android/install-sdk@release/0.1.2 | |
- name: Set up Python 3 | |
uses: actions/setup-python@v2 | |
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 results # TODO: delete this | |
if: success() || failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: results | |
if-no-files-found: error | |
path: ./sdk/sdk-android/src/main/* | |
retention-days: 1 |