-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-web.sh
More file actions
executable file
·47 lines (34 loc) · 1.55 KB
/
deploy-web.sh
File metadata and controls
executable file
·47 lines (34 loc) · 1.55 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
#!/bin/bash
# Script to build and deploy the WebAssembly version to GitHub Pages
# This script builds the quantsim_ui crate and syncs the output to the docs/ folder
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
DIST_DIR="$ROOT_DIR/crates/quantsim_ui/dist"
DOCS_DIR="$ROOT_DIR/docs"
echo "Building WebAssembly release..."
# Build the WASM release
cd "$ROOT_DIR/crates/quantsim_ui"
env -u NO_COLOR trunk build --release
echo "Syncing built files to docs/..."
# Remove old generated web artifacts that can go stale between releases.
rm -f "$DOCS_DIR"/*.js "$DOCS_DIR"/*.wasm "$DOCS_DIR"/index.html \
"$DOCS_DIR"/favicon.ico "$DOCS_DIR"/manifest.json "$DOCS_DIR"/sw.js
rm -rf "$DOCS_DIR"/assets
# Copy the fresh build output.
cp -R "$DIST_DIR"/. "$DOCS_DIR"/
# Check what files were copied
echo "Copied files:"
ls -la "$DOCS_DIR"/*.js "$DOCS_DIR"/*.wasm "$DOCS_DIR"/index.html
echo "Updating index.html..."
# Update index.html title, base href, and file paths
cd "$DOCS_DIR"
sed -i.bak 's|<base href="[^"]*"|<base href="/quantum_algorithm_simulator/"|g' index.html
sed -i.bak "s|from '/quantsim_ui.js'|from './quantsim_ui.js'|g" index.html
sed -i.bak "s|module_or_path: '/quantsim_ui_bg.wasm'|module_or_path: './quantsim_ui_bg.wasm'|g" index.html
sed -i.bak "s|href=\"/quantsim_ui.js\"|href=\"./quantsim_ui.js\"|g" index.html
sed -i.bak "s|href=\"/quantsim_ui_bg.wasm\"|href=\"./quantsim_ui_bg.wasm\"|g" index.html
# Remove backup files
rm -f index.html.bak
echo "Web deployment complete!"
echo "Files updated in docs/ folder:"
ls -la *.js *.wasm index.html