-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPublish.ps1
92 lines (63 loc) · 1.97 KB
/
Publish.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
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
trap
{
"Powershell execution error"
write-output $_
exit 1
}
# Paths
$solutionFilePath = "src/JiraTimers.sln"
$projectPath = "\src\JiraTimers"
$publishProfileName = "Release-Win"
$workingDirectory = Get-Location
$winReleasePath = Join-Path $projectPath "publish-win"
$fullReleasePath = Join-Path $workingDirectory $winReleasePath
$appDllPath = Join-Path $fullReleasePath "JiraTimers.dll"
$chocoPackageFilesPath = ".\chocolatey-package"
$nuspecFilePath = Join-Path $chocoPackageFilesPath "jiratimers.nuspec"
$verificationFilePath = Join-Path $chocoPackageFilesPath "VERIFICATION.txt"
$setupProjectPath = "src/JiraTimers.Setup/JiraTimers.Setup.vdproj"
$devenvPath = "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.com"
# Build process
"1/8: Build windows release..."
dotnet publish $solutionFilePath -p:PublishProfile=$publishProfileName
if ($LastExitCode -ne 0)
{
exit 0
}
"2/8: Retrieve app version"
$version = [Reflection.AssemblyName]::GetAssemblyName($appDllPath).Version.ToString(3)
"3/8: Patch MSI project version..."
((Get-Content -Path $setupProjectPath -Raw) -replace '{version}', $version) | Set-Content -Path $setupProjectPath
if ($LastExitCode -ne 0)
{
exit 0
}
"4/8: Build MSI version..."
& $devenvPath $setupProjectPath /build Release /projectconfig Release
if ($LastExitCode -ne 0)
{
exit 0
}
"5/8: Create zip archive"
$archiveName = "JiraTimers." + $version + ".zip"
$compressPath = $fullReleasePath + "/*"
Compress-Archive -Path $compressPath -DestinationPath $archiveName
if ($LastExitCode -ne 0)
{
exit 0
}
"6/8: Checksum calculation"
$cheksum = (Get-FileHash -Path $archiveName -Algorithm SHA256).Hash
if ($LastExitCode -ne 0)
{
exit 0
}
"7/8 Inject checksum to VERIFICATION.txt"
((Get-Content -Path $verificationFilePath -Raw) -replace '{checksum}', $cheksum) | Set-Content -Path $verificationFilePath
if ($LastExitCode -ne 0)
{
exit 0
}
"8/8: Pack Choco package..."
choco pack $nuspecFilePath --version $version
exit $LastExitCode