Random Asteroid Starting size and Infinate gameplay loop #66
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
name: Deploy Pages | |
on: | |
push: | |
branches: ["main"] | |
workflow_dispatch: | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Pages | |
uses: actions/configure-pages@v3 | |
- name: Checkout | |
id: checkout | |
uses: actions/checkout@v3 | |
- name: Checkout submodules | |
run: git submodule update --init --recursive | |
- name: Setup Zig | |
uses: goto-bus-stop/[email protected] | |
with: | |
version: 0.11.0 | |
- name: Setup Node | |
id: setup-node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "20.10.0" | |
cache: 'npm' | |
cache-dependency-path: "${{ github.workspace }}/src/asteroids-website" | |
- name: Get npm cache directory | |
id: npm-cache-dir | |
shell: bash | |
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} | |
- name: Node Cache | |
uses: actions/cache@v3 | |
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true' | |
with: | |
path: | | |
${{ steps.npm-cache-dir.outputs.dir }} | |
${{ github.workspace }}/src/asteroids-website/node_modules | |
key: ${{ runner.os }}-node-${{ hashFiles('${{ github.workspace }}/src/asteroids-website/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install Node Modules | |
run: | | |
cd ${{ github.workspace }}/src/asteroids-website | |
npm install | |
- name: Install Wizer | |
uses: baptiste0928/[email protected] | |
with: | |
crate: wizer | |
# Enable all features - https://docs.rs/crate/wizer/latest/features | |
features: structopt,env_logger,wasmprinter | |
- name: Zig Cache | |
uses: Hanaasagi/[email protected] | |
with: | |
cache-directories: "${{ github.workspace }}/src/emscripten/upstream/" | |
- name: Build Zig | |
run: | | |
cd ${{ github.workspace }} | |
zig build -Dtarget=wasm32-emscripten -Doptimize=ReleaseFast | |
- name: Wizer Pre-Init | |
run: | | |
cd ${{ github.workspace }}/src/asteroids-website | |
wizer ./src/import/asteroids.wasm --init-func wizer_initialize -o ./src/import/asteroids-initialized.wasm | |
- name: Binaryen Optimize | |
run: | | |
cd ${{ github.workspace }}/src/asteroids-website | |
npm exec --package=binaryen -c 'wasm-opt ./src/import/asteroids-initialized.wasm -all --post-emscripten --low-memory-unused -tnh --converge -Oz --flatten --rereloop -Oz -Oz -o ./src/import/asteroids.wasm' | |
rm ./src/import/asteroids-initialized.wasm | |
- name: Build Svelte | |
run: | | |
cd ${{ github.workspace }}/src/asteroids-website | |
npm run build | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
path: '${{ github.workspace }}/src/asteroids-website/build' | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
permissions: | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 | |
release: | |
runs-on: ubuntu-latest | |
needs: deploy | |
permissions: | |
contents: write | |
steps: | |
- name: Download artifact | |
uses: actions/[email protected] | |
with: | |
name: github-pages | |
path: asteroids | |
- name: Set current datetime | |
id: set_datetime | |
run: echo "datetime=$(date +"%Y%m%d%H%M%S")" >> "$GITHUB_OUTPUT" | |
- name: Create ZIP | |
run: | | |
cd ./asteroids | |
mkdir ./asteroids | |
tar -xvf ./artifact.tar -C ./asteroids | |
zip -r ../asteroids-v${{ steps.set_datetime.outputs.datetime }}.zip ./asteroids/ | |
- name: Create Release | |
id: create_release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "./asteroids-v${{ steps.set_datetime.outputs.datetime }}.zip" | |
artifactContentType: application/zip | |
body: | | |
**Asteroids Game - _Prerelease v${{ steps.set_datetime.outputs.datetime }}_** | |
${{ github.event.head_commit.message }} | |
prerelease: true | |
draft: false | |
commit: ${{ github.head_ref }} | |
tag: v${{ steps.set_datetime.outputs.datetime }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: manleydev/butler-publish-itchio-action@master | |
env: | |
BUTLER_CREDENTIALS: ${{ secrets.ITCHIO_API_KEY }} | |
CHANNEL: html | |
VERSION: v${{ steps.set_datetime.outputs.datetime }} | |
ITCH_GAME: asteroids | |
ITCH_USER: dylanlangston | |
PACKAGE: ./asteroids-v${{ steps.set_datetime.outputs.datetime }}.zip |