Skip to content

Release

Release #1

Workflow file for this run

name: Release
on:
push:
tags:
- "*"
workflow_dispatch: {}
env:
# update with the name of the main binary
add_binaries_to_github_release: github.ref_type == 'tag' && github.ref_name && true
release_version: ${{ (github.ref_type == 'tag' && github.ref_name) || format('{0}_{1}', github.ref_name, github.run_number) }}
concurrency:
group: release
cancel-in-progress: true
jobs:
setup-build-name:
outputs:
binary: ${{ steps.setup-build-name.outputs.BIN }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: setup-build-name
run: |
NAME=$( sed -n 's/^name = "\(.*\)"/\1/p' < ./Cargo.toml )
echo "binary: _$NAME_"
echo "BIN=$NAME" >> $GITHUB_OUTPUT
# Build for wasm
release-wasm:
runs-on: ubuntu-latest
needs: setup-build-name
steps:
- run: |
echo "Binary is ${{ needs.setup-build-name.outputs.binary}}"
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: wasm32-unknown-unknown
- 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 alsa
- name: binstall
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
- name: wasm-bindgen-cli
run: cargo binstall -y wasm-bindgen-cli
- name: Build
run: |
chmod +x ./web-build.sh
./web-build.sh
- name: Package as a zip
working-directory: ./dist
run: |
zip --recurse-paths ../${{ needs.setup-build-name.outputs.binary}}.zip .
- name: Upload binaries to artifacts
uses: actions/upload-artifact@v3
with:
path: ${{ needs.setup-build-name.outputs.binary}}.zip
name: wasm
- name: Fix permissions
run: |
chmod -c -R +rX "dist/" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v2
with:
path: ./dist
- name: Upload binaries to release
if: ${{ env.add_binaries_to_github_release == 'true' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ needs.setup-build-name.outputs.binary}}.zip
asset_name: ${{ needs.setup-build-name.outputs.binary}}-wasm-${{ env.release_version }}.zip
tag: ${{ env.release_version }}
overwrite: true
# Build for Linux
release-linux:
runs-on: ubuntu-latest
needs: setup-build-name
steps:
- run: |
echo "Binary is ${{ needs.setup-build-name.outputs.binary}}"
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: x86_64-unknown-linux-gnu
- 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/${{ needs.setup-build-name.outputs.binary}} linux/
cp -r assets linux/
- name: Package as a zip
working-directory: ./linux
run: |
zip --recurse-paths ../${{ needs.setup-build-name.outputs.binary}}.zip .
- name: Upload binaries to artifacts
uses: actions/upload-artifact@v3
with:
path: ${{ needs.setup-build-name.outputs.binary}}.zip
name: linux
- name: Upload binaries to release
if: ${{ env.add_binaries_to_github_release == 'true' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ needs.setup-build-name.outputs.binary}}.zip
asset_name: ${{ needs.setup-build-name.outputs.binary}}-linux-${{ env.release_version }}.zip
tag: ${{ env.release_version }}
overwrite: true
# Build for Windows
release-windows:
runs-on: windows-latest
needs: setup-build-name
steps:
- run: |
echo "Binary is ${{ needs.setup-build-name.outputs.binary}}"
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: x86_64-pc-windows-msvc
- 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/${{ needs.setup-build-name.outputs.binary}}.exe windows/
cp -r assets windows/
- name: Package as a zip
run: |
Compress-Archive -Path windows/* -DestinationPath ${{ needs.setup-build-name.outputs.binary}}.zip
- name: Upload binaries to artifacts
uses: actions/upload-artifact@v3
with:
path: ${{ needs.setup-build-name.outputs.binary}}.zip
name: windows
- name: Upload binaries to release
if: ${{ env.add_binaries_to_github_release == 'true' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ needs.setup-build-name.outputs.binary}}.zip
asset_name: ${{ needs.setup-build-name.outputs.binary}}-windows-${{ env.release_version }}.zip
tag: ${{ env.release_version }}
overwrite: true
# Build for macOS
release-macos:
runs-on: macOS-latest
needs: setup-build-name
steps:
- run: |
echo "Binary is ${{ needs.setup-build-name.outputs.binary}}"
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: x86_64-apple-darwin
- 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 ${{ needs.setup-build-name.outputs.binary}}.app/Contents/MacOS
cp target/x86_64-apple-darwin/release/${{ needs.setup-build-name.outputs.binary}} ${{ needs.setup-build-name.outputs.binary}}.app/Contents/MacOS/
cp -r assets ${{ needs.setup-build-name.outputs.binary}}.app/Contents/MacOS/
hdiutil create -fs HFS+ -volname " ${{ needs.setup-build-name.outputs.binary}}" -srcfolder ${{ needs.setup-build-name.outputs.binary}}.app ${{ needs.setup-build-name.outputs.binary}}.dmg
- name: Upload binaries to artifacts
uses: actions/upload-artifact@v3
with:
path: ${{ needs.setup-build-name.outputs.binary}}.dmg
name: mac
- name: Upload binaries to release
if: ${{ env.add_binaries_to_github_release == 'true' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ needs.setup-build-name.outputs.binary}}.dmg
asset_name: ${{ needs.setup-build-name.outputs.binary}}-macos-${{ env.release_version }}.dmg
tag: ${{ env.release_version }}
overwrite: true
check-if-upload-to-itch-is-configured:
needs: setup-build-name
runs-on: ubuntu-latest
outputs:
should-upload: ${{ steps.check-env.outputs.has-itch-target }}
steps:
- run: |
echo "Binary is ${{ needs.setup-build-name.outputs.binary}}"
- id: check-env
run: |
if [[ -z "$itch_target" ]]; then
echo "has-itch-target=no" >> $GITHUB_OUTPUT
else
echo "has-itch-target=yes" >> $GITHUB_OUTPUT
fi
- name: validate ref
run: echo "RELEASE - ${{ env.release_version}}"
upload-to-github:
runs-on: ubuntu-latest
needs: release-wasm
permissions:
pages: write # to deploy to Pages
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to Github Pages
id: deployment
uses: actions/deploy-pages@v2
with:
artifact_name: github-pages
upload-to-itch:
runs-on: ubuntu-latest
needs:
- check-if-upload-to-itch-is-configured
- release-wasm
- release-linux
- release-windows
- release-macos
if: ${{ needs.check-if-upload-to-itch-is-configured.outputs.should-upload == 'yes' }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ./builds
- name: remove pages
run: rm -rf ./builds/github-pages
- 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: Upload to itch.io
env:
BUTLER_API_KEY: ${{ secrets.BUTLER_CREDENTIALS }}
run: |
for channel in $(ls builds); do
./butler push \
--fix-permissions \
--userversion="${{ env.release_version }}" \
builds/$channel/* \
${{ env.itch_target }}:$channel
done