Skip to content

Commit

Permalink
Merge pull request #30 from Viking-Studios-Arma:make-download-fix
Browse files Browse the repository at this point in the history
make download fix
  • Loading branch information
Amateur-God committed Jun 14, 2024
2 parents 40d2244 + f9dbadf commit 3c1e366
Showing 1 changed file with 5 additions and 26 deletions.
31 changes: 5 additions & 26 deletions tools/make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ $toolsPath = "$projectRoot\tools"
$buildPath = "$projectRoot\.build\@Viking Studios - Milsim Tools"
$cachePath = "$projectRoot\.build\cache"
$modPrefix = "VS_C_"
$releasePage = "https://github.com/KoffeinFlummi/armake/releases"
$downloadPage = "https://github.com/KoffeinFlummi/armake/releases/download/v*.*.*/armake_v*.*.*.zip"
$downloadUrl = "https://github.com/KoffeinFlummi/armake/releases/download/v0.6.3/armake_v0.6.3.zip"
$armake2 = "$projectRoot\tools\armake2.exe"
$armake = "$projectRoot\tools\armake.exe"
$tag = git describe --tag | ForEach-Object {$_ -replace "-.*-", "-"}
Expand Down Expand Up @@ -182,26 +181,6 @@ function Get-InstalledArmakeVersion {
$version
}

function Get-LatestArmakeVersion {
$client = New-Object Net.WebClient
$content = $client.DownloadString($releasePage)
$client.dispose()

# Updated regex to match the latest version from the releases page
$versionMatches = [regex]::Matches($content, 'href="/KoffeinFlummi/armake/releases/download/v([\d\.]+)/armake_v[\d\.]+\.zip"')

if ($versionMatches.Count -eq 0) {
Write-Error -Message "[$timestamp] Failed to find valid armake download link."
return "0.0.0"
}

# Get the highest version number from the matches
$versions = $versionMatches | ForEach-Object { $_.Groups[1].Value }
$latestVersion = $versions | Sort-Object -Descending | Select-Object -First 1

return $latestVersion
}

function Update-Armake {
[CmdletBinding(SupportsShouldProcess=$True)]
param(
Expand Down Expand Up @@ -393,11 +372,11 @@ function Main {
}

$installed = Get-InstalledArmakeVersion
$latest = Get-LatestArmakeVersion
$latest = "0.6.3" # Hardcoded latest version

if (Compare-Version -version1 $latest -version2 $installed) {
Write-Output -InputObject "Found newer version of armake:" " Installed: $installed" " Latest: $latest"
Update-Armake -url ($downloadPage -f $latest)
Write-Output -InputObject ("Found newer version of armake: Installed: " + $installed + " Latest: " + $latest)
Update-Armake -url $downloadUrl
Write-Output -InputObject "Update complete, armake up-to-date."
}

Expand Down Expand Up @@ -433,4 +412,4 @@ function Main {

Copy-SupportFiles
}
Main
Main

0 comments on commit 3c1e366

Please sign in to comment.