Skip to content

Commit

Permalink
Merge pull request #130 from breez/savage-ci-publishing
Browse files Browse the repository at this point in the history
Add CI workflows for publishing
  • Loading branch information
dangeross authored May 3, 2024
2 parents 2ebf8b4 + 2467850 commit 3f675ab
Show file tree
Hide file tree
Showing 15 changed files with 2,029 additions and 0 deletions.
164 changes: 164 additions & 0 deletions .github/workflows/build-bindings-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
name: Build bindings for Android
on:
workflow_dispatch:
inputs:
ref:
description: 'commit/tag/branch reference'
required: true
type: string
workflow_call:
inputs:
repository:
description: 'sdk repository, defaults to current repository'
required: false
type: string
ref:
description: 'commit/tag/branch reference'
required: true
type: string
use-dummy-binaries:
description: 'If true, creates dummy binaries rather than real binaries'
required: false
type: boolean
default: false

jobs:
build:
if: ${{ !inputs.use-dummy-binaries }}
runs-on: ubuntu-latest
name: build ${{ matrix.target }}
strategy:
matrix:
target: [
aarch64-linux-android,
armv7-linux-androideabi,
i686-linux-android,
x86_64-linux-android,
]
steps:
- name: checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
repository: ${{ inputs.repository || github.repository }}

- name: Install rust toolchain
run: |
rustup set auto-self-update disable
rustup toolchain install stable --profile minimal
rustup target add ${{ matrix.target }}
cargo install cargo-ndk
- uses: Swatinem/rust-cache@v2
with:
workspaces: lib

- name: Build bindings
working-directory: lib/bindings
run: |
cargo ndk -t ${{ matrix.target }} build --release
- name: Copy build output
run: |
mkdir -p dist
cp lib/target/${{ matrix.target }}/release/libbreez_liquid_sdk_bindings.so dist
- name: Copy libc++_shared
if: ${{ matrix.target == 'armv7-linux-androideabi'}}
run: cp $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/libc++_shared.so dist

- name: Copy libc++_shared
if: ${{ matrix.target != 'armv7-linux-androideabi'}}
run: cp $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/${{ matrix.target }}/libc++_shared.so dist

- name: Archive release
uses: actions/upload-artifact@v3
with:
name: bindings-${{ matrix.target }}
path: dist/*

jnilibs:
needs: build
runs-on: ubuntu-latest
name: build jniLibs
steps:
- uses: actions/download-artifact@v3
with:
name: bindings-aarch64-linux-android
path: arm64-v8a

- uses: actions/download-artifact@v3
with:
name: bindings-armv7-linux-androideabi
path: armeabi-v7a

- uses: actions/download-artifact@v3
with:
name: bindings-i686-linux-android
path: x86

- uses: actions/download-artifact@v3
with:
name: bindings-x86_64-linux-android
path: x86_64

- name: Archive jniLibs
uses: actions/upload-artifact@v3
with:
name: bindings-android-jniLibs
path: ./*

build-dummies:
if: ${{ inputs.use-dummy-binaries }}
runs-on: ubuntu-latest
name: build android dummies
strategy:
matrix:
target: [
aarch64-linux-android,
armv7-linux-androideabi,
i686-linux-android,
x86_64-linux-android,
]
steps:
- name: Build Android ${{ matrix.target }} dummy
run: |
touch libbreez_liquid_sdk_bindings.so
touch libc++_shared.so.so
- name: Upload dummy Android ${{ matrix.target }} artifact
uses: actions/upload-artifact@v3
with:
name: bindings-${{ matrix.target }}
path: ./*

jnilibs-dummy:
needs: build-dummies
runs-on: ubuntu-latest
name: build jniLibs dummy
steps:
- uses: actions/download-artifact@v3
with:
name: bindings-aarch64-linux-android
path: arm64-v8a

- uses: actions/download-artifact@v3
with:
name: bindings-armv7-linux-androideabi
path: armeabi-v7a

- uses: actions/download-artifact@v3
with:
name: bindings-i686-linux-android
path: x86

- uses: actions/download-artifact@v3
with:
name: bindings-x86_64-linux-android
path: x86_64

- name: Archive jniLibs
uses: actions/upload-artifact@v3
with:
name: bindings-android-jniLibs
path: ./*
116 changes: 116 additions & 0 deletions .github/workflows/build-bindings-darwin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Build bindings for Darwin
on:
workflow_dispatch:
inputs:
ref:
description: 'commit/tag/branch reference'
required: true
type: string
workflow_call:
inputs:
repository:
description: 'sdk repository, defaults to current repository'
required: false
type: string
ref:
description: 'commit/tag/branch reference'
required: true
type: string
use-dummy-binaries:
description: 'If true, creates dummy binaries rather than real binaries'
required: false
type: boolean
default: false

jobs:
build:
if: ${{ !inputs.use-dummy-binaries }}
runs-on: macOS-latest
name: build ${{ matrix.target }}
strategy:
matrix:
target: [
aarch64-apple-darwin,
x86_64-apple-darwin,
]
steps:
- name: checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
repository: ${{ inputs.repository || github.repository }}

- name: Install rust toolchain
run: |
rustup set auto-self-update disable
rustup toolchain install stable --profile minimal
rustup target add ${{ matrix.target }}
cargo install cargo-lipo
- uses: Swatinem/rust-cache@v2
with:
workspaces: lib

- name: Build bindings
working-directory: lib/bindings
run: cargo lipo --release --targets ${{ matrix.target }}

- name: Archive release
uses: actions/upload-artifact@v3
with:
name: bindings-${{ matrix.target }}
path: |
lib/target/${{ matrix.target }}/release/libbreez_liquid_sdk_bindings.dylib
lib/target/${{ matrix.target }}/release/libbreez_liquid_sdk_bindings.a
merge:
runs-on: macOS-latest
needs: build
name: build darwin-universal
steps:
- uses: actions/download-artifact@v3
with:
name: bindings-aarch64-apple-darwin
path: aarch64-apple-darwin

- uses: actions/download-artifact@v3
with:
name: bindings-x86_64-apple-darwin
path: x86_64-apple-darwin

- name: Build Darwin universal
run: |
mkdir -p darwin-universal
lipo -create -output darwin-universal/libbreez_liquid_sdk_bindings.dylib aarch64-apple-darwin/libbreez_liquid_sdk_bindings.dylib x86_64-apple-darwin/libbreez_liquid_sdk_bindings.dylib
lipo -create -output darwin-universal/libbreez_liquid_sdk_bindings.a aarch64-apple-darwin/libbreez_liquid_sdk_bindings.a x86_64-apple-darwin/libbreez_liquid_sdk_bindings.a
- name: Archive release
uses: actions/upload-artifact@v3
with:
name: bindings-darwin-universal
path: |
darwin-universal/libbreez_liquid_sdk_bindings.dylib
darwin-universal/libbreez_liquid_sdk_bindings.a
build-dummies:
if: ${{ inputs.use-dummy-binaries }}
runs-on: ubuntu-latest
name: build darwin dummies
strategy:
matrix:
target: [
aarch64-apple-darwin,
x86_64-apple-darwin,
darwin-universal
]
steps:
- name: Build dummy darwin ${{ matrix.target }}
run: |
touch libbreez_liquid_sdk_bindings.dylib
touch libbreez_liquid_sdk_bindings.a
- name: Upload dummy darwin ${{ matrix.target }} artifact
uses: actions/upload-artifact@v3
with:
name: bindings-${{ matrix.target }}
path: ./*
Loading

0 comments on commit 3f675ab

Please sign in to comment.