From 391127c5b9b51f89c8c782808ae49f08a14f49ea Mon Sep 17 00:00:00 2001 From: Alexander Loren Date: Fri, 28 Aug 2026 17:02:28 -0700 Subject: [PATCH] Places build templates in correct location --- export-linux.sh | 24 +++++++++++++++++++++--- export-macos.sh | 24 +++++++++++++++++++++--- export-windows.ps1 | 27 ++++++++++++++++++++++++--- 3 files changed, 66 insertions(+), 9 deletions(-) diff --git a/export-linux.sh b/export-linux.sh index 8162db3..242a2d6 100644 --- a/export-linux.sh +++ b/export-linux.sh @@ -60,22 +60,39 @@ find_editor() { find "$EDITOR_DIR" -maxdepth 3 -type f -name 'Godot*' -print -quit } +install_export_templates() { + local staging_directory="$1" + local staged_templates="$staging_directory/templates" + local staged_version="$staged_templates/version.txt" + local actual_template_version + + [[ -f "$staged_version" ]] || fail "The export-template archive '$TEMPLATES_ASSET' did not contain templates/version.txt." + actual_template_version="$(tr -d '\r\n' < "$staged_version")" + [[ "$actual_template_version" == "$TEMPLATE_VERSION" ]] || fail "The export-template archive '$TEMPLATES_ASSET' reports template version '$actual_template_version', expected '$TEMPLATE_VERSION'." + mkdir -p "$TEMPLATE_DIR" + cp -R "$staged_templates/." "$TEMPLATE_DIR/" + rm -rf "$staging_directory" + [[ -f "$TEMPLATE_DIR/version.txt" ]] || fail "The export-template archive '$TEMPLATES_ASSET' could not be installed to '$TEMPLATE_DIR'." +} + install_godot() { local sum_file="$CACHE_DIR/SHA512-SUMS.txt" local editor_archive="$CACHE_DIR/$EDITOR_ASSET" local templates_archive="$CACHE_DIR/$TEMPLATES_ASSET" + local templates_staging_directory="$CACHE_DIR/templates-staging" local editor_checksum local templates_checksum rm -rf "$CACHE_DIR" - mkdir -p "$EDITOR_DIR" "$TEMPLATE_DIR" + mkdir -p "$EDITOR_DIR" curl --fail --location --retry 3 --silent --show-error "$BASE_URL/SHA512-SUMS.txt" --output "$sum_file" editor_checksum="$(release_asset_checksum "$EDITOR_ASSET" "$sum_file")" templates_checksum="$(release_asset_checksum "$TEMPLATES_ASSET" "$sum_file")" download_and_verify "$EDITOR_ASSET" "$editor_archive" "$editor_checksum" download_and_verify "$TEMPLATES_ASSET" "$templates_archive" "$templates_checksum" unzip -q "$editor_archive" -d "$EDITOR_DIR" - unzip -q "$templates_archive" -d "$TEMPLATE_DIR" + unzip -q "$templates_archive" -d "$templates_staging_directory" + install_export_templates "$templates_staging_directory" EDITOR_EXECUTABLE="$(find_editor)" [[ -n "$EDITOR_EXECUTABLE" ]] || fail "The Godot editor archive did not contain an executable." [[ -f "$TEMPLATE_DIR/version.txt" ]] || fail "The export-template archive did not contain version.txt." @@ -118,14 +135,15 @@ if [[ "$GODOT_DOTNET" == "true" ]]; then EDITION=dotnet EDITOR_ASSET="Godot_v${GODOT_VERSION}_mono_linux_${GODOT_HOST_ARCH}.zip" TEMPLATES_ASSET="Godot_v${GODOT_VERSION}_mono_export_templates.tpz" + TEMPLATE_VERSION="${GODOT_VERSION//-/.}.mono" else EDITION=standard EDITOR_ASSET="Godot_v${GODOT_VERSION}_linux.${GODOT_HOST_ARCH}.zip" TEMPLATES_ASSET="Godot_v${GODOT_VERSION}_export_templates.tpz" + TEMPLATE_VERSION="${GODOT_VERSION//-/.}" fi BASE_URL="https://github.com/godotengine/godot/releases/download/$GODOT_VERSION" -TEMPLATE_VERSION="${GODOT_VERSION//-/.}" CACHE_DIR="$GODOT_ACTION_ROOT/cache/$GODOT_VERSION/$EDITION/linux-$GODOT_HOST_ARCH" EDITOR_DIR="$CACHE_DIR/editor" USER_DATA_DIR="$CACHE_DIR/user-data" diff --git a/export-macos.sh b/export-macos.sh index 9dbce41..20d3810 100644 --- a/export-macos.sh +++ b/export-macos.sh @@ -58,22 +58,39 @@ find_editor() { find "$EDITOR_DIR" -type f -path '*.app/Contents/MacOS/*' -name 'Godot*' -print -quit } +install_export_templates() { + local staging_directory="$1" + local staged_templates="$staging_directory/templates" + local staged_version="$staged_templates/version.txt" + local actual_template_version + + [[ -f "$staged_version" ]] || fail "The export-template archive '$TEMPLATES_ASSET' did not contain templates/version.txt." + actual_template_version="$(tr -d '\r\n' < "$staged_version")" + [[ "$actual_template_version" == "$TEMPLATE_VERSION" ]] || fail "The export-template archive '$TEMPLATES_ASSET' reports template version '$actual_template_version', expected '$TEMPLATE_VERSION'." + mkdir -p "$TEMPLATE_DIR" + cp -R "$staged_templates/." "$TEMPLATE_DIR/" + rm -rf "$staging_directory" + [[ -f "$TEMPLATE_DIR/version.txt" ]] || fail "The export-template archive '$TEMPLATES_ASSET' could not be installed to '$TEMPLATE_DIR'." +} + install_godot() { local sum_file="$CACHE_DIR/SHA512-SUMS.txt" local editor_archive="$CACHE_DIR/$EDITOR_ASSET" local templates_archive="$CACHE_DIR/$TEMPLATES_ASSET" + local templates_staging_directory="$CACHE_DIR/templates-staging" local editor_checksum local templates_checksum rm -rf "$CACHE_DIR" - mkdir -p "$EDITOR_DIR" "$TEMPLATE_DIR" + mkdir -p "$EDITOR_DIR" curl --fail --location --retry 3 --silent --show-error "$BASE_URL/SHA512-SUMS.txt" --output "$sum_file" editor_checksum="$(release_asset_checksum "$EDITOR_ASSET" "$sum_file")" templates_checksum="$(release_asset_checksum "$TEMPLATES_ASSET" "$sum_file")" download_and_verify "$EDITOR_ASSET" "$editor_archive" "$editor_checksum" download_and_verify "$TEMPLATES_ASSET" "$templates_archive" "$templates_checksum" unzip -q "$editor_archive" -d "$EDITOR_DIR" - unzip -q "$templates_archive" -d "$TEMPLATE_DIR" + unzip -q "$templates_archive" -d "$templates_staging_directory" + install_export_templates "$templates_staging_directory" EDITOR_EXECUTABLE="$(find_editor)" [[ -n "$EDITOR_EXECUTABLE" ]] || fail "The Godot editor archive did not contain a macOS app executable." [[ -f "$TEMPLATE_DIR/version.txt" ]] || fail "The export-template archive did not contain version.txt." @@ -116,14 +133,15 @@ if [[ "$GODOT_DOTNET" == "true" ]]; then EDITION=dotnet EDITOR_ASSET="Godot_v${GODOT_VERSION}_mono_macos.universal.zip" TEMPLATES_ASSET="Godot_v${GODOT_VERSION}_mono_export_templates.tpz" + TEMPLATE_VERSION="${GODOT_VERSION//-/.}.mono" else EDITION=standard EDITOR_ASSET="Godot_v${GODOT_VERSION}_macos.universal.zip" TEMPLATES_ASSET="Godot_v${GODOT_VERSION}_export_templates.tpz" + TEMPLATE_VERSION="${GODOT_VERSION//-/.}" fi BASE_URL="https://github.com/godotengine/godot/releases/download/$GODOT_VERSION" -TEMPLATE_VERSION="${GODOT_VERSION//-/.}" CACHE_DIR="$GODOT_ACTION_ROOT/cache/$GODOT_VERSION/$EDITION/macos-$GODOT_HOST_ARCH" EDITOR_DIR="$CACHE_DIR/editor" USER_HOME="$CACHE_DIR/home" diff --git a/export-windows.ps1 b/export-windows.ps1 index fcd5f8b..7a5e9ae 100644 --- a/export-windows.ps1 +++ b/export-windows.ps1 @@ -56,6 +56,24 @@ function Find-Editor([string]$Directory) { return $null } +function Install-ExportTemplates([string]$StagingDirectory, [string]$TemplateDirectory, [string]$TemplateAsset, [string]$ExpectedVersion) { + $stagedTemplates = Join-Path $StagingDirectory 'templates' + $stagedVersion = Join-Path $stagedTemplates 'version.txt' + if (-not (Test-Path -LiteralPath $stagedVersion -PathType Leaf)) { + Fail "The export-template archive '$TemplateAsset' did not contain templates/version.txt." + } + $actualVersion = (Get-Content -LiteralPath $stagedVersion -Raw).Trim() + if ($actualVersion -ne $ExpectedVersion) { + Fail "The export-template archive '$TemplateAsset' reports template version '$actualVersion', expected '$ExpectedVersion'." + } + New-Item -ItemType Directory -Force -Path $TemplateDirectory | Out-Null + Get-ChildItem -LiteralPath $stagedTemplates -Force | Copy-Item -Destination $TemplateDirectory -Recurse -Force + Remove-Item -LiteralPath $StagingDirectory -Recurse -Force + if (-not (Test-Path -LiteralPath (Join-Path $TemplateDirectory 'version.txt') -PathType Leaf)) { + Fail "The export-template archive '$TemplateAsset' could not be installed to '$TemplateDirectory'." + } +} + $GodotVersion = Require-Environment 'GODOT_VERSION' $HostOs = Require-Environment 'GODOT_HOST_OS' $HostArch = Require-Environment 'GODOT_HOST_ARCH' @@ -95,6 +113,7 @@ if ($Dotnet -eq 'true') { 'arm64' { "Godot_v${GodotVersion}_mono_windows_arm64.zip" } } $templatesAsset = "Godot_v${GodotVersion}_mono_export_templates.tpz" + $templateVersion = ($GodotVersion -replace '-', '.') + '.mono' } else { $edition = 'standard' $editorAsset = switch ($HostArch) { @@ -103,10 +122,10 @@ if ($Dotnet -eq 'true') { 'arm64' { "Godot_v${GodotVersion}_windows_arm64.exe.zip" } } $templatesAsset = "Godot_v${GodotVersion}_export_templates.tpz" + $templateVersion = $GodotVersion -replace '-', '.' } $script:BaseUrl = "https://github.com/godotengine/godot/releases/download/$GodotVersion" -$templateVersion = $GodotVersion -replace '-', '.' $cacheDirectory = Join-Path $ActionRoot "cache\$GodotVersion\$edition\windows-$HostArch" $editorDirectory = Join-Path $cacheDirectory 'editor' $userHome = Join-Path $cacheDirectory 'home' @@ -120,17 +139,19 @@ if ((Test-Path -LiteralPath $marker -PathType Leaf) -and (Test-Path -LiteralPath if (-not $editorExecutable) { if (Test-Path -LiteralPath $cacheDirectory) { Remove-Item -LiteralPath $cacheDirectory -Recurse -Force } - New-Item -ItemType Directory -Force -Path $editorDirectory, $templateDirectory | Out-Null + New-Item -ItemType Directory -Force -Path $editorDirectory | Out-Null $manifestPath = Join-Path $cacheDirectory 'SHA512-SUMS.txt' $editorArchive = Join-Path $cacheDirectory $editorAsset $templatesArchive = Join-Path $cacheDirectory $templatesAsset + $templatesStagingDirectory = Join-Path $cacheDirectory 'templates-staging' Invoke-WebRequest -Uri "$script:BaseUrl/SHA512-SUMS.txt" -OutFile $manifestPath $editorChecksum = Get-Checksum $manifestPath $editorAsset $templatesChecksum = Get-Checksum $manifestPath $templatesAsset Download-AndVerify $editorAsset $editorArchive $editorChecksum Download-AndVerify $templatesAsset $templatesArchive $templatesChecksum Expand-Archive -LiteralPath $editorArchive -DestinationPath $editorDirectory -Force - Expand-Archive -LiteralPath $templatesArchive -DestinationPath $templateDirectory -Force + Expand-Archive -LiteralPath $templatesArchive -DestinationPath $templatesStagingDirectory -Force + Install-ExportTemplates $templatesStagingDirectory $templateDirectory $templatesAsset $templateVersion $editorExecutable = Find-Editor $editorDirectory if (-not $editorExecutable) { Fail 'The Godot editor archive did not contain an executable.' } if (-not (Test-Path -LiteralPath (Join-Path $templateDirectory 'version.txt') -PathType Leaf)) { Fail 'The export-template archive did not contain version.txt.' }