Skip to content

Commit

Permalink
make c# publish depend on platform build
Browse files Browse the repository at this point in the history
  • Loading branch information
JssDWt committed Jul 27, 2023
1 parent 5950305 commit 56d472f
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 58 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-all-platforms.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Build all platforms
on:
workflow_call:
workflow_dispatch:
push:
branches:
Expand All @@ -11,4 +12,4 @@ jobs:
build-darwin:
uses: ./.github/workflows/build-darwin.yml
build-linux:
uses: ./.github/workflows/build-linux.yml
uses: ./.github/workflows/build-linux.yml
2 changes: 1 addition & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
target: [
i686-pc-windows-msvc,
aarch64-pc-windows-msvc,
x86_64-pc-windows-msvc,
]
steps:
Expand Down
115 changes: 59 additions & 56 deletions .github/workflows/publish-csharp.yml
Original file line number Diff line number Diff line change
@@ -1,78 +1,81 @@
name: Publish C# Bindings
on:
workflow_dispatch:
inputs:
version:
description: 'breez-sdk repo release (MAJOR.MINOR.PATCH)'
required: true
type: string
cs-project-ref:
description: 'commit/tag to use for the csharp project. Can be different from `version`'
required: true
type: string
push:
branches:
- "build-artifacts-in-ci"

jobs:
build-tag-release:
name: Build, tag, and release the Breez SDK C# bindings
runs-on: macOS-latest
build-all-platforms:
name: Build all platforms
uses: ./.github/workflows/build-all-platforms.yml

build-package:
needs: build-all-platforms
runs-on: ubuntu-latest
steps:
- name: Install required dependencies
env:
HOMEBREW_NO_AUTO_UPDATE: 1
run: |
brew tap messense/macos-cross-toolchains
brew install protobuf
brew install mingw-w64
brew install aarch64-unknown-linux-gnu
brew install x86_64-unknown-linux-gnu
cargo install --version 0.22.0 uniffi_bindgen
- name: Checkout breez-sdk repo
uses: actions/checkout@v3
with:
path: build
ref: ${{ inputs.version }}
- name: Checkout breez-sdk repo for C# project
uses: actions/checkout@v3
with:
path: dist
ref: ${{ inputs.cs-project-ref }}
- name: Build C# bindings
working-directory: build/libs/sdk-bindings
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER: x86_64-linux-gnu-gcc
run: |
make init
rustup target add x86_64-pc-windows-gnu
cargo build --release --target aarch64-unknown-linux-gnu
cargo build --release --target x86_64-unknown-linux-gnu
cargo build --release --target x86_64-pc-windows-gnu
make csharp-darwin
- name: Copy binding

- name: Install rust
run: |
cp build/libs/sdk-bindings/ffi/csharp/breez_sdk.cs dist/libs/sdk-bindings/bindings-csharp
- name: Copy libraries
rustup set auto-self-update disable
rustup toolchain install stable --profile minimal
cargo install uniffi-bindgen-cs --git https://github.com/breez/uniffi-bindgen-cs --branch namespace
- name: Build C# binding
working-directory: libs/sdk-bindings
run: |
mkdir -p dist/libs/sdk-bindings/bindings-csharp/runtimes/osx-arm64/native && cp build/libs/target/aarch64-apple-darwin/release/libbreez_sdk_bindings.dylib "$_"
mkdir -p dist/libs/sdk-bindings/bindings-csharp/runtimes/osx-x64/native && cp build/libs/target/x86_64-apple-darwin/release/libbreez_sdk_bindings.dylib "$_"
mkdir -p dist/libs/sdk-bindings/bindings-csharp/runtimes/linux-arm64/native && cp build/libs/target/aarch64-unknown-linux-gnu/release/libbreez_sdk_bindings.so "$_"
mkdir -p dist/libs/sdk-bindings/bindings-csharp/runtimes/linux-x64/native && cp build/libs/target/x86_64-unknown-linux-gnu/release/libbreez_sdk_bindings.so "$_"
mkdir -p dist/libs/sdk-bindings/bindings-csharp/runtimes/win-x64/native && cp build/libs/target/x86_64-pc-windows-gnu/release/breez_sdk_bindings.dll "$_"
- name: Update package version
working-directory: dist/libs/sdk-bindings/bindings-csharp
run: sed -i.bak -e 's/<Version>.*<\/Version>/<Version>${{ inputs.version }}<\/Version>/' Breez.Sdk.csproj
uniffi-bindgen-cs src/breez_sdk.udl -o bindings-csharp -c ./uniffi.toml
- uses: actions/download-artifact@v3
with:
name: sdk-bindings-${{ github.sha }}-aarch64-apple-darwin
path: libs/sdk-bindings/bindings-csharp/runtimes/osx-arm64/native

