From 0964e080d4f2335b23bcc5a6d3db2da911d0e27d Mon Sep 17 00:00:00 2001 From: florianvazelle Date: Wed, 29 Nov 2023 18:48:27 +0100 Subject: [PATCH] ci: build for web (#20) * ci: build for web * ci: only deploy on main branch * chore: fix changelog issue ID --- .github/workflows/release-packaging.yml | 42 ++++++++++++++++++------- CHANGELOG.md | 1 + Justfile | 7 ++++- export_presets.cfg | 2 ++ plug.gd | 1 + project.godot | 2 +- 6 files changed, 41 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release-packaging.yml b/.github/workflows/release-packaging.yml index 8652eec..f27545c 100644 --- a/.github/workflows/release-packaging.yml +++ b/.github/workflows/release-packaging.yml @@ -26,6 +26,7 @@ jobs: if: startsWith(github.ref, 'refs/tags/') run: | [ "${{ env.game_version }}" == "${{ env.BRANCH_NAME }}" ] || exit 2 + build: runs-on: ubuntu-22.04 timeout-minutes: 30 @@ -48,6 +49,35 @@ jobs: path: dist/* retention-days: 1 + deploy: + runs-on: ubuntu-22.04 + timeout-minutes: 30 + needs: [check] + + if: github.ref == 'refs/heads/main' + + steps: + - uses: actions/checkout@v4 + - uses: extractions/setup-just@v1 + + - name: Load dotenv + run: just ci-load-dotenv + + - name: Export + run: just export-web + + # Installing rsync is needed in order to deploy to GitHub Pages. Without it, the build will fail. + - name: Install rsync + run: | + sudo apt-get update && sudo apt-get install -y rsync + + - name: Deploy to GitHub Pages + uses: JamesIves/github-pages-deploy-action@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: gh-pages + folder: build/web + publish: runs-on: ubuntu-22.04 timeout-minutes: 30 @@ -75,15 +105,3 @@ jobs: env: BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # # Installing rsync is needed in order to deploy to GitHub Pages. Without it, the build will fail. - # - name: Install rsync - # run: | - # apt-get update && apt-get install -y rsync - # - # - name: Deploy to GitHub Pages - # uses: JamesIves/github-pages-deploy-action@v4 - # with: - # token: ${{ secrets.GITHUB_TOKEN }} - # branch: gh-pages - # folder: build/web diff --git a/CHANGELOG.md b/CHANGELOG.md index 8098ac4..2ec4837 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] ### Added +- Add web deploy ([#20](https://github.com/MechanicalFlower/Marble/pull/20)) ### Changed - Use Justfile as command runner ([#18](https://github.com/MechanicalFlower/Marble/pull/18)) ### Deprecated diff --git a/Justfile b/Justfile index f511327..8f06522 100644 --- a/Justfile +++ b/Justfile @@ -113,7 +113,7 @@ import-resources: echo "Create the override.cfg" touch override.cfg - echo -e "[build_info]\npackage/version={{ game_version }}\npackage/build_date={{ build_date }}\nsource/commit={{ commit_hash }}" > override.cfg + echo '[build_info]\npackage/version="{{ game_version }}"\npackage/build_date="{{ build_date }}"\nsource/commit="{{ commit_hash }}"' > override.cfg # Godot binary wrapper @godot *ARGS: makedirs install-godot install-templates @@ -148,6 +148,11 @@ export-linux: bump-version install-addons import-resources mv {{ build_dir }}/linux/{{ game_name }}-linux-v{{ game_version }}.zip {{ dist_dir }}/{{ game_name }}-linux-v{{ game_version }}.zip rm -rf {{ build_dir }}/linux +# Export game for the web +export-web: bump-version install-addons import-resources + mkdir -p {{ build_dir }}/web + just godot --export-release "Web" --headless {{ build_dir }}/web/index.html + # Export on all platform export: export-windows export-mac export-linux diff --git a/export_presets.cfg b/export_presets.cfg index 4d1a2c1..a77ad8b 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -98,6 +98,8 @@ progressive_web_app/icon_144x144="" progressive_web_app/icon_180x180="" progressive_web_app/icon_512x512="" progressive_web_app/background_color=Color(0, 0, 0, 1) +include_coi_service_worker=true +iframe_breakout="Disabled" [preset.2] diff --git a/plug.gd b/plug.gd index c6e9ff3..7d71374 100644 --- a/plug.gd +++ b/plug.gd @@ -4,3 +4,4 @@ extends "res://addons/gd-plug/plug.gd" func _plugging(): plug("godot-extended-libraries/godot-debug-menu", {"commit": "2d5d67012c76b272173dcfb4947a65dc385fab94"}) plug("KoBeWi/Godot-Universal-Fade", {"commit": "f091514bba652880f81c5bc8809e0ee4498988ea"}) + plug("nisovin/godot-coi-serviceworker", {"commit": "962b1abaf14ac62079b9e5321ef98e6f2b09c96e"}) diff --git a/project.godot b/project.godot index ea9d52f..435b5c7 100644 --- a/project.godot +++ b/project.godot @@ -35,7 +35,7 @@ window/size/height=720 [editor_plugins] -enabled=PackedStringArray("res://addons/debug_menu/plugin.cfg") +enabled=PackedStringArray("res://addons/debug_menu/plugin.cfg","res://addons/coi_serviceworker/plugin.cfg") [filesystem]