Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions .github/workflows/itch-io-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Deploy to itch.io

on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: 'Tag to deploy (e.g., v0.4.0)'
required: true
type: string

jobs:
deploy-to-itch:
runs-on: ubuntu-latest
if: github.actor == 'commjoen' || github.event_name == 'release'

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test

- name: Build game
run: npm run build

- name: Get version from release
id: get_version
run: |
if [ "${{ github.event_name }}" = "release" ]; then
VERSION="${{ github.event.release.tag_name }}"
else
VERSION="${{ github.event.inputs.tag }}"
fi
# Remove 'v' prefix if present
VERSION=${VERSION#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Deploying version: $VERSION"

- name: Setup Butler (itch.io CLI)
run: |
curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default
unzip butler.zip
chmod +x butler
./butler -V

- name: Login to itch.io
env:
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
run: |
if [ -z "$BUTLER_API_KEY" ]; then
echo "❌ BUTLER_API_KEY secret not found!"
echo "Please add your itch.io API key as a repository secret named BUTLER_API_KEY"
echo "Get your API key from: https://itch.io/user/settings/api-keys"
exit 1
fi
./butler login

- name: Deploy to itch.io
env:
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
ITCH_USER: ${{ secrets.ITCH_USER || 'commjoen' }}
ITCH_GAME: ${{ secrets.ITCH_GAME || 'generated-game-experiment' }}
run: |
VERSION="${{ steps.get_version.outputs.version }}"

# Create a package for itch.io with the built game
mkdir -p itch-package
cp -r dist/* itch-package/

# Create a simple index file if needed (itch.io expects index.html at root)
if [ ! -f itch-package/index.html ]; then
echo "❌ No index.html found in build output!"
ls -la itch-package/
exit 1
fi

echo "📦 Packaging game for itch.io..."
echo "📁 Package contents:"
ls -la itch-package/

# Upload to itch.io using butler
echo "🚀 Uploading to itch.io..."
./butler push itch-package "${ITCH_USER}/${ITCH_GAME}:html" --userversion "$VERSION"

echo "✅ Successfully deployed version $VERSION to itch.io!"

- name: Generate deployment summary
run: |
VERSION="${{ steps.get_version.outputs.version }}"
ITCH_USER="${{ secrets.ITCH_USER || 'commjoen' }}"
ITCH_GAME="${{ secrets.ITCH_GAME || 'generated-game-experiment' }}"

echo "## 🎮 Game Deployed to itch.io!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version:** \`$VERSION\`" >> $GITHUB_STEP_SUMMARY
echo "**Game URL:** https://${ITCH_USER}.itch.io/${ITCH_GAME}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📊 Deployment Details" >> $GITHUB_STEP_SUMMARY
echo "- **Platform:** HTML5 (Web)" >> $GITHUB_STEP_SUMMARY
echo "- **Channel:** \`html\`" >> $GITHUB_STEP_SUMMARY
echo "- **User Version:** \`$VERSION\`" >> $GITHUB_STEP_SUMMARY
echo "- **Commit:** \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 🔗 Links" >> $GITHUB_STEP_SUMMARY
echo "- [Play on itch.io](https://${ITCH_USER}.itch.io/${ITCH_GAME})" >> $GITHUB_STEP_SUMMARY
echo "- [itch.io Dashboard](https://itch.io/dashboard)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### ⚡ Next Steps" >> $GITHUB_STEP_SUMMARY
echo "- Game is now live on itch.io" >> $GITHUB_STEP_SUMMARY
echo "- Players can access it immediately" >> $GITHUB_STEP_SUMMARY
echo "- Update game description and screenshots on itch.io if needed" >> $GITHUB_STEP_SUMMARY
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Deploy to GitHub Pages](https://github.com/commjoen/generated-game-experiment/actions/workflows/deploy.yml/badge.svg)](https://github.com/commjoen/generated-game-experiment/actions/workflows/deploy.yml)
[![Docker Build and Release](https://github.com/commjoen/generated-game-experiment/actions/workflows/docker-release.yml/badge.svg)](https://github.com/commjoen/generated-game-experiment/actions/workflows/docker-release.yml)
[![Create Release](https://github.com/commjoen/generated-game-experiment/actions/workflows/release.yml/badge.svg)](https://github.com/commjoen/generated-game-experiment/actions/workflows/release.yml)
[![Deploy to itch.io](https://github.com/commjoen/generated-game-experiment/actions/workflows/itch-io-deploy.yml/badge.svg)](https://github.com/commjoen/generated-game-experiment/actions/workflows/itch-io-deploy.yml)

<!-- Project Status -->
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
Expand All @@ -15,6 +16,7 @@
[![Live Demo](https://img.shields.io/badge/Live%20Demo-GitHub%20Pages-success.svg)](https://commjoen.github.io/generated-game-experiment/)
[![PR Previews](https://img.shields.io/badge/PR%20Previews-Enabled-blue.svg)](https://github.com/commjoen/generated-game-experiment/actions/workflows/pr-preview.yml)
[![Render Deployment](https://img.shields.io/badge/Render-Deployed-46E3B7.svg)](https://generated-game-experiment.onrender.com/)
[![itch.io](https://img.shields.io/badge/itch.io-Available-FA5C5C.svg?logo=itch.io)](https://commjoen.itch.io/generated-game-experiment)
[![Docker](https://img.shields.io/badge/Docker-Available-2496ED.svg)](https://github.com/commjoen/generated-game-experiment/pkgs/container/generated-game-experiment)

<!-- Quality & Security -->
Expand Down Expand Up @@ -45,6 +47,8 @@ A browser-based, side-scrolling platformer game built with TypeScript, Vite, and

[![Play Singleplayer on GitHub Pages](https://img.shields.io/badge/🎮%20Play%20Singleplayer-on%20GitHub%20Pages-238636?style=for-the-badge&logo=github)](https://commjoen.github.io/generated-game-experiment/)

[![Play on itch.io](https://img.shields.io/badge/🎮%20Play%20on-itch.io-FA5C5C?style=for-the-badge&logo=itch.io)](https://commjoen.itch.io/generated-game-experiment)

## Features
- **Procedural Levels**: Each run generates a new level with platforms, spikes, moving platforms, and boxes.
- **Collectibles & Power-Ups**: Coins (score), hearts (lives), double jump (feather), and grow (mushroom, up to 3x size per life).
Expand Down Expand Up @@ -112,6 +116,36 @@ A browser-based, side-scrolling platformer game built with TypeScript, Vite, and
- **PR Previews**: Each pull request gets its own preview deployment at `https://commjoen.github.io/generated-game-experiment/pr-{number}/`
- Preview deployments are automatically cleaned up when PRs are closed or merged

## itch.io Deployment
- **Automatic**: Game is automatically deployed to itch.io when a new release is created
- **Manual**: Can be triggered manually via GitHub Actions workflow dispatch
- **Live at**: https://commjoen.itch.io/generated-game-experiment

### Setting up itch.io Integration
To enable automatic itch.io deployments, you need to configure the following repository secrets:

1. **`BUTLER_API_KEY`** (Required): Your itch.io API key
- Go to https://itch.io/user/settings/api-keys
- Generate a new API key
- Add it as a repository secret

2. **`ITCH_USER`** (Optional): Your itch.io username
- Defaults to `commjoen` if not provided
- Override if deploying to a different itch.io account

3. **`ITCH_GAME`** (Optional): Your itch.io game slug
- Defaults to `generated-game-experiment` if not provided
- Should match your game's URL: `https://[username].itch.io/[game-slug]`

📖 **For detailed setup instructions, see: [docs/ITCH_IO_SETUP.md](docs/ITCH_IO_SETUP.md)**

### How it works
- Triggers automatically when a release is published
- Builds the game using `npm run build`
- Uses itch.io's `butler` CLI tool to upload the HTML5 build
- Deploys to the `html` channel on itch.io
- Version matches the GitHub release tag

## Testing
- Run all tests:
```sh
Expand Down
2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
pointer-events: auto;
}
</style>
<script type="module" crossorigin="" src="/assets/index-Bq2tbWeD.js" integrity="sha384-8NgW6nLuUohQeqkDdUdKhWRvd3hJIK3Bby5wqOfLjLfQLfsGOwvWlDZ8TtXnJUSF"></script>
<script type="module" crossorigin="" src="/assets/index-08sue6YH.js" integrity="sha384-KlSNRdUJzN4m3lzScSRhe2UbxUfYGZZBKT7ArGRMA6BRx8Gxc5Wnmf5koiNnhSnI"></script>
</head>
<body>
<main id="main-content" role="main" tabindex="-1">
Expand Down
141 changes: 141 additions & 0 deletions docs/DEPLOYMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# Deployment Guide

This project supports multiple deployment methods for different use cases. All deployments are automated through GitHub Actions.

## 🚀 Deployment Options

### 1. GitHub Pages (Singleplayer)
- **URL**: https://commjoen.github.io/generated-game-experiment/
- **Trigger**: Automatic on every push to `main`
- **Use Case**: Static hosting, singleplayer mode
- **Workflow**: `.github/workflows/deploy.yml`

### 2. Render.com (Multiplayer)
- **URL**: https://generated-game-experiment.onrender.com/
- **Trigger**: Automatic on pushes via render.yaml
- **Use Case**: Full multiplayer support with WebSocket server
- **Config**: `render.yaml`

### 3. itch.io (Game Distribution)
- **URL**: https://commjoen.itch.io/generated-game-experiment
- **Trigger**: Automatic on releases
- **Use Case**: Game distribution platform
- **Workflow**: `.github/workflows/itch-io-deploy.yml`
- **Setup**: See [ITCH_IO_SETUP.md](ITCH_IO_SETUP.md)

### 4. Docker (Self-hosted)
- **Registry**: ghcr.io/commjoen/generated-game-experiment
- **Trigger**: Automatic on releases and PRs
- **Use Case**: Self-hosted deployment with full control
- **Workflow**: `.github/workflows/docker-release.yml`

### 5. PR Previews
- **URL Pattern**: https://commjoen.github.io/generated-game-experiment/pr-{number}/
- **Trigger**: Automatic on pull requests
- **Use Case**: Testing changes before merge
- **Workflow**: `.github/workflows/pr-preview.yml`

## 🔄 Deployment Flow

```mermaid
graph TD
A[Code Changes] --> B{Where?}
B -->|Pull Request| C[PR Preview Deploy]
B -->|Push to main| D[GitHub Pages Deploy]
B -->|Push to main| E[Render Deploy]
B -->|Create Release| F[Multiple Deployments]
F --> G[Docker Release]
F --> H[itch.io Deploy]
F --> I[Docker Hub]
```

## ⚙️ Setup Requirements

### GitHub Pages
- No setup required - works out of the box

### Render.com
- Connect GitHub repository to Render
- `render.yaml` configuration included

### itch.io
- `BUTLER_API_KEY` secret required
- Optional: `ITCH_USER`, `ITCH_GAME` secrets
- Game page must exist on itch.io

### Docker
- GitHub Container Registry - works automatically
- Docker Hub - requires `DOCKER_HUB_USERNAME` and `DOCKER_HUB_TOKEN` secrets

## 🏷️ Version Management

All deployments use semantic versioning:
- Tags: `v1.0.0`, `v1.0.1`, etc.
- Docker images get multiple tags: `v1.0.0`, `1.0`, `1`, `latest`
- itch.io uses the tag version as the user version

## 🔧 Manual Deployment

### Create a Release
```bash
# Trigger all deployment methods
gh workflow run release.yml -f version_type=patch
```

### Deploy to itch.io manually
```bash
# Deploy specific version
gh workflow run itch-io-deploy.yml -f tag=v1.0.0
```

### Deploy Docker manually
```bash
# Trigger Docker build
gh workflow run docker-release.yml
```

## 🛠️ Troubleshooting

### Common Issues

1. **GitHub Pages not updating**
- Check Actions tab for build failures
- Verify `dist/` directory is being generated

2. **Render deployment failing**
- Check Render dashboard for logs
- Verify `render.yaml` configuration

3. **itch.io deployment failing**
- Check `BUTLER_API_KEY` secret
- Verify game page exists on itch.io
- See detailed troubleshooting in [ITCH_IO_SETUP.md](ITCH_IO_SETUP.md)

4. **Docker build failing**
- Check for dependency issues
- Verify Dockerfile syntax
- Check Actions logs for detailed errors

### Logs and Monitoring

- **GitHub Actions**: Repository → Actions tab
- **Render**: Render dashboard → Logs
- **itch.io**: GitHub Actions logs for deployment status
- **Docker**: GitHub Container Registry for image details

## 📊 Deployment Matrix

| Platform | Mode | Server | Build Time | Auto Deploy | Manual Deploy |
|----------|------|--------|------------|-------------|---------------|
| GitHub Pages | Single | Static | ~2 min | ✅ Push | ❌ |
| Render | Multi | Express | ~5 min | ✅ Push | ✅ |
| itch.io | Single | Static | ~3 min | ✅ Release | ✅ |
| Docker | Multi | Express | ~8 min | ✅ Release | ✅ |
| PR Preview | Single | Static | ~2 min | ✅ PR | ❌ |

## 🔒 Security

- All secrets are stored securely in GitHub repository settings
- Docker images are scanned with Trivy for vulnerabilities
- No credentials are logged or exposed in workflows
- itch.io API keys have limited scope for deployment only
Loading