forked from RandomEngy/VidCoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
138 lines (106 loc) · 4.47 KB
/
build.ps1
File metadata and controls
138 lines (106 loc) · 4.47 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$versionShort,
[string]$p,
[switch]$beta,
[switch]$debugBuild = $false
)
. ./build_common.ps1
function Publish($folderNameSuffix, $publishProfileName, $version4part, $productName) {
$mainPublishFolderPath = ".\VidCoder\bin\publish-$folderNameSuffix"
if (Test-Path -Path $mainPublishFolderPath) {
Get-ChildItem -Path $mainPublishFolderPath -Include * -File -Recurse | foreach { $_.Delete()}
}
$workerPublishFolderPath = ".\VidCoderWorker\bin\publish-$folderNameSuffix"
if (Test-Path -Path $workerPublishFolderPath) {
Get-ChildItem -Path $workerPublishFolderPath -Include * -File -Recurse | foreach { $_.Delete()}
}
# Publish to VidCoder\bin\publish
& dotnet publish .\VidCoder.sln "/p:PublishProfile=$publishProfileName;Version=$version4part;Product=$productName" -c $configuration
# Copy some extra files for the installer
$extraFiles = @(
".\VidCoder\Icons\File\VidCoderPreset.ico",
".\VidCoder\Icons\File\VidCoderQueue.ico")
foreach ($extraFile in $extraFiles) {
copy $extraFile $mainPublishFolderPath; ExitIfFailed
}
}
function SignExe($installerPath) {
& signtool sign /f D:\certs\ComodoIndividualCertv2.pfx /p $p /fd SHA256 /tr http://timestamp.digicert.com /td SHA256 $installerPath
}
if ($debugBuild) {
$buildFlavor = "Debug"
} else {
$buildFlavor = "Release"
}
$branch = &git rev-parse --abbrev-ref HEAD
if ($beta -and ($branch -eq "master")) {
ExitWithError "Current branch is master but build calls for beta"
}
if (!$beta -and ($branch -eq "beta")) {
ExitWithError "Current branch is beta but build calls for stable"
}
if ($beta) {
$configuration = $buildFlavor + "-Beta"
$productName = "VidCoder Beta"
} else {
$configuration = $buildFlavor
$productName = "VidCoder"
}
# Get master version number
$version4Part = $versionShort + ".0.0"
# Publish the files
Publish "installer" "InstallerProfile" $version4part $productName
Publish "portable" "PortableProfile" $version4part $productName
# We need to copy some files from the Worker publish over to the main publish output, because the main publish output doesn't properly set the Worker to self-contained mode
copy ".\VidCoderWorker\bin\publish-portable\VidCoderWorker*" ".\VidCoder\bin\publish-portable"
# Create portable installer
if ($beta) {
$betaNameSection = "-Beta"
} else {
$betaNameSection = ""
}
$binaryNameBase = "VidCoder-$versionShort$betaNameSection"
if ($debugBuild) {
$builtInstallerFolder = "Installer\BuiltInstallers\Test"
} else {
$builtInstallerFolder = "Installer\BuiltInstallers"
}
New-Item -ItemType Directory -Force -Path ".\$builtInstallerFolder"
$portableExeWithoutExtension = ".\$builtInstallerFolder\$binaryNameBase-Portable"
$portableExeWithExtension = $portableExeWithoutExtension + ".exe"
DeleteFileIfExists $portableExeWithExtension
$winRarExe = "c:\Program Files\WinRar\WinRAR.exe"
& $winRarExe a -sfx -z".\Installer\VidCoderRar.conf" -iicon".\VidCoder\VidCoder_icon.ico" -r -ep1 $portableExeWithoutExtension .\VidCoder\bin\publish-portable\** | Out-Null
ExitIfFailed
SignExe $portableExeWithExtension; ExitIfFailed
# Create zip file with binaries
$zipFilePath = ".\Installer\BuiltInstallers\$binaryNameBase.zip"
DeleteFileIfExists $zipFilePath
& $winRarExe a -afzip -ep1 -r $zipFilePath .\VidCoder\bin\publish-installer\
# Build Squirrel installer
Set-Alias Squirrel ($env:USERPROFILE + "\.nuget\packages\clowd.squirrel\2.8.1-pre\tools\Squirrel.exe")
if ($beta) {
$packId = "VidCoder.Beta"
$releaseDirSuffix = "Beta"
} else {
$packId = "VidCoder.Stable"
$releaseDirSuffix = "Stable"
}
$releaseDir = ".\Installer\Releases-$releaseDirSuffix"
Squirrel pack `
--packId $packId `
--packTitle "$productName" `
--packVersion ($versionShort + ".0") `
--packAuthors RandomEngy `
--packDirectory .\VidCoder\bin\publish-installer `
--icon .\Installer\VidCoder_Setup.ico `
--releaseDir $releaseDir `
--splashImage .\Installer\InstallerSplash.png `
--signParams "/f D:\certs\ComodoIndividualCertv2.pfx /p $p /fd SHA256 /tr http://timestamp.digicert.com /td SHA256" `
--framework net6.0.2-x64
ExitIfFailed;
Move-Item -Path ("$releaseDir\" + $packId + "Setup.exe") -Destination ".\Installer\BuiltInstallers\$binaryNameBase.exe" -Force
WriteSuccess
Write-Host