-
Notifications
You must be signed in to change notification settings - Fork 7
71 lines (60 loc) · 2.57 KB
/
update-guide.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
on:
push:
tags:
- guide-latest
name: Release Guide
jobs:
create-release:
name: Update guide
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Add Rust toolchain
run: rustup toolchain install stable --profile minimal --no-self-update
- run: rustup target add wasm32-unknown-unknown --toolchain stable
- name: Add Node.js toolchain
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Build Results Viewer and Book
run: |
set -x
# install mdbook and wasm-pack
mkdir ~/bin
PATH=$PATH:~/bin
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.20/mdbook-v0.4.20-x86_64-unknown-linux-gnu.tar.gz \
| tar -xz -C ~/bin
curl -sSL https://github.com/rustwasm/wasm-pack/releases/download/v0.12.1/wasm-pack-v0.12.1-x86_64-unknown-linux-musl.tar.gz \
| tar -xz --strip-components=1 -C ~/bin --no-anchored wasm-pack
# setup some envs to various paths for convenience
PROJECT_ROOT=$PWD
GUIDE_DIR=$(realpath $PROJECT_ROOT/guide)
RESULTS_VIEWER_REACT_DIR=$(realpath $GUIDE_DIR/results-viewer-react)
WASM_LIB_DIR=$(realpath $PROJECT_ROOT/lib/hdr-histogram-wasm)
WASM_OUTPUT_REACT_DIR=$RESULTS_VIEWER_REACT_DIR/lib/hdr-histogram-wasm
# build the hdr-histogram-wasm for the results viewer
cd $WASM_LIB_DIR
wasm-pack build --release -t bundler -d $WASM_OUTPUT_REACT_DIR --scope fs
cd $RESULTS_VIEWER_REACT_DIR
npm ci
npm run build
# build the book
cd $GUIDE_DIR
mdbook build
- name: Update gh-pages branch and push to Github
run: |
git fetch --no-tags origin gh-pages
cd guide
# create a git worktree of the gh-pages branch and clear it out
git worktree add -B gh-pages gh-pages origin/gh-pages
find gh-pages -not -name '.git' -not -name 'gh-pages' -delete
# copy the source to the gh-pages worktree
cp -r book/. gh-pages/
# commit amend all the changes into the gh-pages branch and force push to github
git remote add github "https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY.git"
cd gh-pages
git add --all
git config --global user.name ${GITHUB_ACTOR}
git config --global user.email ${GITHUB_ACTOR}@users.noreply.github.com
git commit --amend --no-edit
git push --force github gh-pages