forked from eclipse-aaspe/server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PackageRelease.ps1
99 lines (78 loc) · 2.39 KB
/
PackageRelease.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
param(
[Parameter(HelpMessage = "Version to be packaged", Mandatory = $true)]
[string]
$version
)
<#
.SYNOPSIS
This script packages files to be released.
#>
$ErrorActionPreference = "Stop"
Import-Module (Join-Path $PSScriptRoot Common.psm1) -Function `
GetArtefactsDir
function PackageRelease($outputDir)
{
$baseBuildDir = Join-Path $( GetArtefactsDir ) "build" `
| Join-Path -ChildPath "Release"
$targets = $(
"AasxServerBlazor"
"AasxServerCore"
"AasxServerWindows"
)
New-Item -ItemType Directory -Force -Path $outputDir|Out-Null
foreach ($target in $targets)
{
$buildDir = Join-Path $baseBuildDir $target
if (!(Test-Path $buildDir))
{
throw ("The build directory with the release does " +
"not exist: $buildDir; did you build the targets " +
"with BuildForRelease.ps1?")
}
$archPath = Join-Path $outputDir "$target.zip"
Write-Host "Compressing to: $archPath"
Compress-Archive `
-Path $buildDir `
-DestinationPath $archPath
}
# Do not copy the source code in the releases.
# The source code will be distributed automatically through Github releases.
Write-Host "Done packaging the release."
}
function Main
{
if ($version -eq "")
{
throw "Unexpected empty version"
}
$versionRe = [Regex]::new(
'^[0-9]{4}-(0[1-9]|10|11|12)-(0[1-9]|1[0-9]|2[0-9]|3[0-1])' +
'(\.(alpha|beta))?$')
$latestVersionRe = [Regex]::new('^LATEST(\.(alpha|beta))?$')
if ((!$latestVersionRe.IsMatch($version)) -and
(!$versionRe.IsMatch($version)))
{
throw ("Unexpected version; " +
"expected either year-month-day (*e.g.*, 2019-10-23) " +
"followed by an optional maturity tag " +
"(*e.g.*, 2019-10-23.alpha) " +
"or LATEST, but got: $version")
}
$outputDir = Join-Path $( GetArtefactsDir ) "release" `
| Join-Path -ChildPath $version
if (Test-Path $outputDir)
{
Write-Host ("Removing previous release so that " +
"the new release is packaged clean: $outputDir")
Remove-Item -Recurse -Force $outputDir
}
PackageRelease -outputDir $outputDir
}
$previousLocation = Get-Location; try
{
Main
}
finally
{
Set-Location $previousLocation
}