diff --git a/.gitattributes b/.gitattributes index fb7cc71..76d8182 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/gh-pages.yml !export-ignore +/asset-template.json.hb export-ignore # Substitute project version when publishing /project.godot export-subst diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml new file mode 100644 index 0000000..a1dbb50 --- /dev/null +++ b/.github/workflows/gh-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-web + 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" 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)