export_web.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. name: Export projects to Web and deploy to GitHub Pages
  2. on:
  3. push:
  4. branches:
  5. - master
  6. env:
  7. GODOT_VERSION: 4.3
  8. jobs:
  9. export-html5:
  10. name: Export projects to Web and deploy to GitHub Pages
  11. runs-on: ubuntu-24.04
  12. container:
  13. image: barichello/godot-ci:4.3
  14. steps:
  15. - name: Checkout
  16. uses: actions/checkout@v4
  17. - name: Setup
  18. run: |
  19. mkdir -p ~/.local/share/godot/export_templates/
  20. mv /root/.local/share/godot/export_templates/$GODOT_VERSION.stable ~/.local/share/godot/export_templates/$GODOT_VERSION.stable
  21. - name: Export projects to Web
  22. run: |
  23. apt-get update -qq && apt-get install -qqq imagemagick
  24. # Don't export Mono demos (not supported yet), demos that can't be run in Web
  25. # since they're platform-specific or demos that are currently broken in Web.
  26. # Remember to update `.github/dist/footer.html` when updating the list of excluded demos.
  27. rm -rf \
  28. 2d/glow/ \
  29. 2d/navigation_mesh_chunks/ \
  30. 2d/physics_tests/ \
  31. 3d/labels_and_texts/ \
  32. 3d/decals/ \
  33. 3d/ik/ \
  34. 3d/navigation_mesh_chunks/ \
  35. 3d/occlusion_culling_mesh_lod/ \
  36. 3d/particles/ \
  37. 3d/physical_light_camera_units/ \
  38. 3d/physics_tests/ \
  39. 3d/variable_rate_shading/ \
  40. 3d/volumetric_fog/ \
  41. 3d/voxel/ \
  42. audio/bpm_sync/ \
  43. audio/device_changer/ \
  44. audio/midi_piano/ \
  45. audio/spectrum/ \
  46. compute/ \
  47. gui/msdf_font/ \
  48. gui/translation/ \
  49. loading/runtime_save_load \
  50. misc/compute_shader_heightmap \
  51. misc/large_world_coordinates/ \
  52. misc/matrix_transform/ \
  53. mobile/android_iap/ \
  54. mobile/sensors/ \
  55. mono/ \
  56. networking/ \
  57. plugins/ \
  58. xr/
  59. for panorama in 3d/material_testers/backgrounds/*.hdr; do
  60. # Decrease the resolution to get below the 100 MB PCK size limit.
  61. # Otherwise, the website can't be deployed as files larger than 100 MB
  62. # can't be pushed to GitHub.
  63. mogrify -resize 66.667% "$panorama"
  64. done
  65. BASEDIR="$PWD"
  66. # Use absolute paths so that we can `cd` without having to go back to the parent directory manually.
  67. for demo in */*/; do
  68. echo ""
  69. echo ""
  70. echo "================================================================================"
  71. echo "Exporting demo $demo..."
  72. echo "================================================================================"
  73. mkdir -p "$BASEDIR/.github/dist/$demo"
  74. cd "$BASEDIR/$demo"
  75. # Copy an export template preset file configured for Web exporting.
  76. # This way, we don't have to commit `export_presets.cfg` for each project.
  77. cp "$BASEDIR/.github/dist/export_presets.cfg" .
  78. # Enable ETC2 texture importing, which is disabled by default (but required for web exports to work on mobile platforms).
  79. echo "[rendering]\n\ntextures/vram_compression/import_etc2_astc=true" >> project.godot
  80. godot --verbose --headless --export-release "Web" "$BASEDIR/.github/dist/$demo/index.html"
  81. # Replace the WASM file with a symbolic link to avoid duplicating files in the pushed branch.
  82. # (WASM files are identical across projects, but not PCK or HTML/JavaScript files.)
  83. mv -f "$BASEDIR/.github/dist/$demo/index.wasm" "$BASEDIR/.github/dist/index.wasm"
  84. # The symlink must be relative as it needs to point to a file within the pushed repository.
  85. ln -s "../../index.wasm" "$BASEDIR/.github/dist/$demo/index.wasm"
  86. # Append the demo to the list of demos for the website.
  87. PROJECT_NAME=$(cat project.godot | grep "config/name" | cut -d '"' -f 2 | tr -d "\n")
  88. echo "<li><a href='$demo'><img width="64" height="64" src="$demo/index.icon.png" alt=""><p>$PROJECT_NAME</p></a></li>" >> "$BASEDIR/.github/dist/demos.html"
  89. done
  90. cat "$BASEDIR/.github/dist/header.html" "$BASEDIR/.github/dist/demos.html" "$BASEDIR/.github/dist/footer.html" > "$BASEDIR/.github/dist/index.html"
  91. # Clean up files that don't need to be deployed.
  92. rm -f "$BASEDIR/.github/dist/header.html" "$BASEDIR/.github/dist/demos.html" "$BASEDIR/.github/dist/footer.html" "$BASEDIR/.github/dist/export_presets.cfg"
  93. # Installing rsync is needed in order to deploy to GitHub Pages. Without it, the build will fail.
  94. - name: Install rsync 📚
  95. run: |
  96. apt-get update -qq && apt-get install -qqq rsync
  97. - name: Deploy to GitHub Pages 🚀
  98. uses: JamesIves/github-pages-deploy-action@releases/v4
  99. with:
  100. # The folder the action should deploy.
  101. folder: .github/dist
  102. # Artifacts are large; don't keep the branch's history.
  103. single-commit: true