0
0
mirror of https://github.com/sp-tarkov/build.git synced 2025-02-13 08:10:46 -05:00
build/project/build_launcher.ps1
Refringe 73dad7e3be
Changes:
- Updates Drone pipeline with initial version that may or may not work.
- All three project repositories are checked to see if the tag exists before the builds take place.
- Additional static project files are now added into the release directory (release is now whole)
- The release directory is being compressed into a ZIP file using the Deflate algorithm (compatibility) with maximum compression.

TODO:
- Needs major testing within a Drone pipeline--Probably doesn't work at all right now.
- Adapt build script to work with a dynamic tag value.
- Upload release to public folder.
2024-02-27 18:05:43 -05:00

80 lines
4.6 KiB
PowerShell
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Build the Launcher project.
Param(
[Parameter(Mandatory = $true)]
[string] $RELEASE_TAG
)
# Function that pretends the date/time to the start of a log
function Write-Log {
Param(
[string]$Message
)
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
Write-Output "[$timestamp] $Message"
}
Write-Log "✅ Building Launcher Project"
# Set directories
$DIR_ABS = (Get-Location).Path
$DIR = "$DIR_ABS\builds\Launcher"
$DIR_PROJECT = "$DIR\project"
# Remove the build directory if it already exists
if (Test-Path -Path $DIR) {
Write-Log "⏳ Removing Previous Launcher Project Build Directory"
Remove-Item -Recurse -Force $DIR
}
# Pull down the launcher project, at the tag, with no history
Write-Log "⏳ Cloning Launcher Project"
$REPO = "https://dev.sp-tarkov.com/SPT-AKI/Launcher.git"
try {
$processInfo = New-Object System.Diagnostics.ProcessStartInfo
$processInfo.FileName = "git"
$processInfo.Arguments = "clone $REPO --branch $RELEASE_TAG --depth 1 `"$DIR`""
$processInfo.RedirectStandardError = $true
$processInfo.RedirectStandardOutput = $true
$processInfo.UseShellExecute = $false
$processInfo.CreateNoWindow = $true
$process = New-Object System.Diagnostics.Process
$process.StartInfo = $processInfo
$process.Start() | Out-Null
$process.WaitForExit()
$stdout = $process.StandardOutput.ReadToEnd()
$stderr = $process.StandardError.ReadToEnd()
if ($process.ExitCode -ne 0) {
Write-Log "error cloning: $stdout"
throw "git clone command failed with exit code $($process.ExitCode). Error Output: $stderr"
}
}
catch {
$errorMessage = "❌ FAIL: Error Executing git clone: $_"
Write-Log $errorMessage
exit 1 # Fail the build
}
# Create any necessary sub-directories
New-Item -Path $DIR_PROJECT -ItemType Directory -Force | Out-Null
Set-Location $DIR_PROJECT
try {
$BUILD_RESULT = dotnet build --configuration release -m:1 *>&1
if ($LASTEXITCODE -ne 0) {
Write-Log "❌ dotnet build output: $BUILD_RESULT"
throw "dotnet build failed with exit code $LASTEXITCODE"
}
}
catch {
Write-Error "❌ FAIL: Error executing dotnet build: $_"
exit 1 # Fail the build
}
Write-Log "⚡ Launcher Project Built ⚡"
Write-Output ""