From e83842952a019a92ae0a586217121206ffd40dbd Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 25 Oct 2024 14:50:36 +0100 Subject: [PATCH 1/3] Add web export preset This preset is just the default settings for the Web target (as of v4.3.stable.flathub [77dcf97d8], at least). The important line is: variant/thread_support=false This selects a build of the Godot web runtime that does not use threads; and hence does not use SharedArrayBuffer; and hence can be used on GitHub Pages where the necessary headers to allow SharedArrayBuffer to be used cannot be set. https://phabricator.endlessm.com/T35699 --- export_presets.cfg | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 export_presets.cfg diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..ce492c3 --- /dev/null +++ b/export_presets.cfg @@ -0,0 +1,41 @@ +[preset.0] + +name="Web" +platform="Web" +runnable=false +advanced_options=false +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="" +encryption_include_filters="" +encryption_exclude_filters="" +encrypt_pck=false +encrypt_directory=false +script_export_mode=2 + +[preset.0.options] + +custom_template/debug="" +custom_template/release="" +variant/extensions_support=false +variant/thread_support=false +vram_texture_compression/for_desktop=true +vram_texture_compression/for_mobile=false +html/export_icon=true +html/custom_html_shell="" +html/head_include="" +html/canvas_resize_policy=2 +html/focus_canvas_on_start=true +html/experimental_virtual_keyboard=false +progressive_web_app/enabled=false +progressive_web_app/ensure_cross_origin_isolation_headers=true +progressive_web_app/offline_page="" +progressive_web_app/display=1 +progressive_web_app/orientation=0 +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) From 53493638d6237cbc6c9a69090b4070f087ade212 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 25 Oct 2024 14:51:11 +0100 Subject: [PATCH 2/3] ci: Add workflow to deploy to GitHub Pages While it is not necessarily useful to have this game in its default state published to the web, this workflow can be used by a learner who has customised the game in their own repo. The workflow is designed to fail gracefully if GitHub Pages is not available (which is typically the case in a private repo owned by a free account) or not configured correctly. It also only runs on releases or when manually triggered, to avoid running it each time a learner pushes or merges to main. https://phabricator.endlessm.com/T35699 --- .github/workflows/github-pages.yml | 83 ++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 .github/workflows/github-pages.yml diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml new file mode 100644 index 0000000..fd7c93b --- /dev/null +++ b/.github/workflows/github-pages.yml @@ -0,0 +1,83 @@ +name: "Publish to GitHub Pages" +on: + workflow_dispatch: + release: + types: + - published + +permissions: + contents: read + pages: write + id-token: write + +env: + GODOT_VERSION: 4.3 + +jobs: + check: + name: Check if GitHub Pages is enabled + runs-on: ubuntu-latest + steps: + - name: Check + id: check + env: + GH_TOKEN: ${{ github.token }} + run: | + if gh api "repos/${{ github.repository }}/pages" | jq --exit-status '.build_type == "workflow"' + then + echo "enabled=true" >> "$GITHUB_OUTPUT" + else + echo "# Not published to GitHub Pages" >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" + echo -n "Check that Pages is enabled, with the source set to GitHub Actions, in the " >> "$GITHUB_STEP_SUMMARY" + echo "[repository settings](https://github.com/${{ github.repository }}/settings/pages)." >> "$GITHUB_STEP_SUMMARY" + fi + outputs: + enabled: ${{ steps.check.outputs.enabled }} + + build: + name: Build for web + needs: + - check + if: ${{ needs.check.outputs.enabled }} + runs-on: ubuntu-latest + container: + image: barichello/godot-ci:4.3 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + lfs: true + + - name: Set up export templates + run: | + mkdir -v -p ~/.local/share/godot/export_templates/ + mv /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable + + - name: Web Build + run: | + mkdir -v -p build/web + godot --headless --verbose --export-release "Web" ./build/web/index.html + + - name: Upload Artifact + uses: actions/upload-pages-artifact@v3 + with: + name: web + path: build/web + + publish: + name: Publish to GitHub Pages + needs: + - build + runs-on: ubuntu-latest + steps: + - id: deploy + name: Deploy to GitHub Pages + uses: actions/deploy-pages@v4 + with: + artifact_name: web + + - name: Show URL in summary + if: ${{ steps.deploy.outcome == 'success' }} + run: | + echo "Game published to: <${{ steps.deploy.outputs.page_url }}>" >> "$GITHUB_STEP_SUMMARY" From 385378e58975205380b750dfe8b701387debdae9 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 25 Oct 2024 14:51:47 +0100 Subject: [PATCH 3/3] Include GitHub Pages workflow in export This workflow is intended to be useful to learners who have forked this game as a basis for their own modified game. But rather than using an actual fork, they will likely have downloaded the game from the asset library and committed it to a fresh repository. https://phabricator.endlessm.com/T35699 --- .gitattributes | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitattributes b/.gitattributes index fb7cc71..a341db0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,9 +1,13 @@ # Normalize EOL for all files that Git considers text files. * text=auto eol=lf -# Exclude GitHub Actions-related files from published asset -/.github export-ignore -/asset-template.json.hb export-ignore +# Exclude GitHub Actions-related files from published asset, except the GitHub +# Pages workflow which learners may find useful to publish their modified game. +/.github/** export-ignore +/.github/workflows !export-ignore +/.github/workflows/** export-ignore +/.github/workflows/githuh-pages.yml !export-ignore +/asset-template.json.hb export-ignore # Substitute project version when publishing /project.godot export-subst