Build bundled Phaser projects with their own toolchain

The step assumed one project shape: plain sources concatenated with cat
and Phaser pulled from a CDN. trickster-tiles is the other shape — Vite
plus TypeScript, built with `tsc && vite build` — so `cat src/*.js`
found nothing to bundle and the build failed. The earlier guard on the
syntax check fixed only the first symptom of that mismatch.

A project with a build script now runs npm ci && npm run build and is
packaged from its own dist/, which already contains index.html and the
hashed assets. Plain projects keep the existing path untouched.

The bundler's base has to be relative, since games are served out of
/file/<name>-<version>/; the step fails loudly if the build leaves no
dist/index.html rather than shipping an empty zip.

Verified in the phaser-builder image against trickster-tiles: a 344 kB
package with index.html at the root and ./assets/ references.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-16 23:12:12 +02:00
co-authored by Claude Opus 5
parent 64b5c16dc3
commit 9b5c05e647
@@ -22,19 +22,42 @@ steps:
commands: commands:
- | - |
VERSION=$(cat .version) VERSION=$(cat .version)
echo "==> Checking JS syntax" # Ketfele projektforma el egymas mellett: a sima JS (a forrasok
for f in src/*.js; do [ -e "$f" ] || continue; node --check "$f"; done # osszefuzve, a Phaser CDN-rol) es a bundleres (Vite + TypeScript),
mkdir -p dist/web # ami maga allitja elo a kesz webes csomagot.
echo "==> Downloading Phaser 3.90.0" if [ -f package.json ] && grep -q '"build"' package.json; then
curl -sSL https://cdn.jsdelivr.net/npm/phaser@3.90.0/dist/phaser.min.js -o dist/web/phaser.min.js echo "==> Bundled project — npm ci && npm run build"
echo "==> Downloading index.html" npm ci
curl -sSL https://git.teletypegames.org/tools/phaser-tools/raw/branch/master/web/index.html -o dist/web/index.html npm run build
echo "==> Bundling game sources" # A Vite kimenete onmagaban teljes: index.html + a beforgatott
cat src/*.js > dist/web/game.js # assetek. A vite.config base-enek relativnak kell lennie, mert a
echo "==> Packaging web build for $VERSION" # jatek a /file/<nev>-<verzio>/ alkonyvtarbol szolgal ki.
(cd dist/web && zip -r "../../<%= name %>-$VERSION.html.zip" .) if [ ! -f dist/index.html ]; then
echo "==> Cleaning temporary files" echo "ERROR: a build nem hagyott dist/index.html-t" >&2
rm -rf dist/web exit 1
fi
echo "==> Packaging web build for $VERSION"
(cd dist && zip -r "../<%= name %>-$VERSION.html.zip" .)
echo "==> Cleaning temporary files"
rm -rf dist
else
echo "==> Checking JS syntax"
# A bundleres projektben nincs src/*.js, es a shell ilyenkor a
# mintat adja tovabb literalkent — a node MODULE_NOT_FOUND-dal
# szall el rajta.
for f in src/*.js; do [ -e "$f" ] || continue; node --check "$f"; done
mkdir -p dist/web
echo "==> Downloading Phaser 3.90.0"
curl -sSL https://cdn.jsdelivr.net/npm/phaser@3.90.0/dist/phaser.min.js -o dist/web/phaser.min.js
echo "==> Downloading index.html"
curl -sSL https://git.teletypegames.org/build/phaser-tools/raw/branch/master/web/index.html -o dist/web/index.html
echo "==> Bundling game sources"
cat src/*.js > dist/web/game.js
echo "==> Packaging web build for $VERSION"
(cd dist/web && zip -r "../../<%= name %>-$VERSION.html.zip" .)
echo "==> Cleaning temporary files"
rm -rf dist/web
fi
- name: upload - name: upload
image: alpine image: alpine