Skip to content

Commit

Permalink
Add release.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
yamgent committed Aug 20, 2023
1 parent 14282ee commit 4d9bced
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/release.yaml
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

0 comments on commit 4d9bced

Please sign in to comment.