Places build templates in correct location

This commit is contained in:
2026-08-28 17:02:28 -07:00
parent ffba9651c4
commit 391127c5b9
3 changed files with 66 additions and 9 deletions
+24 -3
View File
@@ -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.' }