diff --git a/README.md b/README.md index 6b13c0b..7aa7065 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,15 @@ CI/CD templates for [TIC-80](https://tic80.com) (Lua) game projects. - `example-makefile.make` — project Makefile: local dev targets - (`build`, `minify`, `watch`, `lint`, `docs`, `import_assets`, - `export_assets`, `clean`, `install_precommit_hook`) plus the - Woodpecker pipeline targets (`ci-version`, `ci-lint`, `ci-minify`, - `ci-docs`, `ci-export`, `ci-artifact`, `ci-update`). + (`build`, `minify`, `binaries`, `watch`, `lint`, `docs`, + `import_assets`, `export_assets`, `clean`, `install_precommit_hook`) + plus the Woodpecker pipeline targets (`ci-version`, `ci-lint`, + `ci-minify`, `ci-docs`, `ci-export`, `ci-binaries`, `ci-artifact`, + `ci-update`). - `example-woodpecker.yaml` — Woodpecker pipeline: version → lint → - minify → docs → export (TIC-80 Pro image) → artifact (scp to the - droparea) → update (calls the teletypegames `/update` endpoint with - `platform=tic80`). + minify → docs → export (TIC-80 Pro image) → binaries (native + players, same image) → artifact (scp to the droparea) → update + (calls the teletypegames `/update` endpoint with `platform=tic80`). - `example-tasks.json` — VS Code `.vscode/tasks.json` with the common dev tasks: **Run TIC80** (default build task, `Cmd+Shift+B`), **Build & Run TIC80**, **Export assets** and **Make build**. @@ -25,8 +26,28 @@ CI/CD templates for [TIC-80](https://tic80.com) (Lua) game projects. 3. Copy `example-tasks.json` to `.vscode/tasks.json` and replace the cart name (`impostor.lua`) with `$(PROJECT).lua`. -The pipeline uploads `$(PROJECT)-$(VERSION).lua`, `.tic`, `.html.zip` -and `-docs.zip` to the droparea, then triggers -`/update?platform=tic80&name=$(PROJECT)&version=$(VERSION)`. +The pipeline uploads `$(PROJECT)-$(VERSION).lua`, `.tic`, `.html.zip`, +`-docs.zip` and the native player zips (`-win-x64.zip`, +`-linux-x64.zip`, `-mac-x64.zip`) to the droparea, then triggers +`/update?platform=tic80&name=$(PROJECT)&version=$(VERSION)`. The API's +`BinaryAttachment` concern picks up the `--.zip` +files automatically and registers them as `win_x64` / `linux_x64` / +`mac_x64` release assets. + +## Native binaries + +`make binaries VERSION=x.y` runs TIC-80's `export win / linux / mac`, +which produces self-contained players with the cart baked in. Two +things to know: + +- The player templates are **downloaded from tic80.com at export + time**, so the CI step needs network access (the Woodpecker steps + have it — the same way the artifact step reaches the droparea). +- All upstream players are x86-64 — the mac binary is Intel-only + (runs via Rosetta on Apple Silicon), hence the `mac-x64` slug. + +Each binary is zipped with a single `$(PROJECT)-$(VERSION)-/` +root folder; the zip is created on unix so the executable bit +survives. Detailed documentation lives on the wiki: `/development/tic80`. diff --git a/example-makefile.make b/example-makefile.make index a0678c1..74b914f 100644 --- a/example-makefile.make +++ b/example-makefile.make @@ -67,6 +67,41 @@ export: minify @echo "==> Generated files:" @ls -lh $(PROJECT)-$(VERSION).* $(PROJECT).tic $(PROJECT).html.zip 2>/dev/null || true +# ----------------------------------------- +# Native binaries — self-contained TIC-80 players with the cart baked in. +# The player templates are downloaded from tic80.com at export time, so +# this target needs network access. All upstream players are x86-64, +# hence the win-x64 / linux-x64 / mac-x64 slugs (the API maps +# --.zip droparea files to ReleaseAsset kinds). +# ----------------------------------------- + +BINARY_SLUGS = win-x64 linux-x64 mac-x64 + +# $(1) slug, $(2) exported file, $(3) file name inside the package +# (unixos zip őrzi a végrehajtási bitet) +define f_pack_binary + PKG_DIR="$(PROJECT)-$(VERSION)-$(1)"; \ + rm -rf "$$PKG_DIR" "$$PKG_DIR.zip"; \ + mkdir -p "$$PKG_DIR"; \ + mv "$(2)" "$$PKG_DIR/$(3)"; \ + chmod +x "$$PKG_DIR/$(3)"; \ + zip -r "$$PKG_DIR.zip" "$$PKG_DIR" >/dev/null; \ + rm -rf "$$PKG_DIR"; \ + echo "==> $$PKG_DIR.zip kesz" +endef + +binaries: + @if [ -z "$(VERSION)" ]; then \ + echo "ERROR: VERSION not set!"; \ + exit 1; \ + fi + @echo "==> Exporting native players for version $(VERSION)" + @tic80 --cli --skip --fs=. \ + --cmd="load $(OUTPUT) & export win $(PROJECT)-win & export linux $(PROJECT)-linux & export mac $(PROJECT)-mac & exit" + @$(call f_pack_binary,win-x64,$(PROJECT)-win.exe,$(PROJECT).exe) + @$(call f_pack_binary,linux-x64,$(PROJECT)-linux,$(PROJECT)) + @$(call f_pack_binary,mac-x64,$(PROJECT)-mac,$(PROJECT)) + watch: $(MAKE) build fswatch -o $(SRC_DIR) $(ORDER) assets | while read; do $(MAKE) build; done @@ -167,6 +202,8 @@ export_assets: clean: @rm -f $(PROJECT)-*.tic $(PROJECT)-*.html.zip $(PROJECT)-*-docs.zip $(PROJECT)-docs.zip $(OUTPUT) $(OUTPUT_ORIGINAL) + @rm -f $(PROJECT)-*-win-x64.zip $(PROJECT)-*-linux-x64.zip $(PROJECT)-*-mac-x64.zip + @rm -f $(PROJECT)-win.exe $(PROJECT)-linux $(PROJECT)-mac @echo "==> Cleaned build artifacts" install_precommit_hook: @@ -238,16 +275,25 @@ ci-export: echo "==> Generated files:"; \ ls -lh $(PROJECT)-$$VERSION.* $(PROJECT).tic $(PROJECT).html.zip 2>/dev/null || true +ci-binaries: + @VERSION=$$(cat $(VERSION_FILE)); \ + $(MAKE) binaries VERSION=$$VERSION + ci-artifact: @VERSION=$$(cat $(VERSION_FILE)); \ echo "==> Uploading artifacts for version $$VERSION"; \ cp $(PROJECT).lua $(PROJECT)-$$VERSION.lua; \ + BINS=""; \ + for slug in $(BINARY_SLUGS); do \ + [ -f "$(PROJECT)-$$VERSION-$$slug.zip" ] && BINS="$$BINS $(PROJECT)-$$VERSION-$$slug.zip"; \ + done; \ SCP_TARGET="$(DROPAREA_USER)@$(DROPAREA_HOST):$(DROPAREA_TARGET_PATH)/"; \ sshpass -p "$(DROPAREA_SSH_PASSWORD)" scp -o StrictHostKeyChecking=no -P $(DROPAREA_PORT) \ $(PROJECT)-$$VERSION.lua \ $(PROJECT)-$$VERSION.tic \ $(PROJECT)-$$VERSION.html.zip \ $(PROJECT)-$$VERSION-docs.zip \ + $$BINS \ $$SCP_TARGET ci-update: @@ -255,4 +301,4 @@ ci-update: echo "==> Triggering update for version $$VERSION"; \ curl "$(UPDATE_SERVER)/update?secret=$(UPDATE_SECRET)&name=$(PROJECT)&platform=tic80&version=$$VERSION" -.PHONY: all build download-minify minify export watch import_assets export_assets clean lint install_precommit_hook docs ci-version ci-lint ci-minify ci-docs ci-export ci-artifact ci-update +.PHONY: all build download-minify minify export binaries watch import_assets export_assets clean lint install_precommit_hook docs ci-version ci-lint ci-minify ci-docs ci-export ci-binaries ci-artifact ci-update diff --git a/example-woodpecker.yaml b/example-woodpecker.yaml index 08e3b3f..88f0031 100644 --- a/example-woodpecker.yaml +++ b/example-woodpecker.yaml @@ -31,12 +31,19 @@ steps: - 'make ci-docs' - name: export - image: git.teletype.hu/internal/tic80pro:latest + image: git.teletypegames.org/internal/tic80pro:latest environment: XDG_RUNTIME_DIR: /tmp commands: - 'make ci-export' + - name: binaries + image: git.teletypegames.org/internal/tic80pro:latest + environment: + XDG_RUNTIME_DIR: /tmp + commands: + - 'make ci-binaries' + - name: artifact image: alpine environment: