-
Notifications
You must be signed in to change notification settings - Fork 1
363 lines (322 loc) · 12.2 KB
/
release.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
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
name: Release
run-name: Release ${{github.event.inputs.release-version || github.ref_name}}
concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+' # ex. v1.0.0
- 'v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+' # ex. v1.1.0-rc1 for pre-releases
workflow_dispatch:
inputs:
release-version:
description: "Release version (v#.#.#[-rc#])"
required: true
env:
NEW_RELEASE_TAG: ${{github.event.inputs.release-version || github.ref_name}}
TEST_RUN: ${{contains(github.event.inputs.release-version || github.ref_name, '-rc')}}
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: -D warnings
jobs:
verify:
name: Checks core project built in Rust
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Rust Toolchain Stable
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af
with:
toolchain: stable
default: true
profile: default
target: wasm32-unknown-unknown
- name: Install Rust Toolchain Nightly
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af
with:
toolchain: nightly-2023-12-28
default: false
profile: default
target: wasm32-unknown-unknown
- name: Cargo check
run: make check
- name: Cargo test
run: make test
- name: Cargo fmt
run: make format-check
- name: Set Up Cargo Deny
run: |
cargo install --force cargo-deny
cargo generate-lockfile
- name: License and Issue Check
run: make deny
build-artifacts:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
java_library: libdsnp_graph_sdk_jni.so
node_library: libdsnp_graph_sdk_node.so
rust-target: x86_64-unknown-linux-gnu
additional-rust-target: aarch64-unknown-linux-gnu
- os: windows-latest
java_library: dsnp_graph_sdk_jni.dll
node_library: dsnp_graph_sdk_node.dll
rust-target: x86_64-pc-windows-msvc
- os: macos-latest
java_library: libdsnp_graph_sdk_jni.dylib
node_library: libdsnp_graph_sdk_node.dylib
rust-target: aarch64-apple-darwin
additional-rust-target: x86_64-apple-darwin
name: Build project in ${{ matrix.os }}
needs: verify
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Rust Toolchain
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af
with:
toolchain: nightly
default: true
profile: minimal
target: ${{ matrix.rust-target }}
- run: rustup target add ${{ matrix.additional-rust-target }}
if: ${{ matrix.additional-rust-target != '' }}
- name: Set up Java
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2
with:
java-version: '17'
distribution: 'adopt'
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: https://registry.npmjs.org/
- name: Build Jni bridge
run: |
cargo build -p dsnp-graph-sdk-jni --profile production --target ${{ matrix.rust-target }}
mkdir -p artifacts/java
cp target/${{ matrix.rust-target }}/production/${{ matrix.java_library }} artifacts/java/${{ matrix.rust-target }}_${{ matrix.java_library }}
- name: Build Node bridge
run: |
cargo build -p dsnp-graph-sdk-node --profile production --target ${{ matrix.rust-target }}
mkdir -p artifacts/node
cp target/${{ matrix.rust-target }}/production/${{ matrix.node_library }} artifacts/node/${{ matrix.rust-target }}_dsnp_graph_sdk_node.node
- name: Build additional target for MacOS Jni
run: |
cargo build -p dsnp-graph-sdk-jni --profile production --target ${{ matrix.additional-rust-target }}
mkdir -p artifacts/java
cp target/${{ matrix.additional-rust-target }}/production/${{ matrix.java_library }} artifacts/java/${{ matrix.additional-rust-target }}_${{ matrix.java_library }}
if: matrix.os == 'macos-latest' && matrix.additional-rust-target != ''
- name: Build additional target for MacOS Node
run: |
cargo build -p dsnp-graph-sdk-node --profile production --target ${{ matrix.additional-rust-target }}
cp target/${{ matrix.additional-rust-target }}/production/${{ matrix.node_library }} artifacts/node/${{ matrix.additional-rust-target }}_dsnp_graph_sdk_node.node
if: matrix.os == 'macos-latest' && matrix.additional-rust-target != ''
- name: Build additional targets for Linux Jni
run: |
cargo install cross
cross build +nightly --target ${{ matrix.additional-rust-target }} -p dsnp-graph-sdk-jni --profile production
cp target/${{ matrix.additional-rust-target }}/production/${{ matrix.java_library }} artifacts/java/${{ matrix.additional-rust-target }}_${{ matrix.java_library }}
if: matrix.os == 'ubuntu-latest' && matrix.additional-rust-target != ''
- name: Build other targets Binary for Linux Node
run: |
cross build +nightly --target ${{ matrix.additional-rust-target }} -p dsnp-graph-sdk-node --profile production
cp target/${{ matrix.additional-rust-target }}/production/${{ matrix.node_library }} artifacts/node/${{ matrix.additional-rust-target }}_dsnp_graph_sdk_node.node
if: matrix.os == 'ubuntu-latest' && matrix.additional-rust-target != ''
- name: Upload Artifacts Java
uses: actions/upload-artifact@v3
with:
name: artifacts-java-${{github.run_id}}
path: artifacts/java/
- name: Upload Artifacts Node
uses: actions/upload-artifact@v3
with:
name: artifacts-node-${{github.run_id}}
path: artifacts/node/
publish-java:
name: Build and Publish JVM
runs-on: ubuntu-latest
needs: build-artifacts
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up Java
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2
with:
java-version: '17'
distribution: 'adopt'
- name: Download Binaries
id: download-binaries
uses: actions/download-artifact@v3
with:
name: artifacts-java-${{github.run_id}}
path: java/lib/src/main/resources
- name: List Downloaded Binaries
run: |
download_dir=${{steps.download-binaries.outputs.download-path}}
echo "Download dir: $download_dir"
echo "Downloaded binaries: $(ls -l $download_dir)"
- name: Get current version
id: version
run: |
# removing v from in front of tag to get version
NEW_VERSION=$(echo '${{ env.NEW_RELEASE_TAG }}' | cut -d 'v' -f 2)
echo "New version: $NEW_VERSION"
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Build and Publish with Gradle
working-directory: java
run: ./gradlew -PprojVersion='${{ steps.version.outputs.version }}' build
- name: Publish to GitHub Packages
working-directory: java
run: ./gradlew -PprojVersion='${{ steps.version.outputs.version }}' publish
if: env.TEST_RUN != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_ACTOR: ${{ github.actor }}
publish_npm_package:
name: Publish NPM Package
runs-on: ubuntu-latest
needs: build-artifacts
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: https://registry.npmjs.org/
- name: Install NPM Dependencies
working-directory: bridge/node
run: npm install
- name: Get current version
id: version
working-directory: bridge/node
run: echo ::set-output name=version::$(node -p "require('./package.json').version")
- name: Show versions
working-directory: bridge/node
run: |
echo "Package: v${{ steps.version.outputs.version }}"
echo " Actual: ${{ env.NEW_RELEASE_TAG }}"
- name: Use the new version
working-directory: bridge/node
run: |
npm version --new-version "${{ env.NEW_RELEASE_TAG }}" --allow-same-version
NEW_VERSION=$(node -p "require('./package.json').version")
echo "New version: $NEW_VERSION"
env:
FULL_SHA: ${{ github.sha }}
- name: Build NPM Package
working-directory: bridge/node
run: |
npm run tsc && cp README.md dist/README.md
- name: Download Binaries
id: download-binaries
uses: actions/download-artifact@v3
with:
name: artifacts-node-${{github.run_id}}
path: bridge/node
- name: Copy binaries
working-directory: bridge/node
run: |
cp *_dsnp_graph_sdk_node.node js/
cp *_dsnp_graph_sdk_node.node dist/js/
- name: Publish NPM Package
working-directory: bridge/node
if: env.TEST_RUN != 'true'
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: Dry run NPM Package
working-directory: bridge/node
if: env.TEST_RUN == 'true'
run: npm publish --access public --dry-run
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
generate-docs:
name: Generate graph sdk rust docs
runs-on: ubuntu-latest
needs: build-artifacts
permissions:
contents: read
packages: write
pages: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Rust Toolchain
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af
with:
toolchain: stable
default: true
profile: minimal
target: wasm32-unknown-unknown
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Build Docs
run: |
RUSTC_BOOTSTRAP=1 RUSTDOCFLAGS="--enable-index-page -Zunstable-options" cargo doc --no-deps --all-features
- name: Fix file permissions
shell: sh
run: |
chmod -c -R +rX "target/doc" |
while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Upload Docs
uses: actions/upload-pages-artifact@v1
if: env.TEST_RUN != 'true'
with:
path: ./target/doc
- name: Deploy Docs
uses: actions/deploy-pages@v2
if: env.TEST_RUN != 'true'
id: deployment
release:
needs: [publish-java, publish_npm_package, generate-docs]
runs-on: ubuntu-latest
name: Release generated artifacts
permissions:
contents: write
packages: write
steps:
- name: Download Java Binaries
id: download-binaries-java
uses: actions/download-artifact@v3
with:
name: artifacts-java-${{github.run_id}}
path: downloaded
- name: Download Node.js Binaries
id: download-binaries-node
uses: actions/download-artifact@v3
with:
name: artifacts-node-${{github.run_id}}
path: downloaded
- name: List Downloaded Binaries
run: |
download_dir=${{steps.download-binaries-node.outputs.download-path}}
echo "Download dir: $download_dir"
echo "Downloaded binaries: $(ls -l $download_dir)"
ls -R
- name: creating release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
with:
files: |
downloaded/*
prerelease: ${{ env.TEST_RUN }}
name: ${{env.NEW_RELEASE_TAG}}