-
Notifications
You must be signed in to change notification settings - Fork 22
/
BuildRelease.ps1
64 lines (48 loc) · 2.66 KB
/
BuildRelease.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
## download the last release locally so we can build a delta against it
## Deltas are only ever built against the last previous release, never against more
$squirrel = Get-ChildItem .\Squirrel\squirrel.windows.*\tools\Squirrel.com
$squirrelDll = Get-ChildItem .\Squirrel\squirrel.windows.*\lib\net45\Squirrel.dll
if (-Not(Test-Path -PathType Leaf $squirrel)) {
Write-Error "Squirrel executable is not present"
Exit 1
}
$releasesDir = "releases-packages"
if (Test-Path $releasesDir) {
rm -Force -Recurse $releasesDir
}
mkdir -Force $releasesDir
# Get the latest nuget package
$releasePackage = Join-Path (pwd) "TemplePlus.$($env:TEMPLEPLUS_VERSION).nupkg"
if (!$releasePackage -Or -Not(Test-Path $releasePackage)) {
Write-Error "NuGet package for release doesnt seem to be built. Make sure to run PackRelease.ps1 first"
Exit 1
}
# Download last release to make delta packages!
Invoke-WebRequest https://templeplus.org/update-feeds/stable/RELEASES -OutFile $releasesDir\RELEASES
Add-Type -LiteralPath $squirrelDll
# Using squirrel code here to parse the RELEASES file and get the previous release
$releasesContent = Get-Content $releasesDir\RELEASES -Encoding UTF8 | Out-String
$releases = [Squirrel.ReleaseEntry]::ParseReleaseFile($releasesContent)
$rp = New-Object "Squirrel.ReleasePackage" $releasePackage
$prevRelease = [Squirrel.ReleaseEntry]::GetPreviousRelease($releases, $rp, $releasesDir)
if (!$prevRelease) {
"No previous release found. Picking last full release."
$prevRelease = $releases | Sort-Object Version -Descending | Where-Object { -not $_.IsDelta } | Select-Object -First 1
$targetPath = Join-Path $releasesDir $prevRelease.Filename
$prevRelease = [Squirrel.ReleasePackage]::new($targetPath, $true)
}
"Last Full Release: $($prevRelease.Version.ToString())"
$tagName = "v$($prevRelease.Version.ToString())"
$filenameOnly = [IO.Path]::GetFileName($prevRelease.InputPackageFile)
$downloadUrl = "https://github.com/GrognardsFromHell/TemplePlus/releases/download/$tagName/$filenameOnly"
Invoke-WebRequest $downloadUrl -OutFile $prevRelease.InputPackageFile
# The tag name is actually part of the download URL on github
$baseUrl = "--baseUrl=https://github.com/GrognardsFromHell/TemplePlus/releases/download/v$($env:TEMPLEPLUS_VERSION)/"
"Using BaseURL: $baseUrl"
&$squirrel --releasify=$releasePackage --loadingGif=Configurator\Installing.gif --icon=TemplePlus\toee_gog_icon.ico --setupIcon=TemplePlus\toee_gog_icon.ico --releaseDir=$releasesDir $baseUrl --no-msi
ren "$releasesDir\Setup.exe" "TemplePlusSetup.exe"
# Remove the previous release so it isn't accidentally uploaded as well
if ($prevRelease) {
Remove-Item $prevRelease.InputPackageFile
}