-
Notifications
You must be signed in to change notification settings - Fork 46
150 lines (131 loc) · 4.81 KB
/
publish-csharp.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
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-sdk repo
uses: actions/checkout@v4
with:
repository: ${{ inputs.repository || github.repository }}
ref: ${{ inputs.ref || github.sha }}
- uses: actions/download-artifact@v4
with:
name: bindings-csharp
path: libs/sdk-bindings/bindings-csharp/src
- uses: actions/download-artifact@v4
with:
name: sdk-bindings-aarch64-apple-darwin
path: libs/sdk-bindings/bindings-csharp/src/runtimes/osx-arm64/native
- uses: actions/download-artifact@v4
with:
name: sdk-bindings-x86_64-apple-darwin
path: libs/sdk-bindings/bindings-csharp/src/runtimes/osx-x64/native
- uses: actions/download-artifact@v4
with:
name: sdk-bindings-aarch64-unknown-linux-gnu
path: libs/sdk-bindings/bindings-csharp/src/runtimes/linux-arm64/native
- uses: actions/download-artifact@v4
with:
name: sdk-bindings-x86_64-unknown-linux-gnu
path: libs/sdk-bindings/bindings-csharp/src/runtimes/linux-x64/native
- uses: actions/download-artifact@v4
with:
name: sdk-bindings-x86_64-pc-windows-msvc
path: libs/sdk-bindings/bindings-csharp/src/runtimes/win-x64/native
- uses: actions/download-artifact@v4
with:
name: sdk-bindings-i686-pc-windows-msvc
path: libs/sdk-bindings/bindings-csharp/src/runtimes/win-x86/native
- name: Update package version
if: ${{ inputs.package-version }}
working-directory: libs/sdk-bindings/bindings-csharp/src
run: sed -i.bak -e 's/<Version>.*<\/Version>/<Version>${{ inputs.package-version }}<\/Version>/' Breez.Sdk.csproj
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
- name: Build the project
working-directory: libs/sdk-bindings/bindings-csharp/src
run: dotnet build Breez.Sdk.csproj
- name: Create the package
working-directory: libs/sdk-bindings/bindings-csharp/src
run: dotnet pack --configuration Release Breez.Sdk.csproj
- name: Archive the package
uses: actions/upload-artifact@v4
with:
name: Breez.Sdk.${{ inputs.package-version || '0.0.1' }}.nupkg
path: libs/sdk-bindings/bindings-csharp/src/bin/Release/Breez.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-sdk repo
if: ${{ !inputs.skip-tests }}
uses: actions/checkout@v4
with:
repository: ${{ inputs.repository || github.repository }}
ref: ${{ inputs.ref || github.sha }}
- uses: actions/download-artifact@v4
if: ${{ !inputs.skip-tests }}
with:
name: Breez.Sdk.${{ inputs.package-version || '0.0.1' }}.nupkg
path: libs/sdk-bindings/bindings-csharp/src/bin/Release
- name: Setup dotnet
if: ${{ !inputs.skip-tests }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7.0.x'
- name: test package
if: ${{ !inputs.skip-tests }}
working-directory: libs/sdk-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@v4
with:
name: Breez.Sdk.${{ inputs.package-version }}.nupkg
- name: Publish to nuget.org
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push Breez.Sdk.${{ inputs.package-version }}.nupkg --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json