Skip to content
Closed
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
191 changes: 191 additions & 0 deletions .github/workflows/publish.itch.io.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
name: Publish to itch.io

on: workflow_dispatch

env:
# update with the name of the main binary
binary: bevy_github_ci_template
# update with the names of the itch.io user and game
itch_target: <itch.io-user>/<game>

jobs:
upload-to-itch:
runs-on: ubuntu-latest
needs:
- build-wasm
- build-linux
- build-windows
- build-mac

steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ./builds

- name: Install butler
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: Show what we have
run: |
ls -R

- name: Upload to itch.io
env:
BUTLER_API_KEY: ${{ secrets.BUTLER_CREDENTIALS }}
run: |
for channel in $(ls builds); do
echo ./butler push builds/$channel/* ${{ env.itch_target }}:$channel
./butler push builds/$channel/* ${{ env.itch_target }}:$channel
done

# Build for wasm
build-wasm:
runs-on: ubuntu-latest

steps:
- uses: little-core-labs/get-git-tag@v3.0.1
id: get_version
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
override: true
- name: install wasm-bindgen-cli
run: |
cargo install wasm-bindgen-cli

- name: Build
run: |
cargo build --release --target wasm32-unknown-unknown

- name: Prepare package
run: |
wasm-bindgen --no-typescript --out-name bevy_game --out-dir wasm --target web target/wasm32-unknown-unknown/release/${{ env.binary }}.wasm
cp -r assets wasm/

- name: Package as a zip
uses: vimtor/action-zip@v1
with:
files: wasm
dest: ${{ env.binary }}.zip

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
path: ${{ env.binary }}.zip
name: wasm

# Build for Linux
build-linux:
runs-on: ubuntu-latest

steps:
- uses: little-core-labs/get-git-tag@v3.0.1
id: get_version
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-unknown-linux-gnu
override: true
- name: install dependencies
run: |
sudo apt-get update; sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev

- name: Build
run: |
cargo build --release --target x86_64-unknown-linux-gnu

- name: Prepare package
run: |
mkdir linux
cp target/x86_64-unknown-linux-gnu/release/${{ env.binary }} linux/
cp -r assets linux/

- name: Package as a zip
working-directory: ./linux
run: |
zip --recurse-paths ../${{ env.binary }}.zip .

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
path: ${{ env.binary }}.zip
name: linux

# Build for Windows
build-windows:
runs-on: windows-latest

steps:
- uses: little-core-labs/get-git-tag@v3.0.1
id: get_version
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-pc-windows-msvc
override: true

- name: Build
run: |
cargo build --release --target x86_64-pc-windows-msvc

- name: Prepare package
run: |
mkdir windows
cp target/x86_64-pc-windows-msvc/release/${{ env.binary }}.exe windows/
cp -r assets windows/

- name: Package as a zip
uses: vimtor/action-zip@v1
with:
files: windows
dest: ${{ env.binary }}.zip

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
path: ${{ env.binary }}.zip
name: windows

# Build for macOS
build-mac:
runs-on: macOS-latest

steps:
- uses: little-core-labs/get-git-tag@v3.0.1
id: get_version
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-apple-darwin
override: true
- name: Environment Setup
run: |
export CFLAGS="-fno-stack-check"
export MACOSX_DEPLOYMENT_TARGET="10.9"

- name: Build
run: |
cargo build --release --target x86_64-apple-darwin

- name: Prepare Package
run: |
mkdir -p ${{ env.binary }}.app/Contents/MacOS
cp target/x86_64-apple-darwin/release/${{ env.binary }} ${{ env.binary }}.app/Contents/MacOS/
cp -r assets ${{ env.binary }}.app/Contents/MacOS/
hdiutil create -fs HFS+ -volname "${{ env.binary }}" -srcfolder ${{ env.binary }}.app ${{ env.binary }}.dmg

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
path: ${{ env.binary }}.dmg
name: mac
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,23 @@ A new release will be available in GitHub, with the archives per platform availb

The `git` commands above produced this release: [my-game-1.0](
https://github.com/bevyengine/bevy_github_ci_template/releases/tag/my-game-1.0).

## itch.io

Definition: [.github/workflows/publish.itch.io.yaml](./.github/workflows/publish.itch.io.yaml)

This workflow must be ran manually from GitHub UI. After pushing, go to the
repository's Actions tab, click on "Publish to itch.io" in the sidebar, and run
the workflow with the "Run workflow" button.

### Required Configuration

1. Create an API key in https://itch.io/user/settings/api-keys
2. Go to the repository's Settings tab in GitHub, click on Secrets->Actions in
the sidebar,and add a repository secret named `BUTLER_CREDENTIALS` set to
the API key.
3. Change the `env` settings in this file according to your game:
* Change `env.binary` to the name of the binary (without suffix) `cargo
build` produces.
* Change `env.itch_target` to the itch.io username and the name of the game
on itch.io, separated by a slash (`/`)