Automatically deploying EbitEngine games to itch.io

The following script is designed to build and deploy EbitEngine games to itch.io.

Please Note, I develop on a Linux system so if you run on Windows you will probably need to make some adjustments to this process. If you are not sure how I suggest using an LLM to help.

To follow along I recommend the following software and setup.

  1. Linux - I use PopOS
  2. Neovim - You can also use Visual Studio or any other text editor you are comfortable with
  3. Go - https://go.dev/doc/install
  4. Butler - https://itch.io/docs/butler/installing.html
  5. Just - https://just.systems/

The Just File

Open up your terminal and create a project directory for your game.

Then type in… vim justfile

Review the comments to understand what the script is doing

# justfile for building and deploying the game to Web, PC (Windows & Linux)

# Variables

# We are assuming that the script is located in the base project directory here

PROJECT_PATH := "."

# we are deploying our compiled files to the dist subdirectory

DIST_DIR := "dist"

# Make sure to set your version number here

VERSION := "0.0.0"

# Location of the WebAssembly JavaScript file provided by Go for web builds

GOROOT_WASM := `go env GOROOT` + "/lib/wasm/wasm_exec.js"

# Your itch.io username

BUTLER_USER := "ApocalypseTheory"

# Your itch.io project

BUTLER_PROJECT := ""

# Butler channels for each target

BUTLER_CHANNEL_WEB := "html5"
BUTLER_CHANNEL_WIN := "windows"
BUTLER_CHANNEL_LINUX := "linux"

# Default recipe if you type only just (shows help)

default:
	@just --list

# Show detailed help with explanations

help:
	@clear
	@echo "=== Game Build System Help ==="
	@echo ""
	@echo "This justfile automates building and deploying a Go game to multiple platforms:"
	@echo ""
	@echo "๐ŸŽฏ Main Targets:"
	@echo " just build - Build for all platforms (Web, Windows, Linux)"
	@echo " just deploy - Complete pipeline: depend โ†’ build โ†’ deploy โ†’ clean"
	@echo ""
	@echo "๐ŸŒ Web (HTML5) Targets:"
	@echo " just build-web - Build WebAssembly version for browsers"
	@echo " just deploy-web - Deploy web build to itch.io"
	@echo ""
	@echo "๐Ÿ–ฅ๏ธ Desktop Targets:"
	@echo " just build-pc-windows - Build Windows .exe"
	@echo " just build-pc-linux - Build Linux binary"
	@echo " just deploy-windows - Deploy Windows build to itch.io"
	@echo " just deploy-linux - Deploy Linux build to itch.io"
	@echo ""
	@echo "๐Ÿ”ง Utility Targets:"
	@echo " just clean - Remove all build artifacts"
	@echo " just depend - Update Go module dependencies"
	@echo " just demo - Run the Linux build locally (if exists)"
	@echo " just test - Run Go tests"
	@echo " just status - Check deployment status on itch.io"
	@echo ""
	@echo "๐Ÿ“‹ How it works:"
	@echo " 1. The game is written in Go and builds to multiple targets"
	@echo " 2. Web version uses WebAssembly (WASM) to run in browsers"
	@echo " 3. Desktop versions are native binaries for Windows/Linux"
	@echo " 4. Butler (itch.io CLI tool) handles deployment"
	@echo " 5. Each platform has its own build directory and deployment channel"
	@echo ""
	@echo "๐Ÿš€ Quick Start:"
	@echo " just build # Build for all platforms"
	@echo " just deploy # Build everything and deploy"
	@echo " just demo # Test the Linux build locally"

# Build all platforms

build: clean build-web build-pc-windows build-pc-linux
	@echo "=== All platform builds completed ==="

# Complete deployment pipeline

deploy: depend build deploy-all clean
	@echo "=== All builds and deployments completed successfully ==="

# Deploy all platforms

deploy-all: deploy-web deploy-windows deploy-linux
	@echo "=== All deployments completed ==="

# Build Web (HTML5/WebAssembly)

