diff --git a/.github/actions/compile_gdextension/action.yml b/.github/actions/compile_gdextension/action.yml index 2bf012e9..e7c53856 100644 --- a/.github/actions/compile_gdextension/action.yml +++ b/.github/actions/compile_gdextension/action.yml @@ -12,6 +12,16 @@ inputs: description: Arch (universal|x86_32|x86_64|arm32|arm64|rv64|ppc32|ppc64|wasm32) required: true default: "" + artifact: + description: Artifact name. This name will be used for caching. + required: true + default: "bin" + additional: + description: Any additional arguments + default: "" + additional_enabled_dd3d: + description: Use force_enabled_dd3d if possible + default: "true" output_libs_path: description: Path to compiled libraries required: true @@ -19,15 +29,8 @@ inputs: use_cache: description: Use cache default: "true" - artifact: - description: Artifact name - required: true - default: "bin" - additional: - description: Any additional arguments - default: "" runs: - using: "composite" + using: composite steps: - name: Get godot-cpp SHA shell: bash @@ -40,10 +43,10 @@ runs: uses: actions/cache/restore@v3 with: path: ${{env.SCONS_CACHE}} - key: ${{github.job}}-${{inputs.arch}}_${{inputs.target}}-${{steps.get_godot_cpp_sha.outputs.sha}}-${{github.ref}}-${{github.sha}} + key: ${{github.job}}-${{inputs.artifact}}-${{steps.get_godot_cpp_sha.outputs.sha}}-${{github.ref}}-${{github.sha}} restore-keys: | - ${{github.job}}-${{inputs.arch}}_${{inputs.target}}-${{steps.get_godot_cpp_sha.outputs.sha}}-${{github.ref}} - ${{github.job}}-${{inputs.arch}}_${{inputs.target}}-${{steps.get_godot_cpp_sha.outputs.sha}} + ${{github.job}}-${{inputs.artifact}}-${{steps.get_godot_cpp_sha.outputs.sha}}-${{github.ref}} + ${{github.job}}-${{inputs.artifact}}-${{steps.get_godot_cpp_sha.outputs.sha}} continue-on-error: true - name: Set up Python 3.x @@ -64,11 +67,11 @@ runs: - name: Linux dependencies shell: bash - if: runner.os == 'Linux' + if: (runner.os == 'Linux') && (inputs.platform == 'linux') run: | - sudo apt-get update + sudo apt update if [[ "${{inputs.arch}}" == *"32" ]];then - sudo apt-get install gcc-multilib g++-multilib + sudo apt install gcc-multilib g++-multilib fi - name: Compilation @@ -81,7 +84,7 @@ runs: git apply --ignore-space-change --ignore-whitespace ../patches/unity_build.patch cd .. scons platform=${{inputs.platform}} arch=${{inputs.arch}} target=${{inputs.target}} addon_output_dir=${{inputs.output_libs_path}} ${{inputs.additional}} - if [ "${{inputs.target}}" == "template_release" ] && [ "${{inputs.platform}}" != "android" ]; then + if [ "${{inputs.target}}" == "template_release" ] && [ "${{inputs.additional_enabled_dd3d}}" == "true" ]; then scons platform=${{inputs.platform}} arch=${{inputs.arch}} target=${{inputs.target}} addon_output_dir=${{inputs.output_libs_path}} force_enabled_dd3d=yes ${{inputs.additional}} fi echo "::endgroup::" @@ -103,7 +106,7 @@ runs: Remove-Item ${{inputs.output_libs_path}}/* -Recurse -Include *.exp,*.lib,*.pdb -Force - name: Upload Artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{inputs.artifact}} retention-days: 7 @@ -114,5 +117,5 @@ runs: uses: actions/cache/save@v3 with: path: ${{env.SCONS_CACHE}} - key: ${{github.job}}-${{inputs.arch}}_${{inputs.target}}-${{steps.get_godot_cpp_sha.outputs.sha}}-${{github.ref}}-${{github.sha}} + key: ${{github.job}}-${{inputs.artifact}}-${{steps.get_godot_cpp_sha.outputs.sha}}-${{github.ref}}-${{github.sha}} continue-on-error: true diff --git a/.github/actions/delete_artifact/action.yml b/.github/actions/delete_artifact/action.yml new file mode 100644 index 00000000..6c5cabee --- /dev/null +++ b/.github/actions/delete_artifact/action.yml @@ -0,0 +1,31 @@ +name: Delete the artifact if it exists +description: Delete an artifact by its name if it exists. 'actions/upload-artifact@v4' usually removes artifacts itself when restarting jobs. +inputs: + artifact: + description: Any name of artifact + required: true +runs: + using: composite + steps: + - name: Delete `${{inputs.artifact}}` + shell: bash + continue-on-error: true + run: | + res=$(gh api \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{github.repository}}/actions/runs/${{github.run_id}}/artifacts?name="${{inputs.artifact}}") + + artifact_id=$(echo "$res" | jq -r 'if .total_count > 0 then .artifacts[0].id else 0 end') + + if [ "$artifact_id" == "0" ]; then + echo "No artifact to remove was found." + else + echo "Found the artifact ID $artifact_id for the ${{inputs.artifact}}." + gh api \ + --method DELETE \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{github.repository}}/actions/artifacts/$artifact_id + echo "The artifact with the ID $artifact_id has been removed." + fi diff --git a/.github/workflows/gdextension_build.yml b/.github/workflows/gdextension_build.yml index 2a69e115..00fd99d4 100644 --- a/.github/workflows/gdextension_build.yml +++ b/.github/workflows/gdextension_build.yml @@ -10,22 +10,26 @@ on: description: Use Cache default: true type: boolean - repository_dispatch: # Stop the same workflow actions concurrency: - group: ${{github.workflow}}-${{github.event.pull_request.number || github.run_id}} + group: ${{github.workflow}}-${{github.event.pull_request.number || github.ref}} cancel-in-progress: true +permissions: + actions: write + env: SCONS_CACHE: ${{github.workspace}}/.scons-cache/ + USE_CACHE: ${{!format('{0}', inputs.use_cache) && 'true' || format('{0}', inputs.use_cache)}} # Default true OUTPUT_LIBS_PATH: bin FORCE_DISABLE_UNITY: yes + GH_TOKEN: ${{ github.token }} jobs: windows-gdextension: name: 🏁 Windows - runs-on: "windows-latest" + runs-on: windows-latest strategy: fail-fast: false @@ -35,7 +39,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: lfs: true submodules: recursive @@ -46,16 +50,16 @@ jobs: platform: windows target: ${{matrix.target}} arch: ${{matrix.arch}} - output_libs_path: ${{env.OUTPUT_LIBS_PATH}} - use_cache: ${{format('{0}', inputs.use_cache)}} # Cast to string - artifact: windows + artifact: windows.${{matrix.target}}.${{matrix.arch}} additional: lto=yes + output_libs_path: ${{env.OUTPUT_LIBS_PATH}} + use_cache: ${{env.USE_CACHE}} # ============================================ linux-gdextension: name: 🐧 Linux - runs-on: "ubuntu-20.04" + runs-on: ubuntu-20.04 strategy: fail-fast: false @@ -65,7 +69,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: lfs: true submodules: recursive @@ -76,16 +80,16 @@ jobs: platform: linux target: ${{matrix.target}} arch: ${{matrix.arch}} - output_libs_path: ${{env.OUTPUT_LIBS_PATH}} - use_cache: ${{format('{0}', inputs.use_cache)}} - artifact: linux + artifact: linux.${{matrix.target}}.${{matrix.arch}} additional: lto=yes + output_libs_path: ${{env.OUTPUT_LIBS_PATH}} + use_cache: ${{env.USE_CACHE}} # ============================================ macos-gdextension: name: 🍏 MacOS - runs-on: "macos-latest" + runs-on: macos-latest strategy: fail-fast: false @@ -95,7 +99,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: lfs: true submodules: recursive @@ -106,16 +110,16 @@ jobs: platform: macos target: ${{matrix.target}} arch: ${{matrix.arch}} - output_libs_path: ${{env.OUTPUT_LIBS_PATH}} - use_cache: ${{format('{0}', inputs.use_cache)}} - artifact: macos + artifact: macos.${{matrix.target}}.${{matrix.arch}} additional: lto=yes macos_deployment_target=10.14 + output_libs_path: ${{env.OUTPUT_LIBS_PATH}} + use_cache: ${{env.USE_CACHE}} # ============================================ android-gdextension: name: 🤖 Android - runs-on: "ubuntu-latest" + runs-on: ubuntu-latest strategy: fail-fast: false @@ -125,7 +129,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: lfs: true submodules: recursive @@ -156,16 +160,17 @@ jobs: platform: android target: ${{matrix.target}} arch: ${{matrix.arch}} - output_libs_path: ${{env.OUTPUT_LIBS_PATH}} - use_cache: ${{format('{0}', inputs.use_cache)}} - artifact: android + artifact: android.${{matrix.target}}.${{matrix.arch}} additional: lto=yes + additional_enabled_dd3d: false + output_libs_path: ${{env.OUTPUT_LIBS_PATH}} + use_cache: ${{env.USE_CACHE}} # ============================================ web-gdextension: name: 🕸 Web - runs-on: "ubuntu-latest" + runs-on: ubuntu-latest strategy: fail-fast: false @@ -178,14 +183,19 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: lfs: true submodules: recursive - - uses: mymindstorm/setup-emsdk@v12 + - name: Download Emscripten + uses: mymindstorm/setup-emsdk@v12 + # Continue if failed to cache + # https://github.com/mymindstorm/setup-emsdk/issues/20 + continue-on-error: true with: version: ${{env.EM_VERSION}} + actions-cache-folder: obj/emsdk_cache - name: Compile GDExtension uses: ./.github/actions/compile_gdextension @@ -193,10 +203,10 @@ jobs: platform: web target: ${{matrix.target}} arch: ${{matrix.arch}} - output_libs_path: ${{env.OUTPUT_LIBS_PATH}} - use_cache: ${{format('{0}', inputs.use_cache)}} - artifact: web + artifact: web.${{matrix.target}}.${{matrix.arch}} additional: lto=yes + output_libs_path: ${{env.OUTPUT_LIBS_PATH}} + use_cache: ${{env.USE_CACHE}} # ============================================ @@ -213,15 +223,15 @@ jobs: runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v4 + + # https://github.com/actions/download-artifact/issues/249 - name: Download Binaries - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: path: extracted_files - - name: Remove `gdextension_libs` if the action was restarted - run: | - rm -rf extracted_files/gdextension_libs/ - - name: Store all libraries in one directory run: | ls -R extracted_files/ @@ -229,9 +239,14 @@ jobs: rm -rf extracted_files/**/ touch extracted_files/.gdignore + - name: Output file information + run: | + cd extracted_files + echo "Total size: $(du -ch -b | grep total | cut -f1 | awk '{printf "%.2f", $1/1048576}') MB, Total number of files: $(find . -type f | wc -l)" >> $GITHUB_STEP_SUMMARY + - name: Upload GDExtension - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: gdextension_libs + name: .gdextension_libs retention-days: 7 path: extracted_files/* diff --git a/.github/workflows/github_pages_build.yml b/.github/workflows/github_pages_build.yml deleted file mode 100644 index 506c9dce..00000000 --- a/.github/workflows/github_pages_build.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: 🚀 Deploy Github Pages Demo -on: - workflow_dispatch: - repository_dispatch: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Stop the same workflow actions -concurrency: - group: ${{github.workflow}}-${{github.event.pull_request.number || github.run_id}} - cancel-in-progress: true - -# Environment variables for the job -env: - GODOT_VERSION: 4.1.1 - PROJECT_PATH: dd3d_web_build - -jobs: - build: - name: 🌐 Build Project - runs-on: ubuntu-20.04 - container: - image: barichello/godot-ci:4.1.1 - steps: - - name: Check out code - uses: actions/checkout@v3 - with: - lfs: true - - - name: Setup - 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: Prepare Web Build - run: | - cp -r addons ${PROJECT_PATH}/addons - cp -r examples_dd3d ${PROJECT_PATH}/examples_dd3d - - - name: Import Assets - run: godot -v -e --headless --path ${PROJECT_PATH} --quit || true - - - name: Web Build - run: | - mkdir ${GITHUB_WORKSPACE}/_site - cp ${PROJECT_PATH}/coi-serviceworker.min.js ${GITHUB_WORKSPACE}/_site/coi-serviceworker.min.js - godot -v --headless --path ${PROJECT_PATH} --export-release web ${GITHUB_WORKSPACE}/_site/index.html - - - name: Fix Permissions - run: | - chmod -c -R +rX "_site/" | while read line; do - echo "::warning title=Invalid file permissions automatically fixed::$line" - done - - - name: Upload Site Artifact - uses: actions/upload-pages-artifact@v1 - with: - name: github-pages - - deploy: - name: 🚀 Deploy Site - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v2 diff --git a/.github/workflows/util_cleanup_cache.yml b/.github/workflows/util_cleanup_cache.yml index 0d53c4b4..79f628b3 100644 --- a/.github/workflows/util_cleanup_cache.yml +++ b/.github/workflows/util_cleanup_cache.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Cleanup run: | diff --git a/.github/workflows/util_update_libs.yml b/.github/workflows/util_update_libs.yml index 955f85f2..d66c1189 100644 --- a/.github/workflows/util_update_libs.yml +++ b/.github/workflows/util_update_libs.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: lfs: true @@ -24,22 +24,26 @@ jobs: with: workflow: gdextension_build.yml branch: ${{github.ref_name}} - name: gdextension_libs + name: .gdextension_libs path: extracted_files/ - name: Replace with new files + shell: bash run: | ls -R extracted_files rm -rf ${{env.ADDON_LIBS_PATH}}/ mv -f extracted_files ${{env.ADDON_LIBS_PATH}} - - name: Commit report + - name: Commit and report + shell: bash run: | - git config --global user.name 'Auto Updater' - git config --global user.email 'auto-updater@users.noreply.github.com' + git config --global user.name 'github-actions-auto-updater[bot]' + git config --global user.email 'github-actions-auto-updater[bot]@users.noreply.github.com' git diff - echo "# Changed files:" >> $GITHUB_STEP_SUMMARY - git diff --name-only >> $GITHUB_STEP_SUMMARY git add -A - git commit -am "[CI] ↗️ Updated Binaries" - git push \ No newline at end of file + git commit --allow-empty -am "[CI] ↗️ Updated Binaries: ${{github.sha}}" + git push + + echo "## Changed files:" >> $GITHUB_STEP_SUMMARY + codeblock_tmp=$'```\nSTATS\n```' + echo "${codeblock_tmp//STATS/$(git diff --stat HEAD~)}" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/web_deploy.yml b/.github/workflows/web_deploy.yml new file mode 100644 index 00000000..8486f5a4 --- /dev/null +++ b/.github/workflows/web_deploy.yml @@ -0,0 +1,616 @@ +name: 🚀 Deploy content to Github Pages +on: + push: + branches-ignore: gh-pages + paths: [docs/**, images/**, dd3d_web_build/**, examples_dd3d/**, Doxyfile, src/**, .github/**, "!.github/**/util_*", "patches/**", lib_utils.py, SConstruct] + workflow_dispatch: + inputs: + dev_deploy: + description: Dev deploy + default: true + type: boolean + +# docs/ for documentation +# demo/ for demo project +# dev/ for development version +# dev/BRANCH/docs and dev/BRANCH/demo for dev docs/ and demo/ + +# Permissions to update the PAGES_BRANCH branch +permissions: + contents: write + pages: write + id-token: write + actions: write + +# Stop the same workflow actions +concurrency: + group: ${{github.workflow}}-${{github.event.pull_request.number || github.ref}} + cancel-in-progress: true + +env: + PAGES_BRANCH: gh-pages + DEV_DEPLOY: ${{!format('{0}', inputs.dev_deploy) && 'true' || format('{0}', inputs.dev_deploy)}} # Default true + GH_TOKEN: ${{github.token}} + +jobs: + data_preparation: + name: ⛏ Data preparation + runs-on: ubuntu-latest + outputs: + head_sha: ${{steps.get_sha.outputs.head_sha}} + lib_version: ${{steps.get_lib_version.outputs.version}} + domain: ${{steps.get_domain.outputs.domain}} + + steps: + - name: Is development version + shell: bash + run: | + echo "Is a development build: \`${{env.DEV_DEPLOY}}\`" >> $GITHUB_STEP_SUMMARY + + - name: Get HEAD + shell: bash + id: get_sha + run: | + sha=$(gh api \ + -H "Accept: application/vnd.github.sha" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{github.repository}}/commits/${{env.PAGES_BRANCH}}) + + if [ $? -ne 0 ]; then + echo "Curl failed with error: $?" + exit $? + fi + echo "head_sha=$sha" >> $GITHUB_OUTPUT + echo "\`$sha\` will be used as a restore point." >> $GITHUB_STEP_SUMMARY + + - name: Checkout version.h + uses: actions/checkout@v4 + with: + path: current + sparse-checkout: | + src/version.h + + - name: Get library version + id: get_lib_version + shell: bash + run: | + # Get DD3D version + source_file="current/src/version.h" + + major=$(grep -oP '(?<=#define DD3D_MAJOR )\d+' "$source_file") + minor=$(grep -oP '(?<=#define DD3D_MINOR )\d+' "$source_file") + patch=$(grep -oP '(?<=#define DD3D_PATCH )\d+' "$source_file") + + version_string="$major.$minor.$patch" + + echo "version=$version_string" >> $GITHUB_OUTPUT + echo "Version found in file \`version.h\`: \`$version_string\`" >> $GITHUB_STEP_SUMMARY + + - name: Checkout CNAME + uses: actions/checkout@v4 + continue-on-error: true + id: checkout_cname + with: + ref: ${{env.PAGES_BRANCH}} + path: pages + sparse-checkout: | + CNAME + + - name: Get CNAME or domain + id: get_domain + run: | + if [ "${{steps.checkout_cname.conclusion}}" == "success" ]; then + cname=$(cat pages/CNAME) + echo "domain=$cname" >> $GITHUB_OUTPUT + echo "Found CNAME record: \`$cname\`" >> $GITHUB_STEP_SUMMARY + else + domain="${{github.repository_owner}}.github.io/${{github.event.repository.name}}" + echo "domain=$domain" >> $GITHUB_OUTPUT + echo "CNAME not found, presumably domain of gh-pages: \`$domain\`" >> $GITHUB_STEP_SUMMARY + fi + + + web-gdextension: + name: 🕸 Build a Web library + needs: data_preparation + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + env: + EM_VERSION: 3.1.39 + # Faster build, but bigger library size (726KB vs 680KB) + FORCE_DISABLE_UNITY: no + SCONS_CACHE: ${{github.workspace}}/.scons-cache/ + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + lfs: true + submodules: recursive + + - name: Download Emscripten + uses: mymindstorm/setup-emsdk@v12 + # Continue if failed to cache + # https://github.com/mymindstorm/setup-emsdk/issues/20 + continue-on-error: true + with: + version: ${{env.EM_VERSION}} + actions-cache-folder: obj/emsdk_cache + + - name: Compile GDExtension + uses: ./.github/actions/compile_gdextension + with: + platform: web + target: template_release + arch: wasm32 + artifact: web.demo_build + additional: lto=yes force_enabled_dd3d=yes + additional_enabled_dd3d: false + output_libs_path: bin + use_cache: true + + + generate_docs: + name: 📚 Generate Docs + needs: data_preparation + runs-on: ubuntu-latest + + env: + DOXYGEN_VERSION: 1.9.8 + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + lfs: true + submodules: recursive + + - name: Install Doxygen + shell: bash + run: | + mkdir obj + cd obj + wget -nv https://www.doxygen.nl/files/doxygen-${{env.DOXYGEN_VERSION}}.linux.bin.tar.gz + tar -xf doxygen-${{env.DOXYGEN_VERSION}}.linux.bin.tar.gz + + - name: Run Doxygen + shell: bash + run: | + ( cat Doxyfile ; echo "PROJECT_NUMBER=${{needs.data_preparation.outputs.lib_version}}" ) | ./obj/doxygen-${{env.DOXYGEN_VERSION}}/bin/doxygen - + + - name: Get destination_dir + id: get_ref + shell: bash + env: + REF: ${{github.ref_name}} + content_dir: docs + # dev folder name must be synced with :fix_ref_names + run: | + fixed_ref_name=$(echo "$REF" | tr -c [:alnum:]+[:cntrl:] [_*]) + new_ref_name="" + if [ "${{env.DEV_DEPLOY}}" == "true" ]; then + new_ref_name="dev/$fixed_ref_name/$content_dir" + echo "new_ref_name=$new_ref_name" >> $GITHUB_OUTPUT + else + new_ref_name="$content_dir/${{needs.data_preparation.outputs.lib_version}}" + echo "new_ref_name=$new_ref_name" >> $GITHUB_OUTPUT + fi + echo "Target URL: https://${{needs.data_preparation.outputs.domain}}/$new_ref_name" >> $GITHUB_STEP_SUMMARY + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + publish_dir: obj/doxygen/html + destination_dir: ${{steps.get_ref.outputs.new_ref_name}} + publish_branch: ${{env.PAGES_BRANCH}} + allow_empty_commit: true + keep_files: true + commit_message: Updated documentation + user_name: 'github-actions-deploy[bot]' + user_email: 'github-actions-deploy[bot]@users.noreply.github.com' + + + export_demo_project: + name: 🌐📦 Export Demo Project + runs-on: ubuntu-20.04 + needs: [data_preparation, generate_docs, web-gdextension] + container: + image: barichello/godot-ci:4.2.1 + + env: + # Sync with container: image: + GODOT_VERSION: 4.2.1 + PROJECT_PATH: dd3d_web_build + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + lfs: true + + - name: Setup + 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: Download Binaries + uses: actions/download-artifact@v4 + with: + path: addons/debug_draw_3d/libs + name: web.demo_build + + - name: Prepare Web Build + run: | + ls addons/debug_draw_3d/libs + ls ${GITHUB_WORKSPACE}/addons/debug_draw_3d/libs + cp -r addons ${PROJECT_PATH}/addons + cp -r examples_dd3d ${PROJECT_PATH}/examples_dd3d + + - name: Import Assets + run: godot -v -e --headless --path ${PROJECT_PATH} --quit || true + + - name: Web Build + run: | + mkdir ${GITHUB_WORKSPACE}/demo + cp ${PROJECT_PATH}/coi-serviceworker.min.js ${GITHUB_WORKSPACE}/demo/coi-serviceworker.min.js + godot -v --headless --path ${PROJECT_PATH} --export-release web ${GITHUB_WORKSPACE}/demo/index.html + + - name: Fix Permissions + run: | + chmod -c -R +rX "demo/" | while read line; do + echo "::warning title=Invalid file permissions automatically fixed::$line" + done + + - name: Get destination_dir + id: get_ref + shell: bash + env: + REF: ${{github.ref_name}} + content_dir: demo + # dev folder name must be synced with :fix_ref_names + run: | + fixed_ref_name=$(echo "$REF" | tr -c [:alnum:]+[:cntrl:] [_*]) + new_ref_name="" + if [ "${{env.DEV_DEPLOY}}" == "true" ]; then + new_ref_name="dev/$fixed_ref_name/$content_dir" + echo "new_ref_name=$new_ref_name" >> $GITHUB_OUTPUT + else + new_ref_name="$content_dir/${{needs.data_preparation.outputs.lib_version}}" + echo "new_ref_name=$new_ref_name" >> $GITHUB_OUTPUT + fi + echo "Target URL: https://${{needs.data_preparation.outputs.domain}}/$new_ref_name" >> $GITHUB_STEP_SUMMARY + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + publish_dir: demo + destination_dir: ${{steps.get_ref.outputs.new_ref_name}} + publish_branch: ${{env.PAGES_BRANCH}} + allow_empty_commit: true + keep_files: true + commit_message: Updated demo build + user_name: 'github-actions-deploy[bot]' + user_email: 'github-actions-deploy[bot]@users.noreply.github.com' + + + finalization: + name: 🏁 Finalization + needs: [data_preparation, export_demo_project] + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{env.PAGES_BRANCH}} + # MUST BE A SUFFICIENT VALUE TO BE ABLE TO RESET TO THE INITIAL COMMIT + fetch-depth: 4 + lfs: true + + - name: Clean unused folders + if: env.DEV_DEPLOY == 'false' + continue-on-error: true + # default bash without -e (fail-fast) + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference + shell: bash --noprofile --norc -o pipefail {0} + run: | + # Get branches + response=$(gh api \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{github.repository}}/branches) + + # Can't compare existing folders with no branches + if [ $? -ne 0 ]; then + echo "Error: Could not load the list of branches. Exiting." + exit 1 + fi + + git_branches=$(echo "$response" | jq -r '.[].name') + # Fix ref names + # :fix_ref_names + for ((i=0; i<${#git_branches[@]}; i++)); do + git_branches[$i]=$(echo "${git_branches[$i]}" | tr -c [:alnum:]+[:cntrl:] [_*]) + done + echo "Found branches:" + echo "${git_branches[@]}" + + cd dev + # 'cd' must run successfully to avoid accidentally deleting anything unnecessary + if [ $? -ne 0 ]; then + echo "Error: Could not change folder to 'dev'. Exiting." + exit 1 + fi + + # Get directories + folders=$(find . -mindepth 1 -maxdepth 1 -type d) + echo "Existing folders:" + echo ${folders[@]} + + for folder in $folders; do + folder_name=$(basename "$folder") + + # Check if the branch exists + if ! echo "$git_branches" | grep -q "^$folder_name$"; then + echo "Removing the folder: $folder_name" + rm -r "$folder_name" + fi + done + + - name: Add a dev index.html + shell: bash --noprofile --norc -o pipefail {0} + run: | + html_template=' + +
+ +