Skip to content

Commit 7edafcd

Browse files
committed
Add initial city game build script
1 parent 6200945 commit 7edafcd

File tree

3 files changed

+54
-7
lines changed

3 files changed

+54
-7
lines changed

.github/workflows/publish.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ on:
33
branches: ["main"]
44

55
name: Build and deploy on push
6+
7+
env:
8+
RUST_CHANNEL: stable
9+
610
jobs:
711
build:
812
name: Deploy website
@@ -13,9 +17,16 @@ jobs:
1317
with:
1418
node-version: '16'
1519

16-
- name: Install npm
20+
- name: Install asteroids deps
1721
uses: actions/setup-node@v2
1822

23+
- name: Install city-game deps
24+
run: |
25+
rustup update --no-self-update ${{ env.RUST_CHANNEL }}
26+
rustup default ${{ env.RUST_CHANNEL }}
27+
rustup target install wasm32-unknown-unknown
28+
cargo install wasm-bindgen-cli
29+
1930
- name: Build website
2031
run: ./scripts/build.sh
2132
env:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
+++
2+
title = "The Merp Experiment"
3+
description = "Game"
4+
weight = 1
5+
+++
6+
7+
[Play here](/the-merp-experiment/).

scripts/build-subprojects.sh

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,44 @@
11
#!/usr/bin/env bash
22

3-
set -e
3+
set -ex
44

55
HERE="$(dirname "${BASH_SOURCE[0]}")"
66
cd "$HERE"
77
REPO_DIR="$(git rev-parse --show-toplevel)"
88

9-
ASTEROIDS="$(mktemp -d -t asteroids-3d.XXX)"
10-
echo "Building subproject [directory=$ASTEROIDS]"
11-
git clone https://github.com/elihunter173/asteroids-3d.git "$ASTEROIDS"
12-
cd "$ASTEROIDS"
9+
subproject() {
10+
proj="$1"
11+
dir="$(mktemp -d -t "$proj".XXX)"
12+
echo "Building subproject [directory=$dir]"
13+
git clone "https://github.com/elihunter173/$proj.git" "$dir"
14+
cd "$dir"
15+
}
16+
17+
subproject asteroids-3d
1318
npm install --production
1419
npm run build
15-
cp -r "$ASTEROIDS/dist" "$REPO_DIR/static/asteroids"
20+
cp -r ./dist "$REPO_DIR/static/asteroids"
21+
22+
subproject city-game
23+
cargo build --release --target wasm32-unknown-unknown
24+
wasm-bindgen --no-typescript --target web \
25+
--out-dir ./out/ \
26+
--out-name "game" \
27+
./target/wasm32-unknown-unknown/web/game.wasm
28+
cat << EOF > ./out/index.html
29+
<!doctype html>
30+
<html lang="en">
31+
<body style="margin: 0px;">
32+
<script type="module">
33+
import init from './game.js'
34+
init().catch((error) => {
35+
if (!error.message.startsWith("Using exceptions for control flow, don't mind me. This isn't actually an error!")) {
36+
throw error;
37+
}
38+
});
39+
</script>
40+
</body>
41+
</html>
42+
EOF
43+
cp -r ./assets ./out/.
44+
cp -r ./out "$REPO_DIR/static/the-merp-experiment"

0 commit comments

Comments
 (0)