Skip to content

Commit aeb26fc

Browse files
authored
Merge pull request #40 from yuchanns/feat/deploy-wasm-gh-pages
feat(ci): auto deploy to gh pages
2 parents 0a9e104 + e2b95fd commit aeb26fc

File tree

5 files changed

+201
-1
lines changed

5 files changed

+201
-1
lines changed

.github/assets/coi-serviceworker.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/assets/font.zip

2.22 MB
Binary file not shown.

.github/assets/index.html

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Deep Future</title>
6+
<style>
7+
body { margin: 0; background: #000; }
8+
canvas { display: block; width: 100vw; height: 100vh; }
9+
</style>
10+
<script src="./coi-serviceworker.min.js"></script>
11+
</head>
12+
<body>
13+
<canvas id="canvas" oncontextmenu="event.preventDefault()"></canvas>
14+
15+
<script>
16+
var Module = {
17+
arguments: ["zipfile=/data/main.zip:/data/font.zip"],
18+
canvas: document.getElementById('canvas'),
19+
preRun: [function () {
20+
const runDependency = 'load-main-zip';
21+
const fontDependency = 'load-font';
22+
23+
const originalLookup = MEMFS.lookup;
24+
MEMFS.lookup = function (parent, name) {
25+
try {
26+
return originalLookup.call(this, parent, name);
27+
} catch (e) {
28+
console.error('[MEMFS lookup failed]',
29+
'parent:', Module.FS.getPath(parent),
30+
'name:', name, e);
31+
throw e;
32+
}
33+
};
34+
35+
Module.FS_createPath('/', 'data', true, true);
36+
37+
try {
38+
FS.mkdir('/persistent');
39+
FS.mount(IDBFS, {autoPersist: true}, '/persistent');
40+
FS.syncfs(true, err => {
41+
if (err) console.error('Failed to sync from IDBFS', err);
42+
else console.log('Synced from IDBFS');
43+
});
44+
45+
setInterval(() => {
46+
FS.syncfs(false, err => {
47+
if (err) console.error('Failed to sync to IDBFS', err);
48+
else console.log('Synced to IDBFS');
49+
});
50+
}, 10000);
51+
} catch (e) {}
52+
53+
Module.addRunDependency(runDependency);
54+
fetch('./main.zip')
55+
.then(function (response) {
56+
if (!response.ok) {
57+
throw new Error('HTTP ' + response.status + ' while fetching main.zip');
58+
}
59+
return response.arrayBuffer();
60+
})
61+
.then(function (buffer) {
62+
const data = new Uint8Array(buffer);
63+
Module.FS.writeFile('/data/main.zip', data, { canOwn: true });
64+
console.log('main.zip loaded:', Module.FS.readdir('/data'));
65+
})
66+
.catch(function (err) {
67+
console.error('Failed to load main.zip', err);
68+
throw err;
69+
})
70+
.finally(function () {
71+
Module.removeRunDependency(runDependency);
72+
});
73+
Module.addRunDependency(fontDependency);
74+
fetch('./font.zip')
75+
.then(function (response) {
76+
if (!response.ok) {
77+
throw new Error('HTTP ' + response.status + ' while fetching font.zip');
78+
}
79+
return response.arrayBuffer();
80+
})
81+
.then(function (buffer) {
82+
const data = new Uint8Array(buffer);
83+
Module.FS.writeFile('/data/font.zip', data, { canOwn: true });
84+
console.log('font.zip loaded:', Module.FS.readdir('/data'));
85+
})
86+
.catch(function (err) {
87+
console.error('Failed to load font.zip', err);
88+
throw err;
89+
})
90+
.finally(function () {
91+
Module.removeRunDependency(fontDependency);
92+
});
93+
}],
94+
onRuntimeInitialized: function () {
95+
console.log('Soluna runtime ready');
96+
},
97+
onExit: function (status) {
98+
console.log('Program exited with status', status);
99+
},
100+
onAbort: function (what) {
101+
console.error('Program aborted:', what);
102+
},
103+
print: console.log,
104+
printErr: console.error
105+
};
106+
</script>
107+
<script src="./soluna.js"></script>
108+
</body>
109+
</html>

.github/workflows/deploy.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Nightly Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
name: Build Soluna
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
steps:
19+
- uses: actions/checkout@v5
20+
with:
21+
submodules: recursive
22+
- uses: actions/checkout@v5
23+
with:
24+
repository: floooh/sokol-tools-bin
25+
ref: "a06f19929ff8f9824ec6dd87c21329b1f205809e"
26+
path: sokol-tools-bin
27+
fetch-depth: 1
28+
- name: Setup sokol-shdc
29+
shell: bash
30+
run: |
31+
TARGET_DIR="/usr/local/bin"
32+
SHDC_BINARY="sokol-shdc"
33+
FIND_PATH="bin/linux"
34+
echo "Setting up sokol-tools from sokol-tools-bin/$FIND_PATH"
35+
find sokol-tools-bin/$FIND_PATH -name $SHDC_BINARY -exec cp {} $TARGET_DIR \;
36+
$SHDC_BINARY -h
37+
- uses: yuchanns/actions-luamake@v1
38+
with:
39+
luamake-version: "5bedfce66f075a9f68b1475747738b81b3b41c25"
40+
- name: Install Dependencies
41+
run: |
42+
sudo apt-get update
43+
sudo apt-get install -y build-essential \
44+
libgl1-mesa-dev libglu1-mesa-dev libx11-dev \
45+
libxrandr-dev libxi-dev libxxf86vm-dev libxcursor-dev \
46+
libasound2-dev libfontconfig1-dev
47+
- uses: mymindstorm/setup-emsdk@v14
48+
- name: Build Emscripten
49+
shell: bash
50+
working-directory: soluna
51+
run: |
52+
luamake precompile
53+
luamake -compiler emcc precompile
54+
luamake -compiler emcc
55+
- name: Prepare Game Content
56+
shell: bash
57+
run: |
58+
mkdir build
59+
SOLUNA_BINARY="soluna.wasm"
60+
SOLUNA_PATH=$(find soluna/bin -name $SOLUNA_BINARY | head -n 1)
61+
SOLUNA_JS="soluna.js"
62+
SOLUNA_JS_PATH=$(find soluna/bin -name $SOLUNA_JS | head -n 1)
63+
cp "$SOLUNA_PATH" ./build/
64+
cp "$SOLUNA_JS_PATH" ./build/
65+
zip -r ./build/main.zip asset core gameplay localization service visual main.game main.lua
66+
cp .github/assets/index.html ./build/
67+
cp .github/assets/font.zip ./build/
68+
cp .github/assets/coi-serviceworker.min.js ./build/
69+
- name: Upload static files as artifact
70+
id: deployment
71+
uses: actions/upload-pages-artifact@v3
72+
with:
73+
path: build/
74+
deploy:
75+
name: Deploy to GitHub Pages
76+
needs: [build]
77+
runs-on: ubuntu-latest
78+
permissions:
79+
pages: write
80+
id-token: write
81+
environment:
82+
name: github-pages
83+
url: ${{ steps.deployment.outputs.page_url }}
84+
steps:
85+
- name: Deploy to GitHub Pages
86+
id: deployment
87+
uses: actions/deploy-pages@v4
88+
89+

localization/setting.dl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ setting :
2323
font : "Noto Sans"
2424
wasm :
2525
font : Arial
26-
fontfile : asset/font/WenQuanWeiMiHei-1.ttf
26+
fontfile : asset/font/arial.ttf
2727
timefmt : "%b %d, %Y %H:%M"
2828
homepage : "https://boardgamegeek.com/boardgame/194986/deep-future"

0 commit comments

Comments
 (0)