build-web:
	@echo "=== Building Web (HTML5) ==="
	@mkdir -p {{DIST_DIR}}/web
	@cp {{GOROOT_WASM}} {{DIST_DIR}}/web/
	@env GOOS=js GOARCH=wasm go build -o {{DIST_DIR}}/web/{{BUTLER_PROJECT}}.wasm {{PROJECT_PATH}}
	@echo '<!DOCTYPE html><html><head><meta charset="UTF-8"><title>{{BUTLER_PROJECT}}</title></head><body><script src="wasm_exec.js"></script><script>if(!WebAssembly.instantiateStreaming){WebAssembly.instantiateStreaming=async(resp,importObject)=>{const source=await(resp).arrayBuffer();return await WebAssembly.instantiate(source,importObject);};}const go=new Go();WebAssembly.instantiateStreaming(fetch("{{BUTLER_PROJECT}}.wasm"),go.importObject).then(result=>{go.run(result.instance);});</script></body></html>' > {{DIST_DIR}}/web/index.html
	@echo "Web (HTML5) build done."

# Deploy web build to itch.io

deploy-web:
	@echo "=== Deploying Web (HTML5) Build to itch.io ==="
	@butler push {{DIST_DIR}}/web {{BUTLER_USER}}/{{BUTLER_PROJECT}}:{{BUTLER_CHANNEL_WEB}} --userversion {{VERSION}}
	@echo "Web build deployed."

# Build Windows executable

build-pc-windows:
	@echo "=== Building for Windows ==="
	@mkdir -p {{DIST_DIR}}/pc/windows
	@env GOOS=windows GOARCH=amd64 go build -o {{DIST_DIR}}/pc/windows/{{BUTLER_PROJECT}}.exe {{PROJECT_PATH}}
	@echo "Windows build done."

# Deploy Windows build to itch.io

deploy-windows:
	@echo "=== Deploying Windows Build to itch.io ==="
	@butler push {{DIST_DIR}}/pc/windows {{BUTLER_USER}}/{{BUTLER_PROJECT}}:{{BUTLER_CHANNEL_WIN}} --userversion {{VERSION}}
	@echo "Windows build deployed."

# Build Linux binary

build-pc-linux:
	@echo "=== Building for Linux ==="
	@mkdir -p {{DIST_DIR}}/pc/linux
	@env GOOS=linux GOARCH=amd64 go build -o {{DIST_DIR}}/pc/linux/{{BUTLER_PROJECT}} {{PROJECT_PATH}}
	@echo "Linux build done."

# Deploy Linux build to itch.io

deploy-linux:
	@echo "=== Deploying Linux Build to itch.io ==="
	@butler push {{DIST_DIR}}/pc/linux {{BUTLER_USER}}/{{BUTLER_PROJECT}}:{{BUTLER_CHANNEL_LINUX}} --userversion {{VERSION}}
	@echo "Linux build deployed."

# Clean up build artifacts

clean:
	@echo "=== Cleaning up build artifacts ==="
	@rm -rf {{DIST_DIR}}
	@echo "All cleaned."

# Update Go module dependencies

depend:
	@echo "=== Updating Dependencies ==="
	@go mod tidy
	@echo "Dependencies updated."

# Check deployment status on itch.io

status:
	@echo "=== Checking Deployment Status on itch.io ==="
	@butler status {{BUTLER_USER}}/{{BUTLER_PROJECT}}:{{BUTLER_CHANNEL_WEB}}
	@butler status {{BUTLER_USER}}/{{BUTLER_PROJECT}}:{{BUTLER_CHANNEL_WIN}}
	@butler status {{BUTLER_USER}}/{{BUTLER_PROJECT}}:{{BUTLER_CHANNEL_LINUX}}

# Run the game locally (Linux build)

demo:
	@echo "=== Running the Game Locally (Linux Build) ==="
	@if [ -f {{DIST_DIR}}/pc/linux/{{BUTLER_PROJECT}} ]; then \
	 ./{{DIST_DIR}}/pc/linux/{{BUTLER_PROJECT}}; \
	 else \
	 echo 'No Linux build found at {{DIST_DIR}}/pc/linux/{{BUTLER_PROJECT}}'; \
	 echo 'Run "just build-pc-linux" first to create the Linux build.'; \
	 fi

# Run Go tests

test:
	@echo "=== Running Tests ==="
	@go test ./...
You are not alone
Favorite Quotes Day 1