Files
breez-sdk-liquid/.github/workflows/publish-csharp.yml
2024-05-03 12:35:02 +02:00

151 lines
4.8 KiB
YAML

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>.*<\/Version>/<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