diff --git a/.github/workflows/build-bindings-android.yml b/.github/workflows/build-bindings-android.yml new file mode 100644 index 000000000..881d1901d --- /dev/null +++ b/.github/workflows/build-bindings-android.yml @@ -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: ./* \ No newline at end of file diff --git a/.github/workflows/build-bindings-darwin.yml b/.github/workflows/build-bindings-darwin.yml new file mode 100644 index 000000000..51da15155 --- /dev/null +++ b/.github/workflows/build-bindings-darwin.yml @@ -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: ./* \ No newline at end of file diff --git a/.github/workflows/build-bindings-ios.yml b/.github/workflows/build-bindings-ios.yml new file mode 100644 index 000000000..89f891e2c --- /dev/null +++ b/.github/workflows/build-bindings-ios.yml @@ -0,0 +1,133 @@ +name: Build bindings for iOS +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-ios, + x86_64-apple-ios, + aarch64-apple-ios-sim, + ] + 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 }} + + - uses: Swatinem/rust-cache@v2 + with: + workspaces: lib + + - name: Install xcode + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + + - name: Build bindings + working-directory: lib/bindings + run: cargo build --release --target ${{ 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.a + + merge: + runs-on: macOS-latest + needs: build + name: build ios-universal + steps: + - uses: actions/download-artifact@v3 + with: + name: bindings-aarch64-apple-ios + path: aarch64-apple-ios + + - uses: actions/download-artifact@v3 + with: + name: bindings-x86_64-apple-ios + path: x86_64-apple-ios + + - uses: actions/download-artifact@v3 + with: + name: bindings-aarch64-apple-ios-sim + path: aarch64-apple-ios-sim + + - name: Build ios-universal + run: | + mkdir -p ios-universal + lipo -create -output ios-universal/libbreez_liquid_sdk_bindings.a aarch64-apple-ios/libbreez_liquid_sdk_bindings.a x86_64-apple-ios/libbreez_liquid_sdk_bindings.a + + - name: Build ios-universal-sim + run: | + mkdir -p ios-universal-sim + lipo -create -output ios-universal-sim/libbreez_liquid_sdk_bindings.a aarch64-apple-ios-sim/libbreez_liquid_sdk_bindings.a x86_64-apple-ios/libbreez_liquid_sdk_bindings.a + + - name: Archive ios-universal + uses: actions/upload-artifact@v3 + with: + name: bindings-ios-universal + path: ios-universal/libbreez_liquid_sdk_bindings.a + + - name: Archive ios-universal-sim + uses: actions/upload-artifact@v3 + with: + name: bindings-ios-universal-sim + path: ios-universal-sim/libbreez_liquid_sdk_bindings.a + + build-dummies: + if: ${{ inputs.use-dummy-binaries }} + runs-on: ubuntu-latest + name: build ios dummies + strategy: + matrix: + target: [ + aarch64-apple-ios, + x86_64-apple-ios, + aarch64-apple-ios-sim, + ios-universal, + ios-universal-sim, + ] + steps: + - name: Build dummy ios ${{ matrix.target }} + run: | + touch libbreez_liquid_sdk_bindings.a + + - name: Upload dummy ios ${{ matrix.target }} artifact + uses: actions/upload-artifact@v3 + with: + name: bindings-${{ matrix.target }} + path: ./* diff --git a/.github/workflows/build-bindings-linux.yml b/.github/workflows/build-bindings-linux.yml new file mode 100644 index 000000000..0b39a5061 --- /dev/null +++ b/.github/workflows/build-bindings-linux.yml @@ -0,0 +1,97 @@ +name: Build bindings for Linux +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-20.04 + name: build ${{ matrix.target }} + strategy: + matrix: + target: [ + aarch64-unknown-linux-gnu, + x86_64-unknown-linux-gnu, + ] + 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 }} + + - name: Install gcc-aarch64-linux-gnu + if: matrix.target == 'aarch64-unknown-linux-gnu' + run: | + sudo apt-get update -y + sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu + + - name: Install gcc-x86-64-linux-gnu + if: matrix.target == 'x86_64-unknown-linux-gnu' + run: | + sudo apt-get update -y + sudo apt-get install -y gcc-x86-64-linux-gnu g++-x86-64-linux-gnu + + - uses: Swatinem/rust-cache@v2 + with: + workspaces: lib + + - name: Build bindings + working-directory: lib/bindings + env: + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: /usr/bin/aarch64-linux-gnu-gcc + CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER: /usr/bin/x86_64-linux-gnu-gcc + run: cargo build --release --target ${{ 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.so + + build-dummies: + if: ${{ inputs.use-dummy-binaries }} + runs-on: ubuntu-latest + name: build linux dummies + strategy: + matrix: + target: [ + aarch64-unknown-linux-gnu, + x86_64-unknown-linux-gnu, + ] + steps: + - name: Build dummy linux ${{ matrix.target }} + run: | + touch libbreez_liquid_sdk_bindings.so + + - name: Upload dummy linux ${{ matrix.target }} artifact + uses: actions/upload-artifact@v3 + with: + name: bindings-${{ matrix.target }} + path: ./* \ No newline at end of file diff --git a/.github/workflows/build-bindings-windows.yml b/.github/workflows/build-bindings-windows.yml new file mode 100644 index 000000000..6517946d6 --- /dev/null +++ b/.github/workflows/build-bindings-windows.yml @@ -0,0 +1,82 @@ +name: Build bindings for Windows +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: windows-latest + name: build ${{ matrix.target }} + strategy: + matrix: + target: [ + x86_64-pc-windows-msvc, + i686-pc-windows-msvc, + ] + 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 }} + + - uses: Swatinem/rust-cache@v2 + with: + workspaces: lib + + - name: Build bindings + working-directory: lib/bindings + run: cargo build --release --target ${{ matrix.target }} + + - name: Archive release + uses: actions/upload-artifact@v3 + with: + name: bindings-${{ matrix.target }} + path: lib/target/${{ matrix.target }}/release/breez_liquid_sdk_bindings.dll + + build-dummies: + if: ${{ inputs.use-dummy-binaries }} + runs-on: ubuntu-latest + name: build windows dummies + strategy: + matrix: + target: [ + x86_64-pc-windows-msvc, + i686-pc-windows-msvc, + ] + steps: + - name: Build dummy windows ${{ matrix.target }} + run: | + touch breez_liquid_sdk_bindings.dll + + - name: Upload dummy windows ${{ matrix.target }} artifact + uses: actions/upload-artifact@v3 + with: + name: bindings-${{ matrix.target }} + path: ./* \ No newline at end of file diff --git a/.github/workflows/build-language-bindings.yml b/.github/workflows/build-language-bindings.yml new file mode 100644 index 000000000..3491839d0 --- /dev/null +++ b/.github/workflows/build-language-bindings.yml @@ -0,0 +1,148 @@ +name: Build Language bindings +on: + workflow_dispatch: + inputs: + ref: + description: 'commit/tag/branch reference' + required: true + type: string + kotlin: + required: false + type: boolean + default: false + swift: + required: false + type: boolean + default: false + python: + required: false + type: boolean + default: false + csharp: + required: false + type: boolean + default: false + golang: + required: false + type: boolean + default: false + 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 + kotlin: + required: false + type: boolean + default: false + swift: + required: false + type: boolean + default: false + python: + required: false + type: boolean + default: false + csharp: + required: false + type: boolean + default: false + golang: + required: false + type: boolean + default: false + +jobs: + build-language-bindings: + runs-on: ubuntu-latest + steps: + - name: Checkout breez-liquid-sdk repo + uses: actions/checkout@v3 + with: + repository: ${{ inputs.repository || github.repository }} + ref: ${{ inputs.ref || github.sha }} + + - name: Install rust + run: | + rustup set auto-self-update disable + rustup toolchain install stable --profile minimal + + - name: Build Kotlin binding + if: ${{ inputs.kotlin }} + working-directory: lib/bindings + run: | + cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/breez_liquid_sdk.udl --language kotlin -o ffi/kotlin + + - name: Archive Kotlin binding + if: ${{ inputs.kotlin }} + uses: actions/upload-artifact@v3 + with: + name: bindings-kotlin + path: lib/bindings/ffi/kotlin/breez_liquid_sdk/breez_liquid_sdk.kt + + - name: Archive Kotlin multiplatform binding + if: ${{ inputs.kotlin }} + uses: actions/upload-artifact@v3 + with: + name: bindings-kotlin-multiplatform + path: lib/bindings/ffi/kmp/* + + - name: Build Swift binding + if: ${{ inputs.swift }} + working-directory: lib/bindings + run: | + cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/breez_liquid_sdk.udl --no-format --language swift --out-dir bindings-swift/Sources/BreezLiquidSDK + mv bindings-swift/Sources/BreezLiquidSDK/breez_liquid_sdk.swift bindings-swift/Sources/BreezLiquidSDK/BreezLiquidSDK.swift + + - name: Archive Swift binding + if: ${{ inputs.swift }} + uses: actions/upload-artifact@v3 + with: + name: bindings-swift + path: lib/bindings/bindings-swift/Sources/BreezLiquidSDK/* + + - name: Build Python binding + if: ${{ inputs.python }} + working-directory: lib/bindings + run: | + cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/breez_liquid_sdk.udl --language python -o ffi/python + + - name: Archive Python binding + if: ${{ inputs.python }} + uses: actions/upload-artifact@v3 + with: + name: bindings-python + path: lib/bindings/ffi/python/breez_liquid_sdk.py + +# - name: Build C# binding +# if: ${{ inputs.csharp }} +# working-directory: lib/bindings +# run: | +# cargo install uniffi-bindgen-cs --git https://github.com/breez/uniffi-bindgen-cs --branch namespace +# uniffi-bindgen-cs src/breez_liquid_sdk.udl -o ffi/csharp -c ./uniffi.toml +# +# - name: Archive C# binding +# if: ${{ inputs.csharp }} +# uses: actions/upload-artifact@v3 +# with: +# name: bindings-csharp +# path: lib/bindings/ffi/csharp/breez_liquid_sdk.cs +# +# - name: Build golang binding +# if: ${{ inputs.golang }} +# working-directory: lib/bindings +# run: | +# cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.1.5+v0.23.0 +# uniffi-bindgen-go src/breez_liquid_sdk.udl -o ffi/golang -c ./uniffi.toml +# +# - name: Archive golang binding +# if: ${{ inputs.golang }} +# uses: actions/upload-artifact@v3 +# with: +# name: bindings-golang +# path: lib/bindings/ffi/golang/breez/breez_liquid_sdk/breez_liquid_sdk.* diff --git a/.github/workflows/publish-all-platforms.yml b/.github/workflows/publish-all-platforms.yml new file mode 100644 index 000000000..2b73ae9d8 --- /dev/null +++ b/.github/workflows/publish-all-platforms.yml @@ -0,0 +1,313 @@ +name: Publish all packages +on: + workflow_dispatch: + inputs: + ref: + description: 'commit/tag/branch reference' + required: true + type: string + package-version: + description: 'version for the published package(s) (MAJOR.MINOR.BUILD)' + required: true + type: string + packages-to-publish: + description: 'array of packages to publish (remove what you do not want)' + required: true + type: string + default: '["csharp", "golang", "maven", "kotlin-multiplatform", "flutter", "react-native", "python", "swift"]' + csharp-ref: + description: 'optional commit/tag/branch reference for the C# project. Defaults to ref.' + required: false + type: string + use-dummy-binaries: + description: 'boolean indicating whether to use dummies for the sdk binaries. Default = false.' + required: false + type: boolean + default: false + publish: + description: 'boolean indicating whether packages should be published. true to publish. false to build only. Default = false.' + required: false + type: boolean + default: false + 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 + package-version: + description: 'version for the published package(s) (MAJOR.MINOR.BUILD)' + required: true + type: string + packages-to-publish: + description: 'array of packages to publish (remove what you do not want)' + required: true + type: string + default: '["csharp", "golang", "maven", "kotlin-multiplatform", "flutter", "react-native", "python", "swift"]' + csharp-ref: + description: 'optional commit/tag/branch reference for the C# project. Defaults to ref.' + required: false + type: string + use-dummy-binaries: + description: 'boolean indicating whether to use dummies for the sdk binaries. Default = false.' + required: false + type: boolean + default: false + +jobs: + pre-setup: + name: Pre-setup + runs-on: ubuntu-latest + outputs: + # These outputs mimic the inputs for the workflow. + # Their only purpose is to be able to test this workflow if you make + # changes that you won't want to commit to main yet. + # You can set these values manually, to test how the CI behaves with + # certain inputs. + repository: ${{ inputs.repository || github.repository }} + ref: ${{ inputs.ref || github.sha }} + csharp-package-version: ${{ (contains(fromJSON(inputs.packages-to-publish), 'csharp') && inputs.package-version) || '' }} + csharp-ref: ${{ inputs.csharp-ref || inputs.ref || github.sha }} + golang-package-version: ${{ (contains(fromJSON(inputs.packages-to-publish), 'golang') && inputs.package-version) || '' }} + maven-package-version: ${{ (contains(fromJSON(inputs.packages-to-publish), 'maven') && inputs.package-version) || ''}} + kotlin-multiplatform-package-version: ${{ (contains(fromJSON(inputs.packages-to-publish), 'kotlin-multiplatform') && inputs.package-version) || '' }} + flutter-package-version: ${{ (contains(fromJSON(inputs.packages-to-publish), 'flutter') && inputs.package-version) || '' }} + react-native-package-version: ${{ (contains(fromJSON(inputs.packages-to-publish), 'react-native') && inputs.package-version) || '' }} + python-package-version: ${{ (contains(fromJSON(inputs.packages-to-publish), 'python') && inputs.package-version) || '' }} + swift-package-version: ${{ (contains(fromJSON(inputs.packages-to-publish), 'swift') && inputs.package-version) || '' }} + use-dummy-binaries: ${{ inputs.use-dummy-binaries }} + publish: ${{ inputs.publish }} + steps: + - run: echo "set pre-setup output variables" + + setup: + name: Setup + needs: pre-setup + runs-on: ubuntu-latest + outputs: + # Careful, a boolean input is not a boolean output. A boolean input is + # actually a boolean, but these outputs are strings. All the boolean + # checks in this file have the format `boolean == 'true'`. So feel free + # to set these variables here to `true` or `false` + # (e.g. bindings-windows: true) if you want to test something. + repository: ${{ needs.pre-setup.outputs.repository }} + bindings-windows: ${{ !!needs.pre-setup.outputs.csharp-package-version || !!needs.pre-setup.outputs.golang-package-version || !!needs.pre-setup.outputs.python-package-version }} + bindings-darwin: ${{ !!needs.pre-setup.outputs.csharp-package-version || !!needs.pre-setup.outputs.golang-package-version || !!needs.pre-setup.outputs.python-package-version || !!needs.pre-setup.outputs.swift-package-version }} + bindings-linux: ${{ !!needs.pre-setup.outputs.csharp-package-version || !!needs.pre-setup.outputs.golang-package-version || !!needs.pre-setup.outputs.python-package-version }} + bindings-android: ${{ !!needs.pre-setup.outputs.kotlin-multiplatform-package-version || !!needs.pre-setup.outputs.maven-package-version || !!needs.pre-setup.outputs.golang-package-version }} + bindings-ios: ${{ !!needs.pre-setup.outputs.kotlin-multiplatform-package-version || !!needs.pre-setup.outputs.maven-package-version || !!needs.pre-setup.outputs.swift-package-version }} + kotlin: ${{ !!needs.pre-setup.outputs.kotlin-multiplatform-package-version || !!needs.pre-setup.outputs.maven-package-version || !!needs.pre-setup.outputs.flutter-package-version }} + swift: ${{ !!needs.pre-setup.outputs.flutter-package-version || !!needs.pre-setup.outputs.swift-package-version }} + python: ${{ !!needs.pre-setup.outputs.python-package-version }} + csharp: ${{ !!needs.pre-setup.outputs.csharp-package-version }} + golang: ${{ !!needs.pre-setup.outputs.golang-package-version }} + maven: ${{ !!needs.pre-setup.outputs.maven-package-version }} + kotlin-multiplatform: ${{ !!needs.pre-setup.outputs.kotlin-multiplatform-package-version }} + flutter: ${{ !!needs.pre-setup.outputs.flutter-package-version }} + react-native: ${{ !!needs.pre-setup.outputs.react-native-package-version }} + ref: ${{ needs.pre-setup.outputs.ref }} + csharp-package-version: ${{ needs.pre-setup.outputs.csharp-package-version || '0.0.2' }} + csharp-ref: ${{ needs.pre-setup.outputs.csharp-ref }} + golang-package-version: ${{ needs.pre-setup.outputs.golang-package-version || '0.0.2' }} + maven-package-version: ${{ needs.pre-setup.outputs.maven-package-version || '0.0.2' }} + kotlin-multiplatform-package-version: ${{ needs.pre-setup.outputs.kotlin-multiplatform-package-version || '0.0.2' }} + flutter-package-version: ${{ needs.pre-setup.outputs.flutter-package-version || '0.0.2' }} + react-native-package-version: ${{ needs.pre-setup.outputs.react-native-package-version || '0.0.2' }} + python-package-version: ${{ needs.pre-setup.outputs.python-package-version || '0.0.2' }} + swift-package-version: ${{ needs.pre-setup.outputs.swift-package-version || '0.0.2' }} + publish: ${{ needs.pre-setup.outputs.publish }} + use-dummy-binaries: ${{ needs.pre-setup.outputs.use-dummy-binaries }} + steps: + - run: echo "set setup output variables" + + build-bindings-windows: + needs: setup + if: ${{ needs.setup.outputs.bindings-windows == 'true' }} + uses: ./.github/workflows/build-bindings-windows.yml + with: + repository: ${{ needs.setup.outputs.repository }} + ref: ${{ needs.setup.outputs.ref }} + use-dummy-binaries: ${{ needs.setup.outputs.use-dummy-binaries == 'true' }} + + build-bindings-darwin: + needs: setup + if: ${{ needs.setup.outputs.bindings-darwin == 'true' }} + uses: ./.github/workflows/build-bindings-darwin.yml + with: + repository: ${{ needs.setup.outputs.repository }} + ref: ${{ needs.setup.outputs.ref }} + use-dummy-binaries: ${{ needs.setup.outputs.use-dummy-binaries == 'true' }} + + build-bindings-linux: + needs: setup + if: ${{ needs.setup.outputs.bindings-linux == 'true' }} + uses: ./.github/workflows/build-bindings-linux.yml + with: + repository: ${{ needs.setup.outputs.repository }} + ref: ${{ needs.setup.outputs.ref }} + use-dummy-binaries: ${{ needs.setup.outputs.use-dummy-binaries == 'true' }} + + build-bindings-android: + needs: setup + if: ${{ needs.setup.outputs.bindings-android == 'true' }} + uses: ./.github/workflows/build-bindings-android.yml + with: + repository: ${{ needs.setup.outputs.repository }} + ref: ${{ needs.setup.outputs.ref }} + use-dummy-binaries: ${{ needs.setup.outputs.use-dummy-binaries == 'true' }} + + build-bindings-ios: + needs: setup + if: ${{ needs.setup.outputs.bindings-ios == 'true' }} + uses: ./.github/workflows/build-bindings-ios.yml + with: + repository: ${{ needs.setup.outputs.repository }} + ref: ${{ needs.setup.outputs.ref }} + use-dummy-binaries: ${{ needs.setup.outputs.use-dummy-binaries == 'true' }} + + build-language-bindings: + needs: setup + uses: ./.github/workflows/build-language-bindings.yml + with: + repository: ${{ needs.setup.outputs.repository }} + ref: ${{ needs.setup.outputs.ref }} + kotlin: ${{ needs.setup.outputs.kotlin == 'true'}} + csharp: ${{ needs.setup.outputs.csharp == 'true'}} + golang: ${{ needs.setup.outputs.golang == 'true'}} + python: ${{ needs.setup.outputs.python == 'true'}} + swift: ${{ needs.setup.outputs.swift == 'true'}} + +# publish-csharp: +# needs: +# - setup +# - build-bindings-windows +# - build-bindings-darwin +# - build-bindings-linux +# - build-language-bindings +# if: ${{ needs.setup.outputs.csharp == 'true' }} +# uses: ./.github/workflows/publish-csharp.yml +# with: +# repository: ${{ needs.setup.outputs.repository }} +# ref: ${{ needs.setup.outputs.csharp-ref }} +# package-version: ${{ needs.setup.outputs.csharp-package-version }} +# publish: ${{ needs.setup.outputs.publish == 'true' }} +# skip-tests: true +# secrets: +# NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} +# +# publish-golang: +# needs: +# - setup +# - build-bindings-android +# - build-bindings-windows +# - build-bindings-darwin +# - build-bindings-linux +# - build-language-bindings +# if: ${{ needs.setup.outputs.golang == 'true' }} +# uses: ./.github/workflows/publish-golang.yml +# with: +# ref: ${{ needs.setup.outputs.ref }} +# package-version: ${{ needs.setup.outputs.golang-package-version }} +# publish: ${{ needs.setup.outputs.publish == 'true' }} +# secrets: +# REPO_SSH_KEY: ${{ secrets.REPO_SSH_KEY }} + + publish-maven: + needs: + - setup + - build-bindings-android + - build-language-bindings + if: ${{ needs.setup.outputs.maven == 'true' }} + uses: ./.github/workflows/publish-android.yml + with: + repository: ${{ needs.setup.outputs.repository }} + ref: ${{ needs.setup.outputs.ref }} + package-version: ${{ needs.setup.outputs.maven-package-version }} + publish: ${{ needs.setup.outputs.publish == 'true' }} + secrets: + BREEZ_MVN_USERNAME: ${{ secrets.BREEZ_MVN_USERNAME }} + BREEZ_MVN_PASSWORD: ${{ secrets.BREEZ_MVN_PASSWORD }} + + publish-kotlin-multiplatform: + needs: + - setup + - build-bindings-android + - build-bindings-ios + - build-language-bindings + if: ${{ needs.setup.outputs.kotlin-multiplatform == 'true' }} + uses: ./.github/workflows/publish-kotlin-multiplatform.yml + with: + repository: ${{ needs.setup.outputs.repository }} + ref: ${{ needs.setup.outputs.ref }} + package-version: ${{ needs.setup.outputs.kotlin-multiplatform-package-version }} + publish: ${{ needs.setup.outputs.publish == 'true' }} + secrets: + BREEZ_MVN_USERNAME: ${{ secrets.BREEZ_MVN_USERNAME }} + BREEZ_MVN_PASSWORD: ${{ secrets.BREEZ_MVN_PASSWORD }} + +# publish-flutter: +# needs: +# - setup +# - build-language-bindings +# if: ${{ needs.setup.outputs.flutter == 'true' }} +# uses: ./.github/workflows/publish-flutter.yml +# with: +# repository: ${{ needs.setup.outputs.repository }} +# ref: ${{ needs.setup.outputs.ref }} +# package-version: ${{ needs.setup.outputs.flutter-package-version }} +# publish: ${{ needs.setup.outputs.publish == 'true' }} +# secrets: +# REPO_SSH_KEY: ${{ secrets.REPO_SSH_KEY }} + + # react native version x.y.z will at runtime require + # ios and android packages x.y.z being published already. + publish-react-native: + needs: + - setup + if: ${{ needs.setup.outputs.react-native == 'true' }} + uses: ./.github/workflows/publish-react-native.yml + with: + repository: ${{ needs.setup.outputs.repository }} + ref: ${{ needs.setup.outputs.ref }} + package-version: ${{ needs.setup.outputs.react-native-package-version }} + publish: ${{ needs.setup.outputs.publish == 'true' }} + secrets: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + publish-python: + needs: + - setup + - build-bindings-darwin + - build-bindings-linux + - build-bindings-windows + - build-language-bindings + if: ${{ needs.setup.outputs.python == 'true' }} + uses: ./.github/workflows/publish-python.yml + with: + repository: ${{ needs.setup.outputs.repository }} + ref: ${{ needs.setup.outputs.ref }} + package-version: ${{ needs.setup.outputs.python-package-version }} + publish: ${{ needs.setup.outputs.publish == 'true' }} + secrets: + PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + + publish-swift: + needs: + - setup + - build-bindings-darwin + - build-bindings-ios + - build-language-bindings + if: ${{ needs.setup.outputs.swift == 'true' }} + uses: ./.github/workflows/publish-swift.yml + with: + repository: ${{ needs.setup.outputs.repository }} + ref: ${{ needs.setup.outputs.ref }} + package-version: ${{ needs.setup.outputs.swift-package-version }} + publish: ${{ needs.setup.outputs.publish == 'true' }} + secrets: + REPO_SSH_KEY: ${{ secrets.REPO_SSH_KEY }} + COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} diff --git a/.github/workflows/publish-android.yml b/.github/workflows/publish-android.yml new file mode 100644 index 000000000..70939a105 --- /dev/null +++ b/.github/workflows/publish-android.yml @@ -0,0 +1,85 @@ +name: Publish Android Bindings +on: + 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 + package-version: + description: 'version for the gradle library (MAJOR.MINOR.BUILD)' + required: true + type: string + publish: + description: 'value indicating whether to publish to maven.' + required: true + type: boolean + default: false + secrets: + BREEZ_MVN_USERNAME: + description: 'username for gradlew publish' + required: true + BREEZ_MVN_PASSWORD: + description: 'password for gradlew publish' + required: true + +jobs: + build-package: + runs-on: ubuntu-latest + steps: + - name: Checkout breez-liquid-sdk repo + uses: actions/checkout@v3 + with: + repository: ${{ inputs.repository || github.repository }} + ref: ${{ inputs.ref || github.sha }} + + - uses: actions/download-artifact@v3 + with: + name: bindings-android-jniLibs + path: lib/bindings/bindings-android/lib/src/main/jniLibs + + - uses: actions/download-artifact@v3 + with: + name: bindings-kotlin + path: lib/bindings/bindings-android/lib/src/main/kotlin + + - name: Build Android project + working-directory: lib/bindings/bindings-android + env: + ORG_GRADLE_PROJECT_libraryVersion: ${{ inputs.package-version || '0.0.1' }} + run: ./gradlew assemble + + - name: Archive aar + uses: actions/upload-artifact@v3 + with: + name: android-release.aar + path: lib/bindings/bindings-android/lib/build/outputs/aar/lib-release.aar + + - name: Publish artifacts + if: ${{ inputs.publish }} + working-directory: lib/bindings/bindings-android + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BREEZ_MVN_USERNAME: ${{ secrets.BREEZ_MVN_USERNAME }} + BREEZ_MVN_PASSWORD: ${{ secrets.BREEZ_MVN_PASSWORD }} + run: | + ./gradlew publish -PlibraryVersion=${{ inputs.package-version }} -PbreezReposiliteUsername="$BREEZ_MVN_USERNAME" -PbreezReposilitePassword="$BREEZ_MVN_PASSWORD" + + - name: Trigger Jitpack build + if: ${{ inputs.publish }} + shell: bash + run: | + # Jitpack only makes artifacts avaiable when someone requests them. + # Here we trick Jitpack into thinking we're already requesting the newly built package + # to make sure it is available right away for anyone that needs it later. + # We're waiting for at most 60s before triggering the Jitpack build to give our Maven repo + # some time to process the just uploaded files (the Jitpack build is dependent upon them being available). + # If anything fails here, we'll still finish sucessfully as this is an optional optimization. + timeout 60 bash -c 'while [[ "$(curl --output /dev/null --silent --head --write-out ''%{http_code}'' https://mvn.breez.technology/releases/breez_liquid_sdk/bindings-android/${{ inputs.package-version }}/bindings-android-${{ inputs.package-version }}.pom)" != "200" ]]; do echo "Waiting for package to be published on mvn.breez.technology..." && sleep 5; done && echo "Package found."' || echo "Package not found." && true + echo "Attempting to trigger Jitpack build..." + curl -s -m 30 https://jitpack.io/api/builds/com.github.breez/breez-liquid-sdk/${{ inputs.package-version }} || true + echo "Done" diff --git a/.github/workflows/publish-csharp.yml b/.github/workflows/publish-csharp.yml new file mode 100644 index 000000000..1c44541b2 --- /dev/null +++ b/.github/workflows/publish-csharp.yml @@ -0,0 +1,150 @@ +name: Publish C# Bindings +on: + 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 + package-version: + description: 'version for the nuget package (MAJOR.MINOR.BUILD)' + required: true + type: string + skip-tests: + description: 'value indicating whether to skip the tests' + required: false + default: false + type: boolean + publish: + description: 'value indicating whether to publish to nuget.' + required: true + type: boolean + default: false + secrets: + NUGET_API_KEY: + description: 'api key to authenticate the nuget publisher to nuget.org' + required: true + +jobs: + build-package: + runs-on: ubuntu-latest + steps: + - name: Checkout breez-liquid-sdk repo + uses: actions/checkout@v3 + with: + repository: ${{ inputs.repository || github.repository }} + ref: ${{ inputs.ref || github.sha }} + + - uses: actions/download-artifact@v3 + with: + name: bindings-csharp + path: lib/bindings/bindings-csharp/src + + - uses: actions/download-artifact@v3 + with: + name: bindings-aarch64-apple-darwin + path: lib/bindings/bindings-csharp/src/runtimes/osx-arm64/native + + - uses: actions/download-artifact@v3 + with: + name: bindings-x86_64-apple-darwin + path: lib/bindings/bindings-csharp/src/runtimes/osx-x64/native + + - uses: actions/download-artifact@v3 + with: + name: bindings-aarch64-unknown-linux-gnu + path: lib/bindings/bindings-csharp/src/runtimes/linux-arm64/native + + - uses: actions/download-artifact@v3 + with: + name: bindings-x86_64-unknown-linux-gnu + path: lib/bindings/bindings-csharp/src/runtimes/linux-x64/native + + - uses: actions/download-artifact@v3 + with: + name: bindings-x86_64-pc-windows-msvc + path: lib/bindings/bindings-csharp/src/runtimes/win-x64/native + + - uses: actions/download-artifact@v3 + with: + name: bindings-i686-pc-windows-msvc + path: lib/bindings/bindings-csharp/src/runtimes/win-x86/native + + - name: Update package version + if: ${{ inputs.package-version }} + working-directory: lib/bindings/bindings-csharp/src + run: sed -i.bak -e 's/.*<\/Version>/${{ inputs.package-version }}<\/Version>/' Breez.Liquid.Sdk.csproj + + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '6.0.x' + + - name: Build the project + working-directory: lib/bindings/bindings-csharp/src + run: dotnet build Breez.Liquid.Sdk.csproj + + - name: Create the package + working-directory: lib/bindings/bindings-csharp/src + run: dotnet pack --configuration Release Breez.Liquid.Sdk.csproj + + - name: Archive the package + uses: actions/upload-artifact@v3 + with: + name: Breez.Liquid.Sdk.${{ inputs.package-version || '0.0.1' }}.nupkg + path: lib/bindings/bindings-csharp/src/bin/Release/Breez.Liquid.Sdk.*.nupkg + + test-package: + needs: build-package + runs-on: ${{ matrix.target }} + strategy: + matrix: + target: [ + windows-latest, + ubuntu-latest, + ubuntu-20.04, + macOS-latest, + ] + steps: + - name: Checkout breez-liquid-sdk repo + if: ${{ !inputs.skip-tests }} + uses: actions/checkout@v3 + with: + repository: ${{ inputs.repository || github.repository }} + ref: ${{ inputs.ref || github.sha }} + + - uses: actions/download-artifact@v3 + if: ${{ !inputs.skip-tests }} + with: + name: Breez.Liquid.Sdk.${{ inputs.package-version || '0.0.1' }}.nupkg + path: lib/bindings/bindings-csharp/src/bin/Release + + - name: Setup dotnet + if: ${{ !inputs.skip-tests }} + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '7.0.x' + + - name: test package + if: ${{ !inputs.skip-tests }} + working-directory: lib/bindings/bindings-csharp/test + run: dotnet run + + publish-package: + needs: test-package + if: ${{ inputs.publish }} + runs-on: ubuntu-latest + steps: + - name: Download archived package + uses: actions/download-artifact@v3 + with: + name: Breez.Liquid.Sdk.${{ inputs.package-version }}.nupkg + + - name: Publish to nuget.org + env: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + run: dotnet nuget push Breez.Liquid.Sdk.${{ inputs.package-version }}.nupkg --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json diff --git a/.github/workflows/publish-flutter.yml b/.github/workflows/publish-flutter.yml new file mode 100644 index 000000000..d0120983e --- /dev/null +++ b/.github/workflows/publish-flutter.yml @@ -0,0 +1,103 @@ +name: Publish Flutter Package +on: + 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 + package-version: + description: 'version for the flutter package (MAJOR.MINOR.BUILD) (no v prefix)' + required: true + type: string + publish: + description: 'value indicating whether to commit/tag a release.' + required: true + type: boolean + default: true + secrets: + REPO_SSH_KEY: + description: 'ssh key to commit to the breez-liquid-sdk-flutter repository' + required: true + +jobs: + build-tag-release: + runs-on: ubuntu-latest + steps: + - name: Checkout breez-liquid-sdk-flutter repo + uses: actions/checkout@v3 + with: + repository: breez/breez-liquid-sdk-flutter + ssh-key: ${{ secrets.REPO_SSH_KEY }} + fetch-depth: 0 + path: dist + + - name: Checkout breez-liquid-sdk repo + uses: actions/checkout@v3 + with: + repository: ${{ inputs.repository || github.repository }} + ref: ${{ inputs.ref || github.sha }} + path: build + + - uses: subosito/flutter-action@v2 + with: + channel: 'stable' + + - name: Copy package files + working-directory: dist + run: | + rm -r ios + rm -r android + rm -r lib + cp -r ../build/packages/flutter/ios . + mv ios/breez_liquid_sdk.podspec.production ios/breez_liquid_sdk.podspec + cp -r ../build/packages/flutter/android . + mv android/build.gradle.production android/build.gradle + cp -r ../build/packages/flutter/lib . + cp ../build/packages/flutter/pubspec.yaml . + cp ../build/packages/flutter/pubspec.lock . + + - name: Copy docs + working-directory: dist + run: | + cp ../build/packages/flutter/README.pub.md README.md || true + cp ../build/packages/flutter/CHANGELOG.md . || true + + - uses: actions/download-artifact@v3 + with: + name: bindings-swift + path: dist/ios/bindings-swift/Sources/BreezLiquidSDK/ + + - name: Set package version + working-directory: dist + run: | + sed -i.bak -e 's/version:.*/version: ${{ inputs.package-version }}/' pubspec.yaml + sed -i.bak -e "s/^version .*/version '${{ inputs.package-version }}'/" android/build.gradle + sed -i.bak -e "s/^tag_version = .*/tag_version = '${{ inputs.package-version }}'/" ios/breez_liquid_sdk.podspec + rm pubspec.yaml.bak + rm android/build.gradle.bak + rm ios/breez_liquid_sdk.podspec.bak + + - name: Archive flutter release + uses: actions/upload-artifact@v3 + with: + name: breez-liquid-sdk-flutter-${{ inputs.package-version || github.sha }} + path: | + dist/* + !dist/.git + + - name: Tag the Flutter package + working-directory: dist + if: ${{ inputs.publish }} + run: | + git config --global user.email github-actions@github.com + git config --global user.name github-actions + git add . + git commit -m "Update Breez SDK Flutter package to version v${{ inputs.package-version }}" + git push + git tag v${{ inputs.package-version }} -m "v${{ inputs.package-version }}" + git push --tags diff --git a/.github/workflows/publish-golang.yml b/.github/workflows/publish-golang.yml new file mode 100644 index 000000000..7515ba9f6 --- /dev/null +++ b/.github/workflows/publish-golang.yml @@ -0,0 +1,116 @@ +name: Publish Go Bindings +on: + workflow_call: + inputs: + ref: + description: 'commit/tag/branch reference' + required: true + type: string + package-version: + description: 'version for the golang package (MAJOR.MINOR.BUILD) (no v prefix)' + required: true + type: string + publish: + description: 'value indicating whether to commit/tag a release.' + required: true + type: boolean + default: false + secrets: + REPO_SSH_KEY: + description: 'ssh key to commit to the breez-sdk-go repository' + required: true + +jobs: + build-tag-release: + runs-on: ubuntu-latest + steps: + - name: Checkout breez-liquid-sdk-go repo + uses: actions/checkout@v3 + with: + repository: breez/breez-liquid-sdk-go + ssh-key: ${{ secrets.REPO_SSH_KEY }} + fetch-depth: 0 + + - uses: actions/download-artifact@v3 + with: + name: bindings-golang + path: breez_liquid_sdk + + - uses: actions/download-artifact@v3 + with: + name: bindings-i686-linux-android + path: breez_liquid_sdk/lib/android-386 + + - uses: actions/download-artifact@v3 + with: + name: bindings-armv7-linux-androideabi + path: breez_liquid_sdk/lib/android-aarch + + - uses: actions/download-artifact@v3 + with: + name: bindings-aarch64-linux-android + path: breez_liquid_sdk/lib/android-aarch64 + + - uses: actions/download-artifact@v3 + with: + name: bindings-x86_64-linux-android + path: breez_liquid_sdk/lib/android-amd64 + + - uses: actions/download-artifact@v3 + with: + name: bindings-aarch64-apple-darwin + path: breez_liquid_sdk/lib/darwin-aarch64 + + - uses: actions/download-artifact@v3 + with: + name: bindings-x86_64-apple-darwin + path: breez_liquid_sdk/lib/darwin-amd64 + + - uses: actions/download-artifact@v3 + with: + name: bindings-aarch64-unknown-linux-gnu + path: breez_liquid_sdk/lib/linux-aarch64 + + - uses: actions/download-artifact@v3 + with: + name: bindings-x86_64-unknown-linux-gnu + path: breez_liquid_sdk/lib/linux-amd64 + + - uses: actions/download-artifact@v3 + with: + name: bindings-x86_64-pc-windows-msvc + path: breez_liquid_sdk/lib/windows-amd64 + + - name: Archive Go release + uses: actions/upload-artifact@v3 + with: + name: breez-liquid-sdk-go-${{ inputs.package-version || github.sha }} + path: | + ./* + !./.git + + - name: Tag the Go bindings + if: ${{ inputs.publish }} + run: | + git config --global user.email github-actions@github.com + git config --global user.name github-actions + git add breez_liquid_sdk/breez_liquid_sdk.h + git add breez_liquid_sdk/breez_liquid_sdk.c + git add breez_liquid_sdk/breez_liquid_sdk.go + git add breez_liquid_sdk/lib/android-386/libbreez_liquid_sdk_bindings.so + git add breez_liquid_sdk/lib/android-386/libc++_shared.so + git add breez_liquid_sdk/lib/android-aarch/libbreez_liquid_sdk_bindings.so + git add breez_liquid_sdk/lib/android-aarch/libc++_shared.so + git add breez_liquid_sdk/lib/android-aarch64/libbreez_liquid_sdk_bindings.so + git add breez_liquid_sdk/lib/android-aarch64/libc++_shared.so + git add breez_liquid_sdk/lib/android-amd64/libbreez_liquid_sdk_bindings.so + git add breez_liquid_sdk/lib/android-amd64/libc++_shared.so + git add breez_liquid_sdk/lib/darwin-aarch64/libbreez_liquid_sdk_bindings.dylib + git add breez_liquid_sdk/lib/darwin-amd64/libbreez_liquid_sdk_bindings.dylib + git add breez_liquid_sdk/lib/linux-aarch64/libbreez_liquid_sdk_bindings.so + git add breez_liquid_sdk/lib/linux-amd64/libbreez_liquid_sdk_bindings.so + git add breez_liquid_sdk/lib/windows-amd64/breez_liquid_sdk_bindings.dll + git commit -m "Update Go bindings to version v${{ inputs.package-version }}" + git push + git tag v${{ inputs.package-version }} -m "v${{ inputs.package-version }}" + git push --tags diff --git a/.github/workflows/publish-kotlin-multiplatform.yml b/.github/workflows/publish-kotlin-multiplatform.yml new file mode 100644 index 000000000..7fedb41d4 --- /dev/null +++ b/.github/workflows/publish-kotlin-multiplatform.yml @@ -0,0 +1,95 @@ +name: Publish Kotlin multiplatform Bindings +on: + 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 + package-version: + description: 'version for the gradle library (MAJOR.MINOR.BUILD)' + required: true + type: string + publish: + description: 'value indicating whether to publish to maven.' + required: true + type: boolean + default: false + secrets: + BREEZ_MVN_USERNAME: + description: 'username for gradlew publish' + required: true + BREEZ_MVN_PASSWORD: + description: 'password for gradlew publish' + required: true + +jobs: + build-package: + runs-on: macOS-latest + steps: + - name: Checkout breez-liquid-sdk repo + uses: actions/checkout@v3 + with: + repository: ${{ inputs.repository || github.repository }} + ref: ${{ inputs.ref || github.sha }} + + - uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '17' + + - uses: actions/download-artifact@v3 + with: + name: bindings-android-jniLibs + path: lib/bindings/bindings-kotlin-multiplatform/breez-liquid-sdk-kmp/src/androidMain/jniLibs + + - uses: actions/download-artifact@v3 + with: + name: bindings-kotlin-multiplatform + path: lib/bindings/bindings-kotlin-multiplatform/breez-liquid-sdk-kmp/src + + - name: Copy jvmMain + working-directory: lib/bindings + run: | + cp -r bindings-kotlin-multiplatform/breez-liquid-sdk-kmp/src/jvmMain/kotlin bindings-kotlin-multiplatform/breez-liquid-sdk-kmp/src/androidMain/ + + - uses: actions/download-artifact@v3 + with: + name: bindings-aarch64-apple-ios + path: lib/bindings/bindings-kotlin-multiplatform/breez-liquid-sdk-kmp/src/lib/ios-arm64 + + - uses: actions/download-artifact@v3 + with: + name: bindings-aarch64-apple-ios-sim + path: lib/bindings/bindings-kotlin-multiplatform/breez-liquid-sdk-kmp/src/lib/ios-simulator-arm64 + + - uses: actions/download-artifact@v3 + with: + name: bindings-x86_64-apple-ios + path: lib/bindings/bindings-kotlin-multiplatform/breez-liquid-sdk-kmp/src/lib/ios-simulator-x64 + + - name: Build Kotlin Multiplatform project + working-directory: lib/bindings/bindings-kotlin-multiplatform + env: + ORG_GRADLE_PROJECT_libraryVersion: ${{ inputs.package-version || '0.0.1' }} + run: ./gradlew :breez-liquid-sdk-kmp:assemble + + - name: Archive aar + uses: actions/upload-artifact@v3 + with: + name: kotlin-multiplatform-release.aar + path: lib/bindings/bindings-kotlin-multiplatform/breez-liquid-sdk-kmp/build/outputs/aar/breez-liquid-sdk-kmp-release.aar + + - name: Publish artifacts + if: ${{ inputs.publish }} + working-directory: lib/bindings/bindings-kotlin-multiplatform + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BREEZ_MVN_USERNAME: ${{ secrets.BREEZ_MVN_USERNAME }} + BREEZ_MVN_PASSWORD: ${{ secrets.BREEZ_MVN_PASSWORD }} + run: | + ./gradlew publish -PlibraryVersion=${{ inputs.package-version }} -PbreezReposiliteUsername="$BREEZ_MVN_USERNAME" -PbreezReposilitePassword="$BREEZ_MVN_PASSWORD" diff --git a/.github/workflows/publish-python.yml b/.github/workflows/publish-python.yml new file mode 100644 index 000000000..4749979bb --- /dev/null +++ b/.github/workflows/publish-python.yml @@ -0,0 +1,225 @@ +name: Publish Python Bindings +on: + 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 + package-version: + description: 'version for the python package (MAJOR.MINOR.BUILD)' + required: true + type: string + publish: + description: 'value indicating whether to publish to pypi.' + required: true + type: boolean + default: false + secrets: + PYPI_API_TOKEN: + description: 'api token to authenticate to pypi' + required: true + +jobs: + build-macos-wheels: + runs-on: macos-latest + strategy: + matrix: + python: ["3.8", "3.9", "3.10", "3.11", "3.12"] + steps: + - name: Checkout breez-liquid-sdk repo + uses: actions/checkout@v3 + with: + repository: ${{ inputs.repository || github.repository }} + ref: ${{ inputs.ref || github.sha }} + + - name: "Install Python" + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + + - uses: actions/download-artifact@v3 + with: + name: bindings-darwin-universal + path: lib/bindings/bindings-python/src/breez_liquid_sdk + + - uses: actions/download-artifact@v3 + with: + name: bindings-python + path: lib/bindings/bindings-python/src/breez_liquid_sdk + + - name: Clean up downloaded files + run: | + rm -f lib/bindings/bindings-python/src/breez_liquid_sdk/*.a + ls -R lib/bindings/bindings-python + + - name: Update package version + if: ${{ inputs.package-version }} + working-directory: lib/bindings/bindings-python + run: sed -i.bak -e 's/ version=".*",/ version="${{ inputs.package-version }}",/' setup.py + + - name: Install dependencies + working-directory: lib/bindings/bindings-python + run: pip3 install wheel setuptools + + - name: Build wheel + working-directory: lib/bindings/bindings-python + run: python3 setup.py bdist_wheel --plat-name macosx_11_0_universal2 --verbose + + - name: List wheel contents + working-directory: lib/bindings/bindings-python/dist + run: python3 -m zipfile --list *.whl || true + + - name: Archive the wheel + uses: actions/upload-artifact@v3 + with: + name: python-wheel-${{ matrix.python }}-macos + path: lib/bindings/bindings-python/dist/*.whl + + build-linux-wheels: + runs-on: ubuntu-20.04 + strategy: + matrix: + arch: [x86_64, aarch64] + python: ["3.8", "3.9", "3.10", "3.11", "3.12"] + steps: + - name: "Checkout" + uses: actions/checkout@v3 + with: + repository: ${{ inputs.repository || github.repository }} + ref: ${{ inputs.ref || github.sha }} + + - name: "Setup Python" + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + + - uses: actions/download-artifact@v3 + with: + name: bindings-${{ matrix.arch }}-unknown-linux-gnu + path: lib/bindings/bindings-python/src/breez_liquid_sdk + + - uses: actions/download-artifact@v3 + with: + name: bindings-python + path: lib/bindings/bindings-python/src/breez_liquid_sdk + + - name: Update package version + if: ${{ inputs.package-version }} + working-directory: lib/bindings/bindings-python + run: sed -i.bak -e 's/ version=".*",/ version="${{ inputs.package-version }}",/' setup.py + + - name: Install dependencies + working-directory: lib/bindings/bindings-python + run: pip3 install wheel setuptools + + - name: "Build wheel" + working-directory: lib/bindings/bindings-python + run: python3 setup.py bdist_wheel --plat-name manylinux_2_31_${{ matrix.arch }} --verbose + + - uses: actions/upload-artifact@v3 + with: + name: python-wheel-${{ matrix.python }}-manylinux_2_31_${{ matrix.arch }} + path: lib/bindings/bindings-python/dist/*.whl + + build-windows-wheels: + runs-on: windows-latest + strategy: + matrix: + arch: [win_amd64, win32] + python: ["3.8", "3.9", "3.10", "3.11", "3.12"] + steps: + - name: "Checkout" + uses: actions/checkout@v3 + with: + repository: ${{ inputs.repository || github.repository }} + ref: ${{ inputs.ref || github.sha }} + + - name: "Setup Python" + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + + - uses: actions/download-artifact@v3 + if: matrix.arch == 'win_amd64' + with: + name: bindings-x86_64-pc-windows-msvc + path: lib/bindings/bindings-python/src/breez_liquid_sdk + + - uses: actions/download-artifact@v3 + if: matrix.arch == 'win32' + with: + name: bindings-i686-pc-windows-msvc + path: lib/bindings/bindings-python/src/breez_liquid_sdk + + - uses: actions/download-artifact@v3 + with: + name: bindings-python + path: lib/bindings/bindings-python/src/breez_liquid_sdk + + - name: Copy VC redistributable DLLs for Windows + if: matrix.arch == 'win_amd64' + working-directory: lib/bindings/bindings-python/src/breez_liquid_sdk + run: | + Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x64\*\msvcp140.dll') . + Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x64\*\vcruntime140.dll') . + Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x64\*\vcruntime140_1.dll') . + + - name: Copy VC redistributable DLLs for Windows + if: matrix.arch == 'win32' + working-directory: lib/bindings/bindings-python/src/breez_liquid_sdk + run: | + Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x86\*\msvcp140.dll') . + Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x86\*\vcruntime140.dll') . + + - name: Update package version + if: ${{ inputs.package-version }} + working-directory: lib/bindings/bindings-python + run: (Get-Content setup.py) | Foreach-Object {$_ -replace ' version=".*",', (' version="${{ inputs.package-version }}",')} | Set-Content setup.py + + - name: Install dependencies + working-directory: lib/bindings/bindings-python + run: python -m pip install --upgrade pip twine wheel setuptools + + - name: "Build wheel" + working-directory: lib/bindings/bindings-python + run: python -m setup bdist_wheel --plat-name ${{ matrix.arch }} --verbose + + - uses: actions/upload-artifact@v3 + with: + name: python-wheel-${{ matrix.python }}-${{ matrix.arch }} + path: lib/bindings/bindings-python/dist/*.whl + + publish-package: + runs-on: ubuntu-latest + needs: [build-macos-wheels, build-linux-wheels, build-windows-wheels] + steps: + - name: Checkout breez-sdk repo + uses: actions/checkout@v3 + with: + repository: ${{ inputs.repository || github.repository }} + ref: ${{ inputs.ref || github.sha }} + + - name: Download wheels + uses: actions/download-artifact@v3 + with: + path: lib/bindings/bindings-python/dist/ + + - name: Clean downloaded contents + working-directory: lib/bindings/bindings-python + run: | + find dist -maxdepth 1 ! -path dist ! -name "python-wheel-*" -exec rm -rf {} \; + ls -laR dist + + - name: "Publish on PyPI" + if: ${{ inputs.publish }} + uses: pypa/gh-action-pypi-publish@release/v1 + with: + verbose: true + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} + packages_dir: lib/bindings/bindings-python/dist/*/ diff --git a/.github/workflows/publish-react-native.yml b/.github/workflows/publish-react-native.yml new file mode 100644 index 000000000..541517235 --- /dev/null +++ b/.github/workflows/publish-react-native.yml @@ -0,0 +1,67 @@ +name: Publish React Native Plugin +on: + 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 + package-version: + description: 'version for the npm package (MAJOR.MINOR.BUILD)' + required: true + type: string + publish: + description: 'value indicating whether to publish to npm.' + required: true + type: boolean + default: false + secrets: + NPM_TOKEN: + description: 'access token for npm publish' + required: true + +jobs: + build-package: + runs-on: ubuntu-latest + steps: + - name: Checkout breez-liquid-sdk repo + uses: actions/checkout@v3 + with: + repository: ${{ inputs.repository || github.repository }} + ref: ${{ inputs.ref || github.sha }} + + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: 'https://registry.npmjs.org' + scope: '@breeztech' + + - name: Make sure we publish the version as specified + working-directory: packages/react-native + run: npm --no-git-tag-version --allow-same-version version ${{ inputs.package-version || '0.0.2' }} + + - name: Install dependencies + working-directory: packages/react-native + run: yarn + + - name: Pack for archival + working-directory: packages/react-native + run: yarn pack --filename breez-liquid-sdk-react-native.tgz + + - name: Archive the package + uses: actions/upload-artifact@v3 + with: + name: react-native-${{ inputs.package-version || '0.0.2' }} + path: packages/react-native/breez-liquid-sdk-react-native.tgz + + - name: Publish package to npm + if: ${{ inputs.publish }} + working-directory: packages/react-native + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: yarn publish diff --git a/.github/workflows/publish-swift.yml b/.github/workflows/publish-swift.yml new file mode 100644 index 000000000..6d0945902 --- /dev/null +++ b/.github/workflows/publish-swift.yml @@ -0,0 +1,135 @@ +name: Publish Swift Bindings +on: + 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 + package-version: + description: 'version for the python package (MAJOR.MINOR.BUILD)' + required: true + type: string + publish: + description: 'value indicating whether to publish to pypi.' + required: true + type: boolean + default: false + secrets: + REPO_SSH_KEY: + description: 'ssh key to commit to the breez-liquid-sdk-swift repository' + required: true + COCOAPODS_TRUNK_TOKEN: + description: 'cocoapods trunk token' + required: true + +jobs: + build-swift-package: + runs-on: macOS-13 + steps: + - name: Checkout breez-liquid-sdk repo + uses: actions/checkout@v3 + with: + repository: ${{ inputs.repository || github.repository }} + path: build + + - name: Checkout breez-liquid-sdk-swift repo + uses: actions/checkout@v3 + with: + repository: breez/breez-liquid-sdk-swift + ssh-key: ${{ secrets.REPO_SSH_KEY }} + fetch-depth: 0 + path: dist + + - name: Download swift bindings + uses: actions/download-artifact@v3 + with: + name: bindings-swift + path: bindings-swift + + - name: Download aarch64-apple-ios + uses: actions/download-artifact@v3 + with: + name: bindings-aarch64-apple-ios + path: aarch64-apple-ios + + - name: Download ios-universal-sim + uses: actions/download-artifact@v3 + with: + name: bindings-ios-universal-sim + path: ios-universal-sim + + - name: Download darwin-universal + uses: actions/download-artifact@v3 + with: + name: bindings-darwin-universal + path: darwin-universal + + - name: Copy swift bindings + run: | + mkdir -p build/lib/bindings/bindings-swift/Sources/BreezLiquidSDK + cp bindings-swift/BreezLiquidSDK.swift build/lib/bindings/bindings-swift/Sources/BreezLiquidSDK/BreezLiquidSDK.swift + cp bindings-swift/breez_liquid_sdkFFI.h build/lib/bindings/bindings-swift/breez_liquid_sdkFFI.xcframework/ios-arm64/breez_liquid_sdkFFI.framework/Headers + cp bindings-swift/breez_liquid_sdkFFI.h build/lib/bindings/bindings-swift/breez_liquid_sdkFFI.xcframework/ios-arm64_x86_64-simulator/breez_liquid_sdkFFI.framework/Headers + cp bindings-swift/breez_liquid_sdkFFI.h build/lib/bindings/bindings-swift/breez_liquid_sdkFFI.xcframework/macos-arm64_x86_64/breez_liquid_sdkFFI.framework/Headers + mkdir -p build/lib/bindings/bindings-swift/breez_liquid_sdkFFI.xcframework/ios-arm64/breez_liquid_sdkFFI.framework/breez_liquid_sdkFFI + cp aarch64-apple-ios/libbreez_liquid_sdk_bindings.a build/lib/bindings/bindings-swift/breez_liquid_sdkFFI.xcframework/ios-arm64/breez_liquid_sdkFFI.framework/breez_liquid_sdkFFI + mkdir -p build/lib/bindings/bindings-swift/breez_liquid_sdkFFI.xcframework/ios-arm64_x86_64-simulator/breez_liquid_sdkFFI.framework/breez_liquid_sdkFFI + cp ios-universal-sim/libbreez_liquid_sdk_bindings.a build/lib/bindings/bindings-swift/breez_liquid_sdkFFI.xcframework/ios-arm64_x86_64-simulator/breez_liquid_sdkFFI.framework/breez_liquid_sdkFFI + cp darwin-universal/libbreez_liquid_sdk_bindings.a build/lib/bindings/bindings-swift/breez_liquid_sdkFFI.xcframework/macos-arm64_x86_64/breez_liquid_sdkFFI.framework/breez_liquid_sdkFFI + + - name: Compress XCFramework + working-directory: build/lib/bindings/bindings-swift + run: | + zip -9 -r breez_liquid_sdkFFI.xcframework.zip breez_liquid_sdkFFI.xcframework + echo "XCF_CHECKSUM=`swift package compute-checksum breez_liquid_sdkFFI.xcframework.zip`" >> $GITHUB_ENV + + - name: Update Swift Package definition + working-directory: build/lib/bindings/bindings-swift + run: | + sed 's#.binaryTarget(name: "breez_liquid_sdkFFI", path: "./breez_liquid_sdkFFI.xcframework"),#.binaryTarget(name: "breez_liquid_sdkFFI", url: "https://github.com/breez/breez-liquid-sdk-swift/releases/download/${{ inputs.package-version || '0.0.1' }}/breez_liquid_sdkFFI.xcframework.zip", checksum: "${{ env.XCF_CHECKSUM }}"),#;/.testTarget(name: "BreezLiquidSDKTests", dependencies: \["BreezLiquidSDK"\]),/d' Package.swift > ../../../../dist/Package.swift + cp -r Sources ../../../../dist + + - name: Update Cocoapods definitions + working-directory: dist + run: | + sed -i '' 's#^.\{2\}spec.version.*$# spec.version = "${{ inputs.package-version || '0.0.1' }}"#' breez_liquid_sdkFFI.podspec + sed -i '' 's#^.\{2\}spec.version.*$# spec.version = "${{ inputs.package-version || '0.0.1' }}"#' BreezLiquidSDK.podspec + + - name: Tag the Swift bindings + if: ${{ inputs.publish }} + working-directory: dist + run: | + git config --global user.name "SDK release tagger" + git config --global user.email "no-reply@breez.technology" + git add Package.swift + git add Sources + git add breez_liquid_sdkFFI.podspec + git add BreezLiquidSDK.podspec + git commit -m "Update Swift bindings to version ${{ inputs.package-version || '0.0.1' }}" + git push + git tag ${{ inputs.package-version || '0.0.1' }} -m "${{ inputs.package-version || '0.0.1' }}" + git push --tags + + - name: Release and attach XCFramework binary artifact + if: ${{ inputs.publish }} + uses: ncipollo/release-action@v1 + with: + artifacts: "build/lib/bindings/bindings-swift/breez_liquid_sdkFFI.xcframework.zip" + tag: ${{ inputs.package-version || '0.0.1' }} + token: ${{ secrets.GITHUB_TOKEN }} + name: ${{ inputs.package-version || '0.0.1' }} + prerelease: true + + - name: Push update to Cocoapods trunk + if: ${{ inputs.publish }} + working-directory: dist + env: + COCOAPODS_TRUNK_TOKEN: ${{secrets.COCOAPODS_TRUNK_TOKEN}} + run: | + pod trunk push breez_liquid_sdkFFI.podspec --allow-warnings + pod trunk push BreezLiquidSDK.podspec --allow-warnings --synchronous