Repository navigation
Expand file tree
/
Copy pathlib-java-csharp-sdk-release.yml
More file actions
304 lines (304 loc) · 13.3 KB
/
Copy pathlib-java-csharp-sdk-release.yml
File metadata and controls
304 lines (304 loc) · 13.3 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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# Full cross-platform build, test, package, and publish workflow for Java & C# Runtime SDK.
# Dispatched by the release-please post-process-tags job (tags created via GITHUB_TOKEN
# do not trigger on.push.tags workflows). CI is handled by lib-java-csharp-sdk-ci.yml.
name: Java & C# Runtime SDK Release
on:
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g. runtime-sdk-ffi/v1.0.0)'
required: true
type: string
jobs:
# Build API documentation packages
documentation:
runs-on: ubuntu-latest
defaults:
run:
working-directory: libs/runtime
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust ${{ matrix.rust }}
uses: dtolnay/rust-toolchain@stable
- name: Install doxygen 1.14.0
run: wget -q https://github.com/newstack-cloud/ci-files/raw/main/doxygen/doxygen-1.14.0.linux.bin.tar.gz -O- | sudo tar --strip-components=1 -C /usr -xz doxygen-1.14.0
- name: Build FFI and JNI
run: cargo build --release -p celerity_runtime_bindgen_ffi -p celerity_runtime_bindgen_ffi_java
- name: .NET bindings
run: cargo run --bin celerity-runtime-bindings -- --dotnet --doxygen --no-tests
- name: Java bindings
# The underlying oo_bindgen CLI tool only generates docs for Java when tests are enabled.
run: cargo run --bin celerity-runtime-bindings -- --java
env:
# Test environment variables used to resolve vars in the test blueprint.
CELERITY_VARIABLE_secretStoreId: test-secret-store
CELERITY_VARIABLE_certificateId: test-certificate
CELERITY_VARIABLE_logLevel: debug
CELERITY_VARIABLE_paymentApiSecret: test-payment-api-secret
- name: Extract documentation
run: |
mkdir -p ~/doc
cp -a sdk/bindings/dotnet/celerity/doc ~/doc/dotnet
cp -a sdk/bindings/java/celerity/target/apidocs ~/doc/java
- name: Upload documentation
uses: actions/upload-artifact@v4
with:
name: doc-api
path: ~/doc
# Build bindings on Windows x64 [64-bit MSVC (Windows 7+) (x86_64-pc-windows-msvc)]
# and x86 [32-bit MSVC (Windows 7+) (i686-pc-windows-msvc)]
bindings-windows:
runs-on: windows-latest
defaults:
run:
working-directory: libs/runtime
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-msvc # 64-bit MSVC (Windows 7+)
test: true
- target: i686-pc-windows-msvc # 32-bit MSVC (Windows 7+)
test: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install NASM
run: |
choco install nasm
echo "C:\Program Files\NASM" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Add target to the pinned toolchain
run: rustup target add ${{ matrix.target }}
- name: Install Java 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Create FFI modules DIR
run: mkdir ffi-modules\${{ matrix.target }}
- name: Build FFI
run: cargo build -p celerity_runtime_bindgen_ffi --release --target ${{ matrix.target }}
- name: Build JNI
run: cargo build -p celerity_runtime_bindgen_ffi_java --release --target ${{ matrix.target }}
- name: Copy the FFI and JNI libs
shell: pwsh
run: |
Copy-Item -Path ./target/${{ matrix.target }}/release/celerity_runtime_bindgen_ffi.dll -Destination ffi-modules/${{ matrix.target }}
Copy-Item -Path ./target/${{ matrix.target }}/release/celerity_runtime_bindgen_ffi.dll.lib -Destination ffi-modules/${{ matrix.target }}
Copy-Item -Path ./target/${{ matrix.target }}/release/celerity_runtime_bindgen_ffi_java.dll -Destination ffi-modules/${{ matrix.target }}
- name: Upload compiled FFI modules
uses: actions/upload-artifact@v4
with:
name: ffi-modules-${{ matrix.target }}
path: ./libs/runtime/ffi-modules
- name: Test .NET Bindings
if: ${{ matrix.test }}
run: cargo run --bin celerity-runtime-bindings -- --dotnet -r ${{ matrix.target }} -a ./target/${{ matrix.target }}/release
env:
# Test environment variables used to resolve vars in the test blueprint.
CELERITY_VARIABLE_secretStoreId: test-secret-store
CELERITY_VARIABLE_certificateId: test-certificate
CELERITY_VARIABLE_logLevel: debug
CELERITY_VARIABLE_paymentApiSecret: test-payment-api-secret
- name: Test Java
if: ${{ matrix.test }}
run: cargo run --bin celerity-runtime-bindings -- --java -r ${{ matrix.target }} -a ./target/${{ matrix.target }}/release
env:
# Test environment variables used to resolve vars in the test blueprint.
CELERITY_VARIABLE_secretStoreId: test-secret-store
CELERITY_VARIABLE_certificateId: test-certificate
CELERITY_VARIABLE_logLevel: debug
CELERITY_VARIABLE_paymentApiSecret: test-payment-api-secret
# Build bindings on MacOS [64-bit macOS (10.7+, Lion+) (x86_64-apple-darwin)]
bindings-macos:
strategy:
fail-fast: false
matrix:
include:
- runner: macos-14
target: aarch64-apple-darwin
- runner: macos-13
target: x86_64-apple-darwin
runs-on: ${{ matrix.runner }}
defaults:
run:
working-directory: libs/runtime
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Create FFI modules dir
run: mkdir -p ffi-modules/${{ matrix.target }}
- name: Build FFI
run: cargo build -p celerity_runtime_bindgen_ffi --release
- name: Build JNI
run: cargo build -p celerity_runtime_bindgen_ffi_java --release
- name: Copy the FFI and JNI libs
run: |
cp ./target/release/libcelerity_runtime_bindgen_ffi.dylib ./ffi-modules/${{ matrix.target }}
cp ./target/release/libcelerity_runtime_bindgen_ffi_java.dylib ./ffi-modules/${{ matrix.target }}
- name: Upload compiled FFI modules
uses: actions/upload-artifact@v4
with:
name: ffi-modules-${{ matrix.target }}
path: ./libs/runtime/ffi-modules
- name: Test .NET bindings
run: cargo run --bin celerity-runtime-bindings -- --dotnet
env:
# Test environment variables used to resolve vars in the test blueprint.
CELERITY_VARIABLE_secretStoreId: test-secret-store
CELERITY_VARIABLE_certificateId: test-certificate
CELERITY_VARIABLE_logLevel: debug
CELERITY_VARIABLE_paymentApiSecret: test-payment-api-secret
- name: Test Java bindings
run: cargo run --bin celerity-runtime-bindings -- --java
env:
# Test environment variables used to resolve vars in the test blueprint.
CELERITY_VARIABLE_secretStoreId: test-secret-store
CELERITY_VARIABLE_certificateId: test-certificate
CELERITY_VARIABLE_logLevel: debug
CELERITY_VARIABLE_paymentApiSecret: test-payment-api-secret
# Cross-compilation for Linux to produce portable C and JNI libraries
bindings-linux:
env:
# By default, MUSL will not produce a cdylib with dynamic linkage to MUSL LIB C
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS: "-C target-feature=-crt-static"
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS: "-C target-feature=-crt-static"
CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_RUSTFLAGS: "-C target-feature=-crt-static"
strategy:
fail-fast: false
matrix:
cases:
- target: x86_64-unknown-linux-gnu # 64-bit Linux (kernel 2.6.32+, glibc 2.11+)
- target: x86_64-unknown-linux-musl # 64-bit Linux with MUSL
- target: arm-unknown-linux-gnueabihf # ARMv6 Linux, hardfloat (kernel 3.2, glibc 2.17)
- target: arm-unknown-linux-musleabihf # ARMv6 Linux with MUSL, hardfloat
- target: aarch64-unknown-linux-gnu # ARM64 Linux (kernel 4.2, glibc 2.17+)
- target: aarch64-unknown-linux-musl # ARM64 Linux with MUSL
runs-on: ubuntu-latest
defaults:
run:
working-directory: libs/runtime
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.cases.target }}
- name: Install Rust Cross
run: cargo install cross
- name: Create FFI modules dir
run: mkdir -p ffi-modules/${{ matrix.target }}
- name: Build FFI
run: cross build -p celerity_runtime_bindgen_ffi --release --target ${{ matrix.cases.target }}
- name: Build JNI
run: cross build -p celerity_runtime_bindgen_ffi_java --release --target ${{ matrix.cases.target }}
- name: Copy the FFI and JNI libs
run: |
cp ./target/${{ matrix.cases.target }}/release/libcelerity_runtime_bindgen_ffi.so ./ffi-modules/${{ matrix.cases.target }}
cp ./target/${{ matrix.cases.target }}/release/libcelerity_runtime_bindgen_ffi_java.so ./ffi-modules/${{ matrix.cases.target }}
- name: Upload compiled FFI modules
uses: actions/upload-artifact@v4
with:
name: ffi-modules-${{ matrix.cases.target }}
path: ./libs/runtime/ffi-modules
# Package all the generated bindings
packaging:
needs: [documentation, bindings-windows, bindings-macos, bindings-linux]
runs-on: ubuntu-latest
defaults:
run:
working-directory: libs/runtime
steps:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Checkout
uses: actions/checkout@v4
- name: Download compiled FFI
uses: actions/download-artifact@v4
with:
path: ./libs/runtime/ffi-modules
pattern: ffi-modules-*
merge-multiple: true
- name: Package .NET bindings
run: cargo run --bin celerity-runtime-bindings -- --dotnet --package ./ffi-modules --options ./packaging.json
- name: Package Java bindings
run: cargo run --bin celerity-runtime-bindings -- --java --package ./ffi-modules --options ./packaging.json
- name: Upload .NET bindings
uses: actions/upload-artifact@v4
with:
name: dotnet-bindings
path: ./libs/runtime/sdk/bindings/dotnet/nupkg/celerity*
- name: Upload Java bindings
uses: actions/upload-artifact@v4
with:
name: java-bindings-jar
path: ./libs/runtime/sdk/bindings/java/celerity/target/*.jar
- name: Upload Java pom.xml
uses: actions/upload-artifact@v4
with:
name: java-bindings-pom
path: ./libs/runtime/sdk/bindings/java/celerity/pom.xml
release:
needs: [packaging]
runs-on: ubuntu-latest
if: inputs.tag != ''
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Checkout newstack-cloud/celerity-runtime-binding-docs
uses: actions/checkout@v4
with:
repository: newstack-cloud/celerity-runtime-binding-docs
ssh-key: ${{ secrets.CELERITY_DOCS_SSH_KEY }}
path: docs
- name: Upload docs
working-directory: docs
run: |
git config user.name github-actions
git config user.email github-actions@github.com
rm -rf ./celerity/${{github.ref_name}}
mkdir -p ./celerity/${{github.ref_name}}
cp -a ../artifacts/doc/* ./celerity/${{github.ref_name}}
git add -A
git commit -m "[celerity] release ${{github.ref_name}}"
git push
- name: Import PGP key
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.CELERITY_PGP_PRIVATE_KEY }}
passphrase: ${{ secrets.CELERITY_PGP_PRIVATE_KEY_PASSPHRASE }}
- name: Login to Maven Central
uses: whelk-io/maven-settings-xml-action@v14
with:
servers: '[{ "id": "central", "username": "${{ secrets.CELERITY_MAVEN_CENTRAL_USERNAME }}", "password": "${{ secrets.CELERITY_MAVEN_CENTRAL_PASSWORD }}" }]'
- name: Deploy Java
shell: bash
working-directory: artifacts/java-bindings
run: >
shopt -s extglob &&
mvn gpg:sign-and-deploy-file -DrepositoryId=central -DpomFile=pom.xml -Dfile=celerity-${{github.ref_name}}.jar &&
mvn gpg:sign-and-deploy-file -DrepositoryId=central -DpomFile=pom.xml -Dfile=celerity-${{github.ref_name}}-sources.jar -Dclassifier=sources &&
mvn gpg:sign-and-deploy-file -DrepositoryId=central -DpomFile=pom.xml -Dfile=celerity-${{github.ref_name}}-javadoc.jar -Dclassifier=javadoc
- name: Publish NuGet package
shell: bash
run: dotnet nuget push $(find artifacts/dotnet-bindings/celerity*.nupkg) -s https://api.nuget.org/v3/index.json -k ${{ secrets.CELERITY_NUGET_KEY }}
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
draft: true
files: |
release/*.zip
artifacts/dotnet-bindings/celerity*
artifacts/java-bindings/*.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}