Swap the inactivated meteor with the last activated one #115
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 | |
outputs: | |
datetime: ${{ steps.set_datetime.outputs.datetime }} | |
steps: | |
- name: Set current datetime output variable | |
id: set_datetime | |
run: echo "datetime=$(date +"%Y%m%d%H%M%S")" >> "$GITHUB_OUTPUT" | |
- 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 | |
id: upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-artifact | |
path: '${{ github.workspace }}/src/asteroids-website/build' | |
- name: Build Svelte compressed | |
run: | | |
cd ${{ github.workspace }}/src/asteroids-website | |
npm run build-compressed | |
- name: Upload github pages artifact | |
id: upload-compressed | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
path: '${{ github.workspace }}/src/asteroids-website/build' | |
- name: Upload itch.io artifact | |
id: upload-itchio | |
uses: actions/upload-artifact@v4 | |
with: | |
name: itch-io | |
path: '${{ github.workspace }}/src/asteroids-website/build' | |
deploy-github-pages: | |
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 | |
deploy-itchio: | |
runs-on: ubuntu-latest | |
needs: [build, deploy-github-pages] | |
permissions: | |
contents: write | |
steps: | |
- name: Download artifact compressed | |
id: download | |
uses: actions/download-artifact@v4 | |
with: | |
name: itch-io | |
- name: Push to itch.io | |
uses: manleydev/butler-publish-itchio-action@master | |
env: | |
BUTLER_CREDENTIALS: ${{ secrets.ITCHIO_API_KEY }} | |
CHANNEL: html | |
VERSION: v${{ needs.build.outputs.datetime }} | |
ITCH_GAME: asteroids | |
ITCH_USER: dylanlangston | |
PACKAGE: ${{ steps.download.outputs.download-path }} | |
- name: Sleep 30s | |
run: sleep 30s | |
- name: First load of itch.io | |
uses: karol-brejna-i/webpage-screenshot-action@v1 | |
with: | |
url: https://dylanlangston.itch.io/asteroids | |
release: | |
runs-on: ubuntu-latest | |
needs: [build, deploy-github-pages] | |
permissions: | |
contents: write | |
steps: | |
- name: Download artifact | |
id: download | |
uses: actions/download-artifact@v4 | |
with: | |
name: release-artifact | |
- name: Create ZIP | |
run: | | |
cd ${{ steps.download.outputs.download-path }}/../ | |
zip -r ./asteroids-v${{ needs.build.outputs.datetime}}.zip ./asteroids/ | |
- name: Create Release | |
id: create_release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "${{ steps.download.outputs.download-path }}/../asteroids-v${{ needs.build.outputs.datetime}}.zip" | |
artifactContentType: application/zip | |
body: | | |
**Asteroids Game - _Prerelease v${{ needs.build.outputs.datetime }}_** | |
${{ github.event.head_commit.message }} | |
prerelease: true | |
draft: false | |
commit: ${{ github.head_ref }} | |
tag: v${{ needs.build.outputs.datetime }} | |
token: ${{ secrets.GITHUB_TOKEN }} |