-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: release-flow | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v[0-9]+.[0-9]+.[0-9]+*" | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version - in the form of v1.2.3' | ||
required: true | ||
type: string | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
get-version: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get tag | ||
id: tag | ||
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT" | ||
outputs: | ||
version: ${{ inputs.version || steps.tag.outputs.tag }} | ||
|
||
build-web: | ||
runs-on: ubuntu-latest | ||
needs: get-version | ||
env: | ||
VERSION: ${{needs.get-version.outputs.version}} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Install rust toolchain | ||
uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: stable | ||
- name: Install Dependencies | ||
run: sudo apt-get update; sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev | ||
- name: Install trunk | ||
uses: jetli/[email protected] | ||
with: | ||
version: latest | ||
- name: Add wasm target | ||
run: | | ||
rustup target add wasm32-unknown-unknown | ||
- name: Build Release | ||
run: | | ||
trunk build --release | ||
- name: Optimize Wasm | ||
uses: NiklasEi/wasm-opt-action@v2 | ||
with: | ||
file: dist/*.wasm | ||
# Trunk cannot import assets from relative paths (see e.g. https://github.com/thedodd/trunk/issues/395) | ||
# On sites like itch.io, we don't know on which base path the game gets served, so we need to rewrite all links to be relative | ||
- name: Make paths relative | ||
run: | | ||
sed -i 's/\/index/.\/index/g' dist/index.html | ||
sed -i 's/\/${{ env.GAME_EXECUTABLE_NAME }}/.\/${{ env.GAME_EXECUTABLE_NAME }}/g' dist/index.html | ||
- name: Zip release | ||
uses: vimtor/action-zip@v1 | ||
with: | ||
files: dist/ | ||
dest: ${{ env.GAME_EXECUTABLE_NAME }}_web.zip | ||
- name: Upload release | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: ${{ env.GAME_EXECUTABLE_NAME }}_web.zip | ||
asset_name: ${{ env.GAME_EXECUTABLE_NAME }}_${{ env.VERSION }}_web.zip | ||
release_name: ${{ env.VERSION }} | ||
tag: ${{ env.VERSION }} | ||
overwrite: true |