- uses: actions/download-artifact@v3
with:
name: sdk-bindings-${{ github.sha }}-x86_64-apple-darwin
path: libs/sdk-bindings/bindings-csharp/runtimes/osx-x64/native

- uses: actions/download-artifact@v3
with:
name: sdk-bindings-${{ github.sha }}-aarch64-unknown-linux-gnu
path: libs/sdk-bindings/bindings-csharp/runtimes/linux-arm64/native

- uses: actions/download-artifact@v3
with:
name: sdk-bindings-${{ github.sha }}-x86_64-unknown-linux-gnu
path: libs/sdk-bindings/bindings-csharp/runtimes/linux-x64/native

- uses: actions/download-artifact@v3
with:
name: sdk-bindings-${{ github.sha }}-aarch64-pc-windows-msvc
path: libs/sdk-bindings/bindings-csharp/runtimes/win-arm64/native

- uses: actions/download-artifact@v3
with:
name: sdk-bindings-${{ github.sha }}-x86_64-pc-windows-msvc
path: libs/sdk-bindings/bindings-csharp/runtimes/win-x64/native

# - name: Update package version
# working-directory: dist/libs/sdk-bindings/bindings-csharp
# run: sed -i.bak -e 's/<Version>.*<\/Version>/<Version>${{ inputs.version }}<\/Version>/' Breez.Sdk.csproj

- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'

- name: Build the project
working-directory: dist/libs/sdk-bindings/bindings-csharp
run: dotnet build Breez.Sdk.csproj

- name: Create the package
working-directory: dist/libs/sdk-bindings/bindings-csharp
run: dotnet pack --configuration Release Breez.Sdk.csproj

- name: Archive the package
uses: actions/upload-artifact@v2
with:
name: Breez.Sdk.${{ inputs.version }}.nupkg
path: dist/libs/sdk-bindings/bindings-csharp/bin/Release/Breez.Sdk.${{ inputs.version }}.nupkg
name: Breez.Sdk.${{ github.sha }}.nupkg
path: dist/libs/sdk-bindings/bindings-csharp/bin/Release/Breez.Sdk.*.nupkg
1 change: 1 addition & 0 deletions libs/sdk-bindings/bindings-csharp/Breez.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<Content Include="runtimes/osx-x64/native/libbreez_sdk_bindings.dylib" Link="runtimes/osx-x64/native/libbreez_sdk_bindings.dylib" Pack="true" PackagePath="runtimes/osx-x64/native/libbreez_sdk_bindings.dylib" />
<Content Include="runtimes/linux-arm64/native/libbreez_sdk_bindings.so" Link="runtimes/linux-arm64/native/libbreez_sdk_bindings.so" Pack="true" PackagePath="runtimes/linux-arm64/native/libbreez_sdk_bindings.so" />
<Content Include="runtimes/linux-x64/native/libbreez_sdk_bindings.so" Link="runtimes/linux-x64/native/libbreez_sdk_bindings.so" Pack="true" PackagePath="runtimes/linux-x64/native/libbreez_sdk_bindings.so" />
<Content Include="runtimes/win-arm64/native/breez_sdk_bindings.dll" Link="runtimes/win-arm64/native/breez_sdk_bindings.dll" Pack="true" PackagePath="runtimes/win-arm64/native/breez_sdk_bindings.dll" />
<Content Include="runtimes/win-x64/native/breez_sdk_bindings.dll" Link="runtimes/win-x64/native/breez_sdk_bindings.dll" Pack="true" PackagePath="runtimes/win-x64/native/breez_sdk_bindings.dll" />
</ItemGroup>
</Project>

0 comments on commit 56d472f

Please sign in to comment.