-
Notifications
You must be signed in to change notification settings - Fork 27
175 lines (169 loc) · 5.22 KB
/
bindings.nodejs.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
name: Bindings Node.js
on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
paths:
- "core/**"
- "sql/**"
- "driver/**"
- "bindings/nodejs/**"
- ".github/workflows/bindings.nodejs.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: ./.github/actions/setup
with:
cache-key: bindings-nodejs-integration
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Corepack
working-directory: bindings/nodejs
run: corepack enable
- name: Install dependencies
working-directory: bindings/nodejs
run: pnpm install
- name: Check format
working-directory: bindings/nodejs
run: pnpm prettier --check .
build:
needs: check
name: build-${{ matrix.target }}
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- { target: x86_64-unknown-linux-gnu, runner: ubuntu-20.04 }
- { target: aarch64-unknown-linux-gnu, runner: ubuntu-20.04 }
- { target: x86_64-unknown-linux-musl, runner: ubuntu-latest }
- { target: aarch64-unknown-linux-musl, runner: ubuntu-latest }
- { target: x86_64-pc-windows-msvc, runner: windows-latest }
- { target: aarch64-pc-windows-msvc, runner: windows-latest }
- { target: x86_64-apple-darwin, runner: macos-latest }
- { target: aarch64-apple-darwin, runner: macos-latest }
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: ./.github/actions/setup
with:
cache-key: bindings-nodejs-${{ matrix.target }}
target: ${{ matrix.target }}
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install ziglang
if: contains(matrix.target, '-unknown-linux-')
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.11.0
- name: Corepack
working-directory: bindings/nodejs
run: corepack enable
- name: Install dependencies
working-directory: bindings/nodejs
run: pnpm install
- name: build
working-directory: bindings/nodejs
shell: bash
env:
NAPI_TARGET: ${{ matrix.target }}
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
pnpm napi build --platform --target=$NAPI_TARGET --js generated.js
else
pnpm napi build --platform --target=$NAPI_TARGET --release --js generated.js
fi
pnpm node ./scripts/header.js
- name: strip for macos
if: endsWith(matrix.target, '-apple-darwin')
working-directory: bindings/nodejs
run: |
strip -x *.node
- uses: actions/upload-artifact@v4
with:
name: bindings-nodejs-${{ matrix.target }}
path: bindings/nodejs/*.node
integration:
name: integration-${{ matrix.ver }}
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
ver: ["18", "20", "22"]
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.ver }}
- name: Corepack
working-directory: bindings/nodejs
run: corepack enable
- name: Install dependencies
working-directory: bindings/nodejs
run: pnpm install
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
name: bindings-nodejs-x86_64-unknown-linux-gnu
path: bindings/nodejs
- run: make -C tests test-bindings-nodejs
publish:
if: startsWith(github.ref, 'refs/tags/v')
needs: [build, integration]
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
environment:
name: npmjs.com
url: https://www.npmjs.com/package/databend-driver
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Corepack
working-directory: bindings/nodejs
run: corepack enable
- name: Install dependencies
working-directory: bindings/nodejs
run: pnpm install
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: bindings/nodejs/artifacts
pattern: bindings-nodejs-*
merge-multiple: true
- name: Move artifacts
shell: bash
working-directory: bindings/nodejs
run: |
ls -lRh artifacts
pnpm napi artifacts
ls -lRh npm
- name: Add LICENSE
run: cp LICENSE ./bindings/nodejs
- name: Publish
working-directory: bindings/nodejs
env:
GITHUB_TOKEN: ${{ github.token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --access public --provenance