diff --git a/.gitignore b/.gitignore index fd4d60b..8710c02 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ dist .DS_Store *.local .claude +.version +*.html.zip +*.metadata.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..da46e68 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,28 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Serve", + "type": "shell", + "command": "make serve", + "problemMatcher": [], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "Build Web", + "type": "shell", + "command": "make web", + "problemMatcher": [] + }, + { + "label": "Make build", + "type": "shell", + "command": "make build" + } + ] +} diff --git a/.woodpecker.yaml b/.woodpecker.yaml new file mode 100644 index 0000000..a26b34a --- /dev/null +++ b/.woodpecker.yaml @@ -0,0 +1,34 @@ +steps: + - name: version + image: alpine + commands: + - apk add --no-cache git make jq + - make ci-version + + - name: build + image: git.teletypegames.org/internal/phaser-builder:latest + commands: + - make ci-export + + - name: upload + image: alpine + environment: + DROPAREA_HOST: vps.teletype.hu + DROPAREA_PORT: 2223 + DROPAREA_TARGET_PATH: /home/drop + DROPAREA_USER: drop + DROPAREA_SSH_PASSWORD: + from_secret: droparea_ssh_password + commands: + - apk add --no-cache make openssh-client sshpass + - make ci-upload + + - name: update + image: alpine + environment: + UPDATE_SERVER: https://teletypegames.org + UPDATE_SECRET: + from_secret: update_secret_key + commands: + - apk add --no-cache make curl + - make ci-update diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5cd0133 --- /dev/null +++ b/Makefile @@ -0,0 +1,75 @@ +# ----------------------------------------- +# Makefile – Phaser (Vite + TypeScript) project builder +# ----------------------------------------- + +PROJECT = trickster-tiles + +DIST_DIR = dist +OUTPUT_ZIP = $(PROJECT)-$(VERSION).html.zip + +VERSION_FILE = .version + +all: build + +node_modules: package.json package-lock.json + npm ci + +build: node_modules + @echo "==> Type-checking + bundling (tsc + vite)" + npm run build + +web: build + +serve: node_modules + @echo "==> Serving production build on http://localhost:4173" + npm run preview + +dev: node_modules + npm run dev + +export: web + @if [ -z "$(VERSION)" ]; then \ + echo "ERROR: VERSION not set!"; exit 1; \ + fi + @echo "==> Packaging web build for $(VERSION)" + cd $(DIST_DIR) && zip -r ../$(OUTPUT_ZIP) . + @echo "==> Cleaning temporary files" + rm -rf $(DIST_DIR) + +watch: + fswatch -o src | while read; do make build; done + +clean: + rm -rf $(DIST_DIR) + +ci-version: + @if [ -f metadata.json ]; then \ + VERSION=$$(jq -r '.version' metadata.json); \ + else \ + VERSION=$$(git rev-parse --short HEAD); \ + fi; \ + BRANCH=$$(git rev-parse --abbrev-ref HEAD); \ + if [ "$$BRANCH" != "main" ] && [ "$$BRANCH" != "master" ]; then \ + VERSION="dev-$$VERSION-$$BRANCH"; \ + fi; \ + echo $$VERSION > $(VERSION_FILE) + +ci-export: + @VERSION=$$(cat $(VERSION_FILE)); \ + $(MAKE) export VERSION=$$VERSION + +ci-upload: + @VERSION=$$(cat $(VERSION_FILE)); \ + FILE="$(PROJECT)-$$VERSION.html.zip"; \ + META_SRC="metadata.json"; \ + META_DST="$(PROJECT)-$$VERSION.metadata.json"; \ + cp $$META_SRC $$META_DST; \ + sshpass -p "$(DROPAREA_SSH_PASSWORD)" scp -o StrictHostKeyChecking=no -P $(DROPAREA_PORT) \ + $$FILE $$META_DST \ + $(DROPAREA_USER)@$(DROPAREA_HOST):$(DROPAREA_TARGET_PATH)/ + +ci-update: + @VERSION=$$(cat $(VERSION_FILE)); \ + curl "$(UPDATE_SERVER)/update?secret=$(UPDATE_SECRET)&name=$(PROJECT)&platform=phaser&version=$$VERSION" + +.PHONY: all build web serve dev export watch clean ci-version ci-export ci-upload ci-update diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..9d5e13b --- /dev/null +++ b/metadata.json @@ -0,0 +1,9 @@ +{ + "name": "trickster-tiles", + "title": "Trickster Tiles", + "author": "Teletype Games", + "desc": "A small pixel-art platformer: hop, jump, and outwit moving spikes and disappearing tiles across 10 levels. Made with Phaser 3.", + "site": "https://git.teletypegames.org/games/trickster-tiles", + "license": "MIT License", + "version": "0.1.0" +} diff --git a/package.json b/package.json index 4480b71..160acd0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "trickster-tiles", "private": true, - "version": "0.0.0", + "version": "0.1.0", "type": "module", "scripts": { "dev": "vite",