-
Notifications
You must be signed in to change notification settings - Fork 0
297 lines (265 loc) · 9.56 KB
/
Copy pathrelease.yml
File metadata and controls
297 lines (265 loc) · 9.56 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
name: Release
on:
push:
tags:
- "v*"
jobs:
validate:
name: Validate release version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Check tag matches manifest and EXPLAIN package versions
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
TABULARIUM_VERSION=$(jq -r .version .tabularium)
EXPLAIN_VERSION=$(jq -r .version explain/package.json)
if [ "$TAG_VERSION" != "$TABULARIUM_VERSION" ]; then
echo "::error::Tag version ($TAG_VERSION) does not match .tabularium version ($TABULARIUM_VERSION)"
exit 1
fi
# The plugin binaries and the npm parser package ship from the same
# tag, so their versions must agree before anything is built.
if [ "$TAG_VERSION" != "$EXPLAIN_VERSION" ]; then
echo "::error::Tag version ($TAG_VERSION) does not match explain/package.json version ($EXPLAIN_VERSION)"
exit 1
fi
# See ci.yml: pnpm comes from the pinned "packageManager" field, not
# from the Corepack copy bundled with Node.
- name: Setup pnpm
uses: pnpm/action-setup@v6
with:
package_json_file: explain/package.json
- name: Setup Node
uses: actions/setup-node@v7
with:
# pnpm 11.23 requires Node 22.13 or newer.
node-version: "22.13"
# Typecheck and test the parser before any platform binary is built so a
# broken parser fails the whole release instead of only the npm half.
- name: Typecheck and test EXPLAIN parser
working-directory: explain
run: |
pnpm install --frozen-lockfile
pnpm typecheck
pnpm test
build:
name: ${{ matrix.platform-label }}
needs: validate
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- platform-label: linux-x64
runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: zip
binary-suffix: ""
- platform-label: linux-arm64
runner: ubuntu-latest
target: aarch64-unknown-linux-gnu
archive: zip
binary-suffix: ""
cross: true
- platform-label: darwin-x64
runner: macos-latest
target: x86_64-apple-darwin
archive: zip
binary-suffix: ""
- platform-label: darwin-arm64
runner: macos-14
target: aarch64-apple-darwin
archive: zip
binary-suffix: ""
- platform-label: win-x64
runner: windows-latest
target: x86_64-pc-windows-msvc
archive: zip
binary-suffix: ".exe"
steps:
- uses: actions/checkout@v7
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Check for UI extension
id: ui
shell: bash
run: |
if [ -f ui/package.json ]; then
echo "present=true" >> "$GITHUB_OUTPUT"
else
echo "present=false" >> "$GITHUB_OUTPUT"
fi
- name: Check for EXPLAIN parser
id: explain
shell: bash
run: |
if [ -f explain/package.json ]; then
echo "present=true" >> "$GITHUB_OUTPUT"
else
echo "present=false" >> "$GITHUB_OUTPUT"
fi
# See ci.yml: pnpm comes from the pinned "packageManager" field, not
# from the Corepack copy bundled with Node.
- name: Setup pnpm
if: steps.explain.outputs.present == 'true'
uses: pnpm/action-setup@v6
with:
package_json_file: explain/package.json
- name: Setup Node
if: steps.ui.outputs.present == 'true' || steps.explain.outputs.present == 'true'
uses: actions/setup-node@v7
with:
# pnpm 11.23 requires Node 22.13 or newer.
node-version: "22.13"
- name: Build UI
if: steps.ui.outputs.present == 'true'
shell: bash
working-directory: ui
run: |
npm install --no-audit --no-fund
npm run build
- name: Build EXPLAIN parser
if: steps.explain.outputs.present == 'true'
shell: bash
working-directory: explain
run: |
pnpm install --frozen-lockfile
pnpm run build
- name: Install cross (linux-arm64 only)
if: matrix.cross
run: cargo install cross --locked
- name: Build (cross)
if: matrix.cross
run: cross build --release --target ${{ matrix.target }}
- name: Build
if: ${{ !matrix.cross }}
run: cargo build --release --target ${{ matrix.target }}
- name: Package (unix)
if: runner.os != 'Windows'
run: |
STAGE=staging
mkdir -p "$STAGE"
cp target/${{ matrix.target }}/release/sqlserver-plugin${{ matrix.binary-suffix }} "$STAGE/"
cp .tabularium "$STAGE/"
if [ -d assets ]; then
cp -r assets "$STAGE/"
fi
if [ -f ui/dist/index.js ]; then
mkdir -p "$STAGE/ui/dist"
cp ui/dist/index.js "$STAGE/ui/dist/"
fi
if [ -f explain/dist/index.iife.js ]; then
mkdir -p "$STAGE/explain/dist"
cp explain/dist/index.iife.js "$STAGE/explain/dist/"
fi
(cd "$STAGE" && zip -r ../sqlserver-plugin-${{ matrix.platform-label }}.zip .)
- name: Package (windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$stage = "staging"
New-Item -ItemType Directory -Force -Path $stage | Out-Null
Copy-Item "target\${{ matrix.target }}\release\sqlserver-plugin${{ matrix.binary-suffix }}" $stage
Copy-Item ".tabularium" $stage
if (Test-Path "assets") {
Copy-Item -Recurse "assets" "$stage\assets"
}
if (Test-Path "ui\dist\index.js") {
New-Item -ItemType Directory -Force -Path "$stage\ui\dist" | Out-Null
Copy-Item "ui\dist\index.js" "$stage\ui\dist"
}
if (Test-Path "explain\dist\index.iife.js") {
New-Item -ItemType Directory -Force -Path "$stage\explain\dist" | Out-Null
Copy-Item "explain\dist\index.iife.js" "$stage\explain\dist"
}
Compress-Archive -Path "$stage\*" -DestinationPath "sqlserver-plugin-${{ matrix.platform-label }}.zip"
- name: Stash artifact
uses: actions/upload-artifact@v7
with:
name: sqlserver-plugin-${{ matrix.platform-label }}
path: sqlserver-plugin-${{ matrix.platform-label }}.zip
retention-days: 1
publish-explain:
name: Publish EXPLAIN parser to npm
# Runs only once every platform binary has built, so the npm package and
# the GitHub release are cut from the same tag in the same run.
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v7
- name: Setup pnpm
uses: pnpm/action-setup@v6
with:
package_json_file: explain/package.json
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version: "22.13"
registry-url: "https://registry.npmjs.org"
# npm never accepts a second publish of an existing version, so a re-run
# of this workflow (or a recreated tag) must not fail the release on the
# npm half once the package is already out.
- name: Check whether this version is already on npm
id: npm
working-directory: explain
run: |
NAME=$(jq -r .name package.json)
VERSION=$(jq -r .version package.json)
if npm view "$NAME@$VERSION" version >/dev/null 2>&1; then
echo "::warning::$NAME@$VERSION is already published on npm; skipping publish"
echo "published=true" >> "$GITHUB_OUTPUT"
else
echo "published=false" >> "$GITHUB_OUTPUT"
fi
- name: Install and build
if: steps.npm.outputs.published == 'false'
working-directory: explain
run: |
pnpm install --frozen-lockfile
pnpm build
- name: Publish
if: steps.npm.outputs.published == 'false'
working-directory: explain
run: pnpm publish --access public --provenance --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
release:
name: Publish GitHub release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout (for the .tabularium manifest asset)
uses: actions/checkout@v7
- name: Download all build artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
merge-multiple: true
- name: Detect prerelease from tag
id: meta
env:
TAG_NAME: ${{ github.ref_name }}
run: |
if [[ "$TAG_NAME" == *-* ]]; then
echo "prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "prerelease=false" >> "$GITHUB_OUTPUT"
fi
- name: Publish release
uses: softprops/action-gh-release@v3
with:
# .tabularium ships as a standalone asset: the registry resolves the
# manifest from release assets, not the git ref.
files: |
artifacts/*.zip
.tabularium
prerelease: ${{ steps.meta.outputs.prerelease == 'true' }}
make_latest: ${{ steps.meta.outputs.prerelease == 'false' }}