forked from Scighost/Starward
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish.ps1
More file actions
72 lines (62 loc) · 3.2 KB
/
Copy pathpublish.ps1
File metadata and controls
72 lines (62 loc) · 3.2 KB
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
65
66
67
68
69
70
71
72
param(
[string] $Architecture = "x64",
[string] $Version = "1.0.0",
[string] $Output = "build/Starward",
[int] $DiffCount = 5,
[array] $DiffTags = @()
)
$ErrorActionPreference = "Stop";
.\build.ps1 -Version $Version -Architecture $Architecture -Output $Output;
if (!(Get-Module -Name 7Zip4Powershell -ListAvailable)) {
Install-Module -Name 7Zip4Powershell -Force;
}
$package = "Starward_Portable_$($Version)_$($Architecture).7z";
Write-Host "Creating package $package ..." -ForegroundColor Green;
Compress-7Zip -ArchiveFileName $package -Path $Output -OutputPath 'build/release/package/' -CompressionLevel Ultra -PreserveDirectoryRoot;
Write-Host "Packing release ..." -ForegroundColor Green;
dotnet run --project 'src/BuildTool' -c Release -p:Platform=x64 -- pack $Output -v $Version -a $Architecture -t portable;
if ($DiffTags.Count -eq 0 -and $DiffCount -gt 0) {
if ($env:GITHUB_TOKEN) {
$json = Invoke-WebRequest 'https://api.github.com/repos/Scighost/Starward/releases' -Headers @{ Authorization = "Bearer $env:GITHUB_TOKEN" } | ConvertFrom-Json;
}
else {
$json = Invoke-WebRequest 'https://api.github.com/repos/Scighost/Starward/releases' | ConvertFrom-Json;
}
$pre = $true;
$stableCount = 0;
foreach ($r in $json) {
if ($r.tag_name -eq $Version) {
continue;
}
if ($pre -and $r.tag_name -like '*-*') {
$DiffTags += $r.tag_name;
Write-Host "Creating diff for $($r.tag_name) ..." -ForegroundColor Green;
dotnet run --project 'src/BuildTool' -c Release -p:Platform=x64 -- diff -np $Output -nv $Version -ov $r.tag_name -a $Architecture -t portable;
}
if ($r.tag_name -notlike '*-*') {
$pre = $false;
$stableCount += 1;
$DiffTags += $r.tag_name;
Write-Host "Creating diff for $($r.tag_name) ..." -ForegroundColor Green;
dotnet run --project 'src/BuildTool' -c Release -p:Platform=x64 -- diff -np $Output -nv $Version -ov $r.tag_name -a $Architecture -t portable;
}
if ($stableCount -ge $DiffCount) {
break;
}
}
}
elseif ($DiffTags.Count -gt 0) {
foreach ($tag in $DiffTags) {
Write-Host "Creating diff for $tag ..." -ForegroundColor Green;
dotnet run --project 'src/BuildTool' -c Release -p:Platform=x64 -- diff -np $Output -nv $Version -ov $tag -a $Architecture -t portable;
}
}
if ($DiffTags.Count -eq 0) {
Write-Host "Creating release info for $($Version)_$($Architecture) ..." -ForegroundColor Green;
dotnet run --project 'src/BuildTool' -c Release -p:Platform=x64 -- release create "build/release_info_$($Version)_$($Architecture).json" -v $Version -a $Architecture -t portable -p "build/release/package/$package";
}
else {
Write-Host "Creating release info for $($Version)_$($Architecture) with diffs $($DiffTags -join ', ') ..." -ForegroundColor Green;
dotnet run --project 'src/BuildTool' -c Release -p:Platform=x64 -- release create "build/release_info_$($Version)_$($Architecture).json" -v $Version -a $Architecture -t portable -p "build/release/package/$package" -d $DiffTags;
}
Remove-Item 'build/release/temp' -Recurse -Force -ErrorAction SilentlyContinue;