Repository navigation
235 lines (212 loc) · 7.99 KB
/
Copy pathcsharp.yml
File metadata and controls
235 lines (212 loc) · 7.99 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
name: Build and Test CSharp
on:
workflow_call:
pull_request:
paths:
- payjoin-ffi/**
# The unix jobs run inside the flake's csharp dev shell, so changes to
# the flake change this workflow's environment.
- flake.nix
- flake.lock
permissions:
contents: read
jobs:
# Pull requests run only the Linux build and test job. The other jobs
# cover macOS, Windows and packaging, and run on bindings releases and
# the daily run.
build-csharp-and-test-linux:
name: "Build and test csharp"
runs-on: ubuntu-26.04
env:
RUSTUP_TOOLCHAIN: 1.85.0
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false # unneeded: no git auth beyond checkout
- name: "Install Rust 1.85.0"
uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # v1
with:
toolchain: 1.85.0
- name: "Use cache"
uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
lookup-only: ${{ startsWith(github.ref, 'refs/tags/') }}
shared-key: msrv-workspace
- name: Set up nix
uses: $/.github/actions/setup-nix
- name: "Build and test"
run: nix develop .#csharp -c ./payjoin-ffi/csharp/contrib/test.sh
build-csharp-and-test-macos:
name: "Build and test csharp (macos)"
if: github.event_name != 'pull_request'
runs-on: macos-latest
env:
RUSTUP_TOOLCHAIN: 1.85.0
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false # unneeded: no git auth beyond checkout
- name: "Install Rust 1.85.0"
uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # v1
with:
toolchain: 1.85.0
- name: "Use cache"
uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
lookup-only: ${{ startsWith(github.ref, 'refs/tags/') }}
shared-key: msrv-workspace
- name: Set up nix
uses: $/.github/actions/setup-nix
- name: "Build and test"
run: nix develop .#csharp -c ./payjoin-ffi/csharp/contrib/test.sh
build-csharp-and-test-windows:
name: "Build and test csharp (windows)"
if: github.event_name != 'pull_request'
runs-on: windows-latest
env:
RUSTUP_TOOLCHAIN: 1.85
defaults:
run:
working-directory: payjoin-ffi/csharp
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false # unneeded: no git auth beyond checkout
- name: Install Rust 1.85.0
uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # v1
with:
toolchain: 1.85.0
- name: Use cache
uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
lookup-only: ${{ startsWith(github.ref, 'refs/tags/') }}
- name: Install .NET 10 SDK
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: "10.0.x"
- name: Verify .NET SDK
run: |
dotnet --version
dotnet --list-sdks
- name: Generate bindings and binaries
shell: pwsh
run: ./scripts/generate_bindings.ps1
- name: Run tests
run: dotnet test Payjoin.Tests.csproj --logger "console;verbosity=minimal"
pack-nuget:
# Every RID's native asset comes from the native workflow's checked
# double build in the same run. The per-RID smoke jobs verify each one
# on real hardware.
name: "Pack C# NuGet package"
if: github.event_name != 'pull_request'
runs-on: ubuntu-26.04
env:
# Exact version so the packaged bindings build with the toolchain the
# action installs, not an implicitly-installed latest 1.85.x.
RUSTUP_TOOLCHAIN: 1.85.0
RIDS: >-
linux-arm64=aarch64-unknown-linux-gnu
linux-x64=x86_64-unknown-linux-gnu
osx-arm64=aarch64-apple-darwin
osx-x64=x86_64-apple-darwin
win-arm64=aarch64-pc-windows-msvc
win-x64=x86_64-pc-windows-msvc
defaults:
run:
working-directory: payjoin-ffi/csharp
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false # unneeded: no git auth beyond checkout
- name: Install Rust 1.85.0
uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # v1
with:
toolchain: 1.85.0
- name: Use cache
uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
lookup-only: ${{ startsWith(github.ref, 'refs/tags/') }}
- name: Install .NET 10 SDK
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: "10.0.x"
- name: Download the native libraries
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: payjoin-native
path: ${{ runner.temp }}/native
- name: Assemble RID assets
run: |
set -euo pipefail
for pair in $RIDS; do
rid=${pair%%=*}
mkdir -p "artifacts/runtimes/$rid/native"
cp "$RUNNER_TEMP/native/${pair#*=}"/* "artifacts/runtimes/$rid/native/"
done
- name: Generate production bindings
run: |
PAYJOIN_FFI_FEATURES= PAYJOIN_FFI_PROFILE=release bash ./scripts/generate_bindings.sh
- name: Pack NuGet package
run: dotnet pack Payjoin.csproj --configuration Release --output artifacts/packages
# The release lists each library on its own, so the package must carry
# them unchanged.
- name: Check the packed libraries
run: |
set -euo pipefail
for pair in $RIDS; do
for lib in "$RUNNER_TEMP/native/${pair#*=}"/*; do
unzip -p artifacts/packages/*.nupkg "runtimes/${pair%%=*}/native/$(basename "$lib")" | cmp - "$lib"
done
done
- name: Upload NuGet package
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: payjoin-csharp-nuget-package
path: payjoin-ffi/csharp/artifacts/packages/*.nupkg
if-no-files-found: error
smoke-nuget:
name: "Smoke test C# NuGet package"
if: github.event_name != 'pull_request'
runs-on: ${{ matrix.os }}
needs: pack-nuget
defaults:
run:
working-directory: payjoin-ffi/csharp
strategy:
matrix:
include:
- os: ubuntu-26.04-arm
rid: linux-arm64
- os: ubuntu-26.04
rid: linux-x64
- os: macos-latest
rid: osx-arm64
- os: macos-15-intel
rid: osx-x64
- os: windows-11-arm
rid: win-arm64
- os: windows-latest
rid: win-x64
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false # unneeded: no git auth beyond checkout
- name: Install .NET 10 SDK
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: "10.0.x"
- name: Download NuGet package
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: payjoin-csharp-nuget-package
path: payjoin-ffi/csharp/artifacts/packages
- name: Run package smoke test
shell: bash
# 'auto' derives the version from the packed artifact, so Payjoin.csproj
# stays the only place the package version is maintained.
run: bash ./scripts/smoke_nuget_package.sh artifacts/packages auto ${{ matrix.rid }}