From 101fa7d182dd775a50baacb02c273571891f1060 Mon Sep 17 00:00:00 2001 From: Marco Date: Mon, 24 Feb 2025 17:17:46 +0100 Subject: [PATCH] Build script --- .gitignore | 3 ++- Cirno.csproj | 6 ++++++ Export.ps1 | 43 ++++++++++++++++++++++++++++++++++++++++++- GitVersion.yml | 5 +++++ Publish.ps1 | 25 +++++++++++++++++++++++++ export_presets.cfg | 6 +++--- 6 files changed, 83 insertions(+), 5 deletions(-) create mode 100644 GitVersion.yml create mode 100644 Publish.ps1 diff --git a/.gitignore b/.gitignore index 2bf14b32..22ee633b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # Godot 4+ specific ignores .godot/ .vscode/ -build/** \ No newline at end of file +build/** +release/** \ No newline at end of file diff --git a/Cirno.csproj b/Cirno.csproj index 91540dd0..07241326 100644 --- a/Cirno.csproj +++ b/Cirno.csproj @@ -3,8 +3,14 @@ net8.0 true + + $(GIT_ASSEMBLY_SEM_VER) + $(GIT_ASSEMBLY_SEM_VER) + $(GIT_ASSEMBLY_SEM_FILE_VER) + + \ No newline at end of file diff --git a/Export.ps1 b/Export.ps1 index 9788c52a..46837b14 100644 --- a/Export.ps1 +++ b/Export.ps1 @@ -1 +1,42 @@ -F:\Apps\Godot_v4.4\Godot_v4.4-rc1_mono_win64.exe --headless --export-release "Windows Desktop" .\build\Cirno_No_Reason.exe \ No newline at end of file +# Define paths +$gitVersionPath = "dotnet-gitversion.exe" +$godotPath = "F:\Apps\Godot_v4.4\Godot_v4.4-rc1_mono_win64.exe" +$buildDir = ".\build" +$configFile = "export_presets.cfg" +$zipOutputDir = ".\release" +$fileName = "Cirno_No_Reason" + +# Step 1: Clear the build directory +if (Test-Path $buildDir) { + Remove-Item "$buildDir\*" -Recurse -Force +} else { + New-Item -ItemType Directory -Path $buildDir | Out-Null +} + +# Step 2: Get version data from GitVersion +$gitVersionOutput = & $gitVersionPath | ConvertFrom-Json +$assemblySemFileVer = $gitVersionOutput.AssemblySemFileVer +$assemblySemVer = $gitVersionOutput.AssemblySemVer +$fullSemVer = $gitVersionOutput.FullSemVer + +# Step 3: Set environment variables for use in the build process +[System.Environment]::SetEnvironmentVariable("GIT_ASSEMBLY_SEM_FILE_VER", $assemblySemFileVer, [System.EnvironmentVariableTarget]::Process) +[System.Environment]::SetEnvironmentVariable("GIT_ASSEMBLY_SEM_VER", $assemblySemVer, [System.EnvironmentVariableTarget]::Process) + +Write-Host "Set environment variables:" +Write-Host " GIT_ASSEMBLY_SEM_FILE_VER = $assemblySemFileVer" +Write-Host " GIT_ASSEMBLY_SEM_VER = $assemblySemVer" + +# Step 3: Update export_presets.cfg +if (Test-Path $configFile) { + (Get-Content $configFile) ` + -replace 'application/file_version="[^"]*"', "application/file_version=`"$assemblySemFileVer`"" ` + -replace 'application/product_version="[^"]*"', "application/product_version=`"$assemblySemVer`"" ` + | Set-Content $configFile +} else { + Write-Host "Warning: $configFile not found!" +} + +# Step 4: Export the build +& $godotPath --headless --export-release "Windows Desktop" "$buildDir\$fileName.exe" + diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 00000000..d43e1d22 --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1,5 @@ +mode: ContinuousDeployment +branches: {} +ignore: + sha: [] +merge-message-formats: {} diff --git a/Publish.ps1 b/Publish.ps1 new file mode 100644 index 00000000..c24d0dec --- /dev/null +++ b/Publish.ps1 @@ -0,0 +1,25 @@ +$butlerPath = "F:\Apps\butler\butler.exe" +$zipOutputDir = ".\release" +$fileName = "Cirno_No_Reason" +$gitVersionPath = "dotnet-gitversion.exe" +$buildDir = ".\build" + +$gitVersionOutput = & $gitVersionPath | ConvertFrom-Json +$assemblySemFileVer = $gitVersionOutput.AssemblySemFileVer +$assemblySemVer = $gitVersionOutput.AssemblySemVer +$fullSemVer = $gitVersionOutput.FullSemVer +$PreReleaseLabel = $gitVersionOutput.PreReleaseLabelWithDash + +$zipFileName = "$fileName.$fullSemVer.zip" +$zipFilePath = "$zipOutputDir\$zipFileName" + +# Zip the build folder +if (!(Test-Path $zipOutputDir)) { + New-Item -ItemType Directory -Path $zipOutputDir | Out-Null +} + +Compress-Archive -Path "$buildDir\*" -DestinationPath $zipFilePath -Force + +Write-Host "Build completed and packaged as $zipFilePath" + +& $butlerPath push $zipFilePath maddoscientisto/cirno-no-reason:windows$PreReleaseLabel --useversion $fullSemVer \ No newline at end of file diff --git a/export_presets.cfg b/export_presets.cfg index c6e4e99b..c2d6655a 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -37,8 +37,8 @@ application/modify_resources=true application/icon="uid://dicat7qqa0a7o" application/console_wrapper_icon="" application/icon_interpolation=4 -application/file_version="" -application/product_version="" +application/file_version="0.1.0.0" +application/product_version="0.1.0.0" application/company_name="Maddo" application/product_name="Cirno: No Reason" application/file_description="" @@ -66,4 +66,4 @@ Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorActi Remove-Item -Recurse -Force '{temp_dir}'" dotnet/include_scripts_content=false dotnet/include_debug_symbols=true -dotnet/embed_build_outputs=false +dotnet/embed_build_outputs=true