From 1cb726195e1457a2fa350da5ad7b1ca50f7d36e1 Mon Sep 17 00:00:00 2001 From: Marc Platt <97549900+mplatt8@users.noreply.github.com> Date: Tue, 30 Jul 2024 15:09:07 -0400 Subject: [PATCH 1/2] Change build.yaml to build.yaml from ash/ci --- .github/workflows/build.yml | 212 +++++++++++++++--------------------- 1 file changed, 85 insertions(+), 127 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 185304b..5e8a532 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,29 +1,66 @@ name: Build Launcher on: pull_request: - branches: - - "main" push: branches: - - "marc" + - "main" workflow_dispatch: jobs: - build-macos: - runs-on: macos-latest + build: + # both Windows and Linux builds run on Ubuntu + runs-on: ${{ matrix.build == 'macos' && 'macos' || 'ubuntu' }}-latest + strategy: + fail-fast: false + matrix: + build: [macos, windows, linux] + include: + - build: linux + godot-bin: 'godot.linuxbsd.editor.x86_64.mono' + - build: macos + godot-bin: 'godot.macos.editor.universal' + # Windows build runs on Ubuntu + - build: windows + godot-bin: 'godot.linuxbsd.editor.x86_64.mono' + steps: - uses: actions/checkout@v3 - uses: chickensoft-games/setup-godot@v1 with: - version: 4.2.1 - use-dotnet: false + version: 4.2.2 + # When running on Linux, we have to use the .NET build, as this is + # the only custom build available from the CI + use-dotnet: ${{ matrix.build == 'linux' || matrix.build == 'windows' }} include-templates: true + - name: Download Godot w/Bitcoin module + uses: robinraju/release-downloader@v1.11 + with: + repository: LayerTwo-Labs/godot-bitcoin-module + tag: v4.2.2-bitcoin + filename: ${{ matrix.godot-bin }} + + # FIXME: remove + - name: show files + run: | + ls + #echo 'TEMPLATES' + #ls '/Users/runner/Library/Application Support/Godot/export_templates/4.2.2.stable' + #echo 'MACOS TEMPLATES' + #zipinfo -1 '/Users/runner/Library/Application Support/Godot/export_templates/4.2.2.stable/macos.zip' + #echo 'VERSION TXT' + #cat '/Users/runner/Library/Application Support/Godot/export_templates/4.2.2.stable/version.txt' + echo $GODOT + - name: Verify Setup run: | + chmod +x ${{ matrix.godot-bin }} + mv ${{ matrix.godot-bin }} $GODOT godot --version + - name: Import certificate to Keychain + if: ${{ matrix.build == 'macos' }} run: | echo "${{ secrets.MACOS_CERTIFICATE }}" | base64 --decode > certificate.p12 KEYCHAIN_PASSWORD=$(uuidgen) @@ -36,149 +73,70 @@ jobs: MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }} - name: Setup notarization credentials + if: ${{ matrix.build == 'macos' }} run: | echo ${{ secrets.GODOT_MACOS_NOTARIZATION_API_KEY }} | base64 --decode > notarization_api_key.p8 + + # MUST be run before build + - name: Initialize godot cache + run: python3 .github/scripts/godot_ci_cache.py + - name: Export build run: | - godot --headless --export-debug "macOS" --verbose 2>&1 | tee build.log + name="${{fromJSON('{"windows": "Windows Desktop", "macos": "macOS", "linux": "Linux/X11"}')[matrix.build] }}" + godot --headless --export-debug "$name" --verbose 2>&1 | tee build.log + env: - GODOT_MACOS_NOTARIZATION_API_KEY_ID: ${{ secrets.GODOT_MACOS_NOTARIZATION_API_KEY_ID }} + GODOT_MACOS_NOTARIZATION_API_KEY_ID: + ${{ secrets.GODOT_MACOS_NOTARIZATION_API_KEY_ID }} GODOT_MACOS_NOTARIZATION_API_KEY: ./notarization_api_key.p8 - GODOT_MACOS_NOTARIZATION_API_UUID: ${{ secrets.GODOT_MACOS_NOTARIZATION_API_UUID }} + GODOT_MACOS_NOTARIZATION_API_UUID: + ${{ secrets.GODOT_MACOS_NOTARIZATION_API_UUID }} - - name: Upload macOS build + - name: Upload build uses: actions/upload-artifact@v4 with: - name: drivechain_launcher_macos + name: drivechain_launcher_${{ matrix.build }} if-no-files-found: error path: build/drivechain_launcher-* - name: Wait for notarization to finish + if: ${{ matrix.build == 'macos' }} run: | request_id=$(grep 'Notarization request UUID' build.log | rev | cut -d ' ' -f 1 | rev | tr -d '"') + xcrun notarytool wait $request_id \ --issuer ${{ secrets.GODOT_MACOS_NOTARIZATION_API_UUID }} \ --key-id ${{ secrets.GODOT_MACOS_NOTARIZATION_API_KEY_ID }} \ --key ./notarization_api_key.p8 - build-windows-linux: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - build: [windows, linux] - - steps: - - uses: actions/checkout@v3 - - - uses: chickensoft-games/setup-godot@v1 - with: - version: 4.2.1 - use-dotnet: false - include-templates: true - - - name: Verify Setup - run: | - godot --version - - name: Export build - run: | - name="${{fromJSON('{"windows": "Windows Desktop", "linux": "Linux/X11"}')[matrix.build] }}" - godot --headless --export-debug "$name" --verbose 2>&1 | tee build.log - - name: Upload Windows/Linux build - uses: actions/upload-artifact@v4 - with: - name: drivechain_launcher_${{ matrix.build }} - if-no-files-found: error - path: build/drivechain_launcher-* - test-windows-linux: - name: Test Windows and Linux Builds + upload-artifacts-to-releases-drivechain-info: + name: Upload artifacts to releases.drivechain.info runs-on: ubuntu-latest - needs: build-windows-linux + needs: [build] + # avoid uploading on PRs! + if: github.event_name == 'push' && github.repository_owner == 'LayerTwo-Labs' steps: - - name: Download Windows/Linux artifacts + - name: Download artifacts uses: actions/download-artifact@v4 - with: - name: drivechain_launcher_windows - - name: Download Windows/Linux artifacts - uses: actions/download-artifact@v4 - with: - name: drivechain_launcher_linux + - name: Create zip files for releases.drivechain.info + run: | + mv drivechain_launcher_linux drivechain-launcher-latest-x86_64-unknown-linux-gnu + zip -r drivechain-launcher-latest-x86_64-unknown-linux-gnu.zip drivechain-launcher-latest-x86_64-unknown-linux-gnu/* - - name: Check out the repository - uses: actions/checkout@v3 + mv drivechain_launcher_macos drivechain-launcher-latest-x86_64-apple-darwin + zip -r drivechain-launcher-latest-x86_64-apple-darwin.zip drivechain-launcher-latest-x86_64-apple-darwin/* - - name: Run Integration Tests - run: | - chmod +x ./scripts/integration_testing.sh || echo "Drivechain script not found, skipping chmod" - ./scripts/integration_testing.sh || echo "Script not found, skipping tests" - - name: Drivechain Testing Output - run: | - chmod +x ./scripts/drivechain_testing.sh || echo "Function scrript not found, skipping chmod" - ./scripts/drivechain_testing.sh || echo "Script not found, skipping tests" - upload-artifacts-macos: - name: Upload macOS artifacts to releases.drivechain.info - runs-on: ubuntu-latest - needs: build-macos - if: github.event_name == 'push' && github.repository_owner == 'LayerTwo-Labs' - steps: - # - name: Download macOS artifacts - # uses: actions/download-artifact@v4 - # with: - # name: drivechain_launcher_macos - - # - name: Create zip files for macOS - # run: | - # mv drivechain_launcher_macos drivechain-launcher-latest-x86_64-apple-darwin - # zip -r drivechain-launcher-latest-x86_64-apple-darwin.zip drivechain-launcher-latest-x86_64-apple-darwin/* - - # - name: Upload macOS release assets to releases.drivechain.info - # uses: cross-the-world/ssh-scp-ssh-pipelines@latest - # with: - # host: 45.33.96.47 - # user: root - # pass: ${{ secrets.RELEASES_SERVER_PW }} - # port: 22 - # scp: | - # 'drivechain-launcher-latest-x86_64-apple-darwin.zip' => '/var/www/html/' - - - name: Skip upload macOS artifacts - run: echo "Skipping upload of macOS artifacts" - - upload-artifacts-windows-linux: - name: Upload Windows/Linux artifacts to releases.drivechain.info - runs-on: ubuntu-latest - needs: [test-windows-linux] - if: github.event_name == 'push' && github.repository_owner == 'LayerTwo-Labs' - steps: - # - name: Download Windows/Linux artifacts - # uses: actions/download-artifact@v4 - # with: - # name: drivechain_launcher_windows - - # - name: Download Windows/Linux artifacts - # uses: actions/download-artifact@v4 - # with: - # name: drivechain_launcher_linux - - # - name: Create zip files for Windows/Linux - # run: | - # mv drivechain_launcher_linux drivechain-launcher-latest-x86_64-unknown-linux-gnu - # zip -r drivechain-launcher-latest-x86_64-unknown-linux-gnu.zip drivechain-launcher-latest-x86_64-unknown-linux-gnu/* - - # mv drivechain_launcher_windows drivechain-launcher-latest-x86_64-w64 - # zip -r drivechain-launcher-latest-x86_64-w64.zip drivechain-launcher-latest-x86_64-w64/* - - # - name: Upload Windows/Linux release assets to releases.drivechain.info - # uses: cross-the-world/ssh-scp-ssh-pipelines@latest - # with: - # host: 45.33.96.47 - # user: root - # pass: ${{ secrets.RELEASES_SERVER_PW }} - # port: 22 - # scp: | - # 'drivechain-launcher-latest-x86_64-unknown-linux-gnu.zip' => '/var/www/html/' - # 'drivechain-launcher-latest-x86_64-w64.zip' => '/var/www/html/' - - - name: Skip upload Windows/Linux artifacts - run: echo "Skipping upload of Windows/Linux artifacts" + mv drivechain_launcher_windows drivechain-launcher-latest-x86_64-w64 + zip -r drivechain-launcher-latest-x86_64-w64.zip drivechain-launcher-latest-x86_64-w64/* + + - name: Upload release assets to releases.drivechain.info + uses: cross-the-world/ssh-scp-ssh-pipelines@latest + with: + host: 45.33.96.47 + user: root + pass: ${{ secrets.RELEASES_SERVER_PW }} + port: 22 + scp: | + 'drivechain-launcher-latest-*.zip' => '/var/www/html/' From a1af0f17a51d4b3d4d7764564626d891372e6702 Mon Sep 17 00:00:00 2001 From: Ash Manning Date: Mon, 29 Jul 2024 20:25:02 +0800 Subject: [PATCH 2/2] update CI to use Godot w/Bitcoin module --- .github/scripts/godot_ci_cache.py | 79 ++++++++++++++++++++++++++++++ .github/workflows/build.yml | 81 ++++++++++++++++++++++++++++++- 2 files changed, 158 insertions(+), 2 deletions(-) create mode 100644 .github/scripts/godot_ci_cache.py diff --git a/.github/scripts/godot_ci_cache.py b/.github/scripts/godot_ci_cache.py new file mode 100644 index 0000000..ef77335 --- /dev/null +++ b/.github/scripts/godot_ci_cache.py @@ -0,0 +1,79 @@ +# +# Fixes https://github.com/godotengine/godot/issues/77508 +# original script source: https://gist.github.com/d6e/5ed21c37a8ac294db26532cc6af5c61c +# + +import os +import subprocess +import time +import re +from pathlib import Path + +# Set the path to your Godot project and Godot executable +GODOT_PROJECT_PATH = Path(".") +GODOT_EXECUTABLE = "godot" # or the path to your Godot executable +GODOT_LOG_FILE = Path("artifacts") / "godot_output.log" # Log file to store Godot output + +print("Building godot cache...", flush=True) +start_time = time.time() + +# Step 1: Recursively find all '.import' files and collect the expected imported file paths +expected_imported_files = set() +for import_file in GODOT_PROJECT_PATH.rglob('*.import'): + content = import_file.read_text() + matches = re.findall(r'dest_files=\["(res://\.godot/imported/.+?)"\]', content) + expected_imported_files.update(matches) + +total_imports = len(expected_imported_files) +print(f"Found {total_imports} references to imported files...", flush=True) + +# Step 2: Launch Godot in the background to start the import process +print("Starting Godot to import files...", flush=True) +GODOT_LOG_FILE.parent.mkdir(parents=True, exist_ok=True) +with GODOT_LOG_FILE.open("w") as log_file: + try: + godot_process = subprocess.Popen( + [GODOT_EXECUTABLE, "--path", str(GODOT_PROJECT_PATH), "--editor", "--headless"], + stdout=log_file, + stderr=subprocess.STDOUT + ) + except Exception as e: + print(f"Failed to start Godot: {e}") + exit(1) + +# Step 3: Continually check if the expected imported files exist +imported_folder = GODOT_PROJECT_PATH / ".godot/imported" +while expected_imported_files: + # Wait until the imported directory exists + if not imported_folder.exists(): + print(f"Waiting for the imported directory to be created by Godot...") + time.sleep(1) + continue + + for expected_path in list(expected_imported_files): + imported_file_path = GODOT_PROJECT_PATH / expected_path.replace("res://", "") + if imported_file_path.exists(): + expected_imported_files.remove(expected_path) + imported_count = total_imports - len(expected_imported_files) + print(f"Imported {imported_count} / {total_imports} files...") + time.sleep(1) # Wait for a second before checking again + +elapsed_time = time.time() - start_time +print(f"Imported all files in {elapsed_time:.2f} seconds.", flush=True) + +# Step 4: Once all files have been imported, quit Godot +try: + print("Quitting Godot...", flush=True) + start_time = time.time() + godot_process.terminate() + godot_process.wait(timeout=10) + +except subprocess.TimeoutExpired: + print("Godot did not terminate in a timely manner; killing the process.") + godot_process.kill() +finally: + elapsed_time = time.time() - start_time + print(f"Godot has been closed in {elapsed_time:.2f} seconds.", flush=True) + +print("All files have been imported. Godot has been closed.") + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5e8a532..5f9b93e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,11 +17,17 @@ jobs: include: - build: linux godot-bin: 'godot.linuxbsd.editor.x86_64.mono' + godot-template-bins: 'godot.linuxbsd.template_*' + godot-templates-dir: '/home/runner/.local/share/godot/export_templates/4.2.2.stable.mono' - build: macos godot-bin: 'godot.macos.editor.universal' + godot-template-bins: 'godot.macos.template_*' + godot-templates-dir: '/Users/runner/Library/Application Support/Godot/export_templates/4.2.2.stable' # Windows build runs on Ubuntu - build: windows godot-bin: 'godot.linuxbsd.editor.x86_64.mono' + godot-template-bins: 'godot.windows.template_*' + godot-templates-dir: '/home/runner/.local/share/godot/export_templates/4.2.2.stable.mono' steps: - uses: actions/checkout@v3 @@ -41,8 +47,27 @@ jobs: tag: v4.2.2-bitcoin filename: ${{ matrix.godot-bin }} + - name: Download Godot templates w/Bitcoin module + uses: robinraju/release-downloader@v1.11 + with: + repository: LayerTwo-Labs/godot-bitcoin-module + tag: v4.2.2-bitcoin + filename: ${{ matrix.godot-template-bins }} + + # FIXME: remove + - name: show files (linux / windows) + if: ${{ matrix.build == 'linux' || matrix.build == 'windows' }} + run: | + ls + echo 'TEMPLATES' + ls ${{ matrix.godot-templates-dir }} + echo 'VERSION TXT' + cat "${{ matrix.godot-templates-dir }}/version.txt" + echo $GODOT + # FIXME: remove - - name: show files + - name: show files (macos) + if: ${{ matrix.build == 'macos' }} run: | ls #echo 'TEMPLATES' @@ -53,6 +78,59 @@ jobs: #cat '/Users/runner/Library/Application Support/Godot/export_templates/4.2.2.stable/version.txt' echo $GODOT + - name: Replace default templates with custom templates (linux) + if: ${{ matrix.build == 'linux' }} + run: | + rm "${{ matrix.godot-templates-dir }}/linux_debug.x86_64" + mv godot.linuxbsd.template_debug.x86_64.mono "${{ matrix.godot-templates-dir }}/linux_debug.x86_64" + rm "${{ matrix.godot-templates-dir }}/linux_release.x86_64" + mv godot.linuxbsd.template_release.x86_64.mono "${{ matrix.godot-templates-dir }}/linux_release.x86_64" + + - name: Replace default templates with custom templates (macos) + if: ${{ matrix.build == 'macos' }} + run: | + # Temporary directory used to construct the zip file + TMP_ZIP_DIR=$(mktemp -d) + mkdir -p "${TMP_ZIP_DIR}/macos_template.app/Contents/MacOS" + mv "godot.macos.template_debug.universal" "${TMP_ZIP_DIR}/macos_template.app/Contents/MacOS/godot_macos_debug.universal" + mv "godot.macos.template_release.universal" "${TMP_ZIP_DIR}/macos_template.app/Contents/MacOS/godot_macos_release.universal" + zip --delete "${{ matrix.godot-templates-dir }}/macos.zip" "macos_template.app/Contents/MacOS/godot_macos_debug.universal" + zip --delete "${{ matrix.godot-templates-dir }}/macos.zip" "macos_template.app/Contents/MacOS/godot_macos_release.universal" + pushd "${TMP_ZIP_DIR}" + zip "${{ matrix.godot-templates-dir }}/macos.zip" "macos_template.app/Contents/MacOS/godot_macos_debug.universal" + zip "${{ matrix.godot-templates-dir }}/macos.zip" "macos_template.app/Contents/MacOS/godot_macos_release.universal" + popd + + - name: Replace default templates with custom templates (windows) + if: ${{ matrix.build == 'windows' }} + run: | + rm "${{ matrix.godot-templates-dir }}/windows_debug_x86_64.exe" + mv "godot.windows.template_debug.x86_64.exe" "${{ matrix.godot-templates-dir }}/windows_debug_x86_64.exe" + rm "${{ matrix.godot-templates-dir }}/windows_debug_x86_64_console.exe" + mv "godot.windows.template_debug.x86_64.console.exe" "${{ matrix.godot-templates-dir }}/windows_debug_x86_64_console.exe" + rm "${{ matrix.godot-templates-dir }}/windows_release_x86_64.exe" + mv "godot.windows.template_release.x86_64.exe" "${{ matrix.godot-templates-dir }}/windows_release_x86_64.exe" + rm "${{ matrix.godot-templates-dir }}/windows_release_x86_64_console.exe" + mv "godot.windows.template_release.x86_64.console.exe" "${{ matrix.godot-templates-dir }}/windows_release_x86_64_console.exe" + + # FIXME: remove + - name: show files (linux / windows) + if: ${{ matrix.build == 'linux' || matrix.build == 'windows' }} + run: | + ls + echo 'TEMPLATES' + ls ${{ matrix.godot-templates-dir }} + + # FIXME: remove + - name: show files (macos) + if: ${{ matrix.build == 'macos' }} + run: | + ls + echo 'TEMPLATES' + ls '/Users/runner/Library/Application Support/Godot/export_templates/4.2.2.stable' + echo 'MACOS TEMPLATES' + zipinfo -1 '/Users/runner/Library/Application Support/Godot/export_templates/4.2.2.stable/macos.zip' + - name: Verify Setup run: | chmod +x ${{ matrix.godot-bin }} @@ -85,7 +163,6 @@ jobs: run: | name="${{fromJSON('{"windows": "Windows Desktop", "macos": "macOS", "linux": "Linux/X11"}')[matrix.build] }}" godot --headless --export-debug "$name" --verbose 2>&1 | tee build.log - env: GODOT_MACOS_NOTARIZATION_API_KEY_ID: ${{ secrets.GODOT_MACOS_NOTARIZATION_API_KEY_ID }}