-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
108 lines (95 loc) · 3.97 KB
/
build.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
$doCompile = $true
Write-Output "BUILD ABBWorkItemClone"
Write-Output "======================"
Write-Output "Running from $($MyInvocation.MyCommand.Path)"
Write-Output "Do Build & Test? $doCompile"
Write-Output "INSTALL CHOCO APPS"
Write-Output "------------"
# Install Choco Apps
# Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
$installedStuff = choco list -i
if (($installedStuff -like "*7zip*").Count -eq 0) {
Write-Output "Installing 7zip"
choco install 7zip --confirm --accept-license -y
} else { Write-Output "Detected 7zip"}
if (($installedStuff -like "*gh*").Count -eq 0) {
Write-Output "Installing gh"
choco install gh --confirm --accept-license -y
} else { Write-Output "Detected gh"}
if (($installedStuff -like "*GitVersion.Portable*").Count -eq 0) {
Write-Output "Installing GitVersion"
choco install gitversion.portable --confirm --accept-license -y
} else { Write-Output "Detected GitVersion"}
Write-Output "------------"
# Install DotNetApps
Write-Output "INSTALL DotNetApps APPS"
Write-Output "------------"
$installedDotNetStuff = dotnet tool list -g
if (($installedDotNetStuff -like "*GitVersion.Tool*").Count -eq 0) {
Write-Output "Installing GitVersion.Tool"
choco install 7zip --confirm --accept-license -y
} else { Write-Output "Detected GitVersion.Tool"}
dotnet tool install --global GitVersion.Tool
Write-Output "------------"
Write-Output "REFRESH ENVIRONMENT"
Write-Output "------------"
# Refresh environment
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
# Make `refreshenv` available right away, by defining the $env:ChocolateyInstall
# variable and importing the Chocolatey profile module.
# Note: Using `. $PROFILE` instead *may* work, but isn't guaranteed to.
$env:ChocolateyInstall = Convert-Path "$((Get-Command choco).Path)\..\.."
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
Update-SessionEnvironment
Write-Output "------------"
Write-Output "Detect Version"
Write-Output "--------------"
# Get Version Numbers
$versionInfo = dotnet-gitversion | ConvertFrom-Json
Write-Output "FullSemVer: $($versionInfo.FullSemVer)"
Write-Output "SemVer: $($versionInfo.SemVer)"
Write-Output "PreReleaseTag: $($versionInfo.PreReleaseTag)"
Write-Output "InformationalVersion: $($versionInfo.InformationalVersion)"
Write-Output "--------------"
Write-Output "Complile and Test"
Write-Output "--------------"
if ($doCompile)
{
$dotnetversion = where dotnet | dotnet --version
dotnet restore
dotnet build
dotnet test
} else {
Write-Output "Skipping Compile and Test"
}
Write-Output "--------------"
Write-Output "Zip ABBWorkItemClone"
Write-Output "--------------"
$versionText = "v$($versionInfo.SemVer)";
Write-Output "Version: $versionText"
$ZipName = "ABBWorkItemClone-$versionText.zip"
Write-Output "ZipName: $ZipName"
$ZipFilePath = ".\output\$ZipName"
Write-Output "ZipFilePath: $ZipFilePath"
# Create Zip
if (Get-Item -Path ".\output" -ErrorAction SilentlyContinue) {
Write-Output "Cleanning up output folder"
Remove-Item -Path ".\output\" -Recurse -Force
}
New-Item -Name "output" -ItemType Directory
7z a -tzip $ZipFilePath ".\ABB.WorkItemClone.ConsoleUI\bin\Debug\net8.0\**"
Write-Output "--------------"
# Publish
Write-Output "PUBLISH ABBWorkItemClone"
Write-Output "--------------"
if ($versionInfo.PreReleaseTag -eq "") {
Write-Output "Publishing Release"
gh release create $versionText .\output\$ZipName --generate-notes --generate-notes --discussion-category "General"
} else {
Write-Output "Publishing PreRelease"
gh release create $versionText .\output\$ZipName --generate-notes --generate-notes --prerelease --discussion-category "General"
}
$GitVersion_PreReleaseLabel = "Preview"
If (("Preview", "") -notcontains $GitVersion_PreReleaseLabel) {
return 1
}