-
Notifications
You must be signed in to change notification settings - Fork 121
571 lines (508 loc) · 17.7 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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
# Based on: https://github.com/ClementTsang/bottom/blob/master/.github/workflows/deployment.yml
name: Release
on:
push:
tags:
- v*
env:
CARGO_TERM_COLOR: always
HUMANE_VERSION: "0.9.0"
WASM_PACK_VERSION: "v0.10.3"
jobs:
publish-crate:
name: Publish Crate
runs-on: ubuntu-20.04
needs: publish-github-release
steps:
- name: Clone
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.rustup
target
key: ${{ runner.os }}-stable-min165
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
default: true
components: rustfmt, clippy
- name: Install wasm-pack
uses: jetli/[email protected]
with:
version: ${{env.WASM_PACK_VERSION}}
- name: Get Version
run: echo GIT_VERSION="$(git describe --tags | sed 's/^v\(.*\)$/\1/')" >> $GITHUB_ENV
- name: Prepare Git
run: |
git config user.email "[email protected]"
git config user.name "Github Actions"
git checkout -b main
# Use throw-away branch so we don't push the changes to origin
git checkout -b deploy_branch
- name: Prepare Crates
run: |
# Update cargo version,
node ./.backstage/version.cjs
git add ./pagefind/Cargo.toml
git add ./pagefind_web/Cargo.toml
git add ./pagefind_ui/default/package.json
git add ./pagefind_ui/modular/package.json
# Commit changes so cargo doesn't complain about dirty repo
git commit -m "Deploy changes."
- name: Build Coupled JS
working-directory: ./pagefind_web_js
run: npm i && npm run build-coupled
- name: Build WASM
working-directory: ./pagefind_web
run: ./local_build.sh
- name: Build UI
working-directory: ./pagefind_ui/default
run: npm i && npm run build
- name: Build Modular UI
working-directory: ./pagefind_ui/modular
run: npm i && npm run build
- name: Build
run: cargo build --release --verbose
- name: Publish
working-directory: ./pagefind
run: cargo publish --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
publish-npm-package:
name: Publish NPM packages
runs-on: ubuntu-20.04
needs: publish-binary-npm-packages
steps:
- name: Clone
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: release-checksums
path: wrappers/node/checksums
- name: Get Version
run: echo GIT_VERSION="$(git describe --tags | sed 's/^v\(.*\)$/\1/')" >> $GITHUB_ENV
- name: Get Tag
run: echo GIT_TAG="$(node ./.backstage/get_tag.cjs)" >> $GITHUB_ENV
- name: Version optional dependencies
run: |
node ./.backstage/version_main_package.cjs
- name: Prepare wrapper package
working-directory: ./wrappers/node
run: |
npm version $GIT_VERSION
- name: Publish wrapper package
working-directory: ./wrappers/node
run: npm publish --tag $GIT_TAG
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Prepare default ui package
working-directory: ./pagefind_ui/default
run: |
npm version $GIT_VERSION
- name: Publish default ui package
working-directory: ./pagefind_ui/default
run: |
npm i
npm run build
npm publish --tag $GIT_TAG --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Prepare modular ui package
working-directory: ./pagefind_ui/modular
run: |
npm version $GIT_VERSION
- name: Publish modular ui package
working-directory: ./pagefind_ui/modular
run: |
npm i
npm run build
npm publish --tag $GIT_TAG --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-binary-npm-packages:
name: Publish NPM binaries
runs-on: ubuntu-20.04
needs: publish-github-release
strategy:
matrix:
include:
- target: x86_64-pc-windows-msvc
package: windows-x64
os: win32
cpu: x64
- target: x86_64-unknown-linux-musl
package: linux-x64
os: linux
cpu: x64
- target: aarch64-unknown-linux-musl
package: linux-arm64
os: linux
cpu: arm64
- target: x86_64-apple-darwin
package: darwin-x64
os: darwin
cpu: x64
- target: aarch64-apple-darwin
package: darwin-arm64
os: darwin
cpu: arm64
steps:
- name: Clone
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: release
path: build-artifacts
- name: Get Version
run: echo GIT_VERSION="$(git describe --tags | sed 's/^v\(.*\)$/\1/')" >> $GITHUB_ENV
- name: Get Tag
run: echo GIT_TAG="$(node ./.backstage/get_tag.cjs)" >> $GITHUB_ENV
- name: Create Package
run: |
mkdir -p ${{ matrix.package }}/bin/
cd ${{ matrix.package }}
node ../.backstage/create_package.cjs ${{ matrix.os }} ${{ matrix.cpu }}
cp ../wrappers/node/.npmrc .
- name: Extract Binary
working-directory: build-artifacts
run: |
tar xzf pagefind_extended-v$GIT_VERSION-${{ matrix.target }}.tar.gz
rm *.tar.gz
mv * ../${{ matrix.package }}/bin/
- name: Prepare package
working-directory: ${{ matrix.package }}
run: |
npm version $GIT_VERSION
- name: Publish
working-directory: ${{ matrix.package }}
run: npm publish --tag $GIT_TAG --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-github-release:
name: GitHub Release
runs-on: ubuntu-20.04
needs: test-and-build
defaults:
run:
working-directory: ./
steps:
- name: Get Token
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v2
with:
application_id: ${{ secrets.CC_OSS_BOT_ID }}
application_private_key: ${{ secrets.CC_OSS_BOT_PEM }}
- name: Clone
uses: actions/checkout@v3
with:
token: ${{ steps.get_workflow_token.outputs.token }}
- name: Swap to main
uses: actions/checkout@v3
with:
ref: main
fetch-depth: 0 # Full fetch
token: ${{ steps.get_workflow_token.outputs.token }}
- name: Get Version
run: echo GIT_VERSION="$(git describe --tags | sed 's/^v\(.*\)$/\1/')" >> $GITHUB_ENV
- name: Get Tag
run: echo GIT_TAG="$(node ./.backstage/get_tag.cjs)" >> $GITHUB_ENV
- uses: actions/download-artifact@v3
with:
name: release
path: build-artifacts
- name: Build CHANGELOG
if: env.GIT_TAG == 'latest'
run: |
node ./.backstage/changelog.cjs write
echo CHANGELOG=\"$(base64 -w 0 -i CHANGELOG.md)\" >> $GITHUB_ENV
echo SHA=\"$( git rev-parse main:CHANGELOG.md )\" >> $GITHUB_ENV
- name: Build CHANGELOG
if: env.GIT_TAG != 'latest'
run: |
echo "## Prerelease" > RELEASE.md
node ./.backstage/changelog.cjs write || true
- name: Commit new CHANGELOG
uses: octokit/[email protected]
if: env.GIT_TAG == 'latest'
id: push_changes
with:
route: PUT /repos/{owner}/{repo}/contents/CHANGELOG.md
owner: cloudcannon
repo: pagefind
branch: main
message: Changelog for ${{ env.GIT_VERSION }}
sha: ${{ env.SHA }}
content: ${{ env.CHANGELOG }}
env:
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
- name: Release documentation branch
uses: octokit/[email protected]
if: env.GIT_TAG == 'latest'
id: merge_docs
with:
route: POST /repos/{owner}/{repo}/merges
owner: cloudcannon
repo: pagefind
base: production-docs
head: main
commit_message: Release documentation for ${{ env.GIT_VERSION }}
env:
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') && env.GIT_TAG == 'latest'
with:
repository: cloudcannon/pagefind
prerelease: false
body_path: RELEASE.md
files: |
build-artifacts/*
env:
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') && env.GIT_TAG != 'latest'
with:
repository: cloudcannon/pagefind-beta
prerelease: true
body_path: RELEASE.md
files: |
build-artifacts/*
env:
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
test-and-build:
name: Build
runs-on: ${{matrix.os}}
defaults:
run:
shell: bash
strategy:
matrix:
include:
- build: windows
os: windows-latest
rust: stable
target: x86_64-pc-windows-msvc
humane_target: x86_64-pc-windows-msvc
cross: false
run_tests: true
- build: linux
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-musl
humane_target: x86_64-unknown-linux-musl
cross: false
run_tests: true
- build: linux
os: ubuntu-latest
rust: stable
target: aarch64-unknown-linux-musl
humane_target: x86_64-unknown-linux-musl
cross: false
run_tests: false
- build: macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
humane_target: x86_64-apple-darwin
cross: false
run_tests: true
- build: macos-m1
os: macos-latest
rust: stable
target: aarch64-apple-darwin
humane_target: x86_64-apple-darwin
cross: false
run_tests: false
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.rustup
target
key: ${{ runner.os }}-${{ matrix.rust }}
- uses: actions/setup-node@v3
with:
node-version: 16
# From https://github.com/Emoun/duplicate/blob/master/.github/workflows/rust.yml
- name: Get Version
run: echo GIT_VERSION="$(git describe --tags | sed 's/^v\(.*\)$/\1/')" >> $GITHUB_ENV
- name: Get Tag
run: echo GIT_TAG="$(node ./.backstage/get_tag.cjs)" >> $GITHUB_ENV
- name: Verify Changelog
if: env.GIT_TAG == 'latest'
run: |
node ./.backstage/changelog.cjs
- name: Install Linker
if: matrix.cross
run: |
sudo apt update
sudo apt install ${{ matrix.linker }}
- name: Install MUSL Tooling
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt update -y
sudo apt install -y musl-tools musl-dev
- name: Install aarch64 Tooling
if: matrix.target == 'aarch64-unknown-linux-musl'
run: |
sudo apt update -y
sudo apt install -y clang gcc-aarch64-linux-gnu
echo "TARGET_CC=clang" >> $GITHUB_ENV
echo "CFLAGS_aarch64_unknown_linux_musl=--sysroot=/usr/aarch64-linux-gnu" >> $GITHUB_ENV
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=/usr/aarch64-linux-gnu/bin/ld" >> $GITHUB_ENV
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
default: true
components: rustfmt, clippy
- name: Install wasm-pack
uses: jetli/[email protected]
with:
version: ${{env.WASM_PACK_VERSION}}
- name: Install humane
if: matrix.run_tests == true
uses: supplypike/setup-bin@v3
with:
uri: "https://github.com/CloudCannon/humane/releases/download/v${{env.HUMANE_VERSION}}/humane-v${{env.HUMANE_VERSION}}-${{matrix.humane_target}}.tar.gz"
name: "humane"
version: ${{env.HUMANE_VERSION}}
- name: Prepare Git
run: |
git config user.email "[email protected]"
git config user.name "Github Actions"
git checkout -b main
# Use throw-away branch so we don't push the changes to origin
git checkout -b deploy_branch
- name: Prepare Crates
run: |
# Update cargo version,
node ./.backstage/version.cjs
git add ./pagefind/Cargo.toml
git add ./pagefind_web/Cargo.toml
git add ./pagefind_ui/default/package.json
git add ./pagefind_ui/modular/package.json
# Commit changes so cargo doesn't complain about dirty repo
git commit -m "Deploy changes."
- name: Build Coupled JS
working-directory: ./pagefind_web_js
run: npm i && npm run build-coupled
- name: Build WASM
working-directory: ./pagefind_web
run: ./local_build.sh
- name: Build UI
working-directory: ./pagefind_ui/default
run: npm i && npm run build
- name: Build Modular UI
working-directory: ./pagefind_ui/modular
run: npm i && npm run build
- name: Test Web
if: matrix.run_tests == true
working-directory: ./pagefind_web
run: cargo test --release
- name: Build
working-directory: ./pagefind
run: cargo build --release --target ${{ matrix.target }} --features extended
- name: Test Lib
if: matrix.run_tests == true
working-directory: ./pagefind
run: cargo test --release --target ${{ matrix.target }} --features extended
- name: Test CLI
if: matrix.run_tests == true
working-directory: ./pagefind
run: TEST_BINARY=../target/${{ matrix.target }}/release/pagefind humane
- name: Move extended binary aside
run: |
cp target/${{ matrix.target }}/release/pagefind target/${{ matrix.target }}/release/pagefind_extended
- name: Build Non-Extended
working-directory: ./pagefind
run: cargo build --release --target ${{ matrix.target }}
- name: Create Standard Release
run: |
EXEC_NAME="pagefind"
ASSET_PATH="$EXEC_NAME-v$GIT_VERSION-${{ matrix.target }}.tar.gz"
CHECKSUM_PATH="$ASSET_PATH.sha256"
if [ "$RUNNER_OS" == "Windows" ]; then
EXEC_NAME="pagefind.exe"
fi
tar czf $ASSET_PATH -C target/${{ matrix.target }}/release $EXEC_NAME
if command -v gtar &> /dev/null; then
echo "Using gtar"
gtar czf $ASSET_PATH -C target/${{ matrix.target }}/release $EXEC_NAME
else
echo "Using system tar"
tar czf $ASSET_PATH -C target/${{ matrix.target }}/release $EXEC_NAME
fi
case $RUNNER_OS in
Windows)
sha256sum $ASSET_PATH > $CHECKSUM_PATH
;;
Linux)
sha256sum $ASSET_PATH > $CHECKSUM_PATH
;;
macOS)
shasum -a 256 $ASSET_PATH > $CHECKSUM_PATH
;;
esac
echo "ASSET_PATH=$ASSET_PATH" >> $GITHUB_ENV
echo "CHECKSUM_PATH=$CHECKSUM_PATH" >> $GITHUB_ENV
- name: Create Extended Release
run: |
EXEC_NAME="pagefind_extended"
ASSET_PATH="$EXEC_NAME-v$GIT_VERSION-${{ matrix.target }}.tar.gz"
CHECKSUM_PATH="$ASSET_PATH.sha256"
if [ "$RUNNER_OS" == "Windows" ]; then
EXEC_NAME="pagefind_extended.exe"
fi
if command -v gtar &> /dev/null; then
echo "Using gtar"
gtar czf $ASSET_PATH -C target/${{ matrix.target }}/release $EXEC_NAME
else
echo "Using system tar"
tar czf $ASSET_PATH -C target/${{ matrix.target }}/release $EXEC_NAME
fi
case $RUNNER_OS in
Windows)
sha256sum $ASSET_PATH > $CHECKSUM_PATH
;;
Linux)
sha256sum $ASSET_PATH > $CHECKSUM_PATH
;;
macOS)
shasum -a 256 $ASSET_PATH > $CHECKSUM_PATH
;;
esac
echo "EXTENDED_ASSET_PATH=$ASSET_PATH" >> $GITHUB_ENV
echo "EXTENDED_CHECKSUM_PATH=$CHECKSUM_PATH" >> $GITHUB_ENV
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: release
path: |
${{ env.ASSET_PATH }}
${{ env.CHECKSUM_PATH }}
${{ env.EXTENDED_ASSET_PATH }}
${{ env.EXTENDED_CHECKSUM_PATH }}
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: release-checksums
path: |
${{ env.CHECKSUM_PATH }}
${{ env.EXTENDED_CHECKSUM_PATH }}