0
0
mirror of https://github.com/sp-tarkov/build.git synced 2025-02-13 07:10:46 -05:00
build/project/tag_validate.ps1

79 lines
4.8 KiB
PowerShell
Raw Normal View History

<EFBFBD><EFBFBD>## Validate that the tag exists in each project repository, or fail silent.
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 "' Validating Tag"
Write-Log "<00># Checking for existence of tag: $RELEASE_TAG"
$REPOS = @(
"https://dev.sp-tarkov.com/SPT-AKI/Server.git",
"https://dev.sp-tarkov.com/SPT-AKI/Modules.git",
"https://dev.sp-tarkov.com/SPT-AKI/Launcher.git"
)
$TAG_REGEX = "^[a-zA-Z0-9\.\-_]+$" # Modify this regex as necessary to match your tagging conventions
if (-not ($RELEASE_TAG -match $TAG_REGEX)) {
Write-Log "Invalid tag format: $RELEASE_TAG"
exit 1 # Exit if tag does not match expected pattern
}
$ALL_FOUND = $true
foreach ($REPO in $REPOS) {
try {
$processInfo = New-Object System.Diagnostics.ProcessStartInfo
$processInfo.FileName = "git"
$processInfo.Arguments = "ls-remote --tags $REPO"
$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 listing tags: $stderr"
throw "git ls-remote command failed with exit code $($process.ExitCode)"
}
if ($stdout -match "refs/tags/$RELEASE_TAG") {
Write-Log " <00>! ' Tag '$RELEASE_TAG' found in $REPO"
} else {
Write-Log " <00>! L' Tag '$RELEASE_TAG' not found in $REPO"
$ALL_FOUND = $false
}
}
catch {
$errorMessage = "L' FAIL: Error checking tag in ${REPO}: $_"
Write-Log $errorMessage
$ALL_FOUND = $false
continue # Continue checking others
}
}
if (-not $ALL_FOUND) {
# The build tag is not yet in all modules.
Write-Log "L' Required Build Tag Missing L'"
exit 1
}
Write-Log "<00>& Build Tag Confirmed <00>&"
Write-Output ""