-
-
Notifications
You must be signed in to change notification settings - Fork 204
/
do-release.ps1
101 lines (76 loc) · 3.27 KB
/
do-release.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
param (
[switch]$help,
[string]$version
)
$ErrorActionPreference = "Stop"
if ($help) {
Write-Host "Usage: do-release.ps1 [-help] [-version <version>]"
Write-Host " -help: Display this help message"
Write-Host " -version: The version to build"
exit
}
if (-not $version) {
Write-Host "You must specify a version to build"
exit
}
Write-Host "===CPP2IL RELEASE SCRIPT==="
$ProjectRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$MainCommandLineAppDir = Join-Path $ProjectRoot "Cpp2IL"
$ArtifactsDir = Join-Path $ProjectRoot "artifacts"
$BuildDir = Join-Path $MainCommandLineAppDir "bin"
$ReleaseBuildDir = Join-Path $BuildDir "release"
Write-Host "Cleaning up old build and artifacts directories"
if(Test-Path $ReleaseBuildDir)
{
Remove-Item -Recurse -Force $ReleaseBuildDir
}
if(Test-Path $ArtifactsDir)
{
Remove-Item -Recurse -Force $ArtifactsDir
}
cd $MainCommandLineAppDir
$baseVersion = (Select-Xml -XPath "//Project/PropertyGroup/VersionPrefix" -Path ".\Cpp2IL.csproj").Node.InnerText
$fullVersionString = "$baseVersion-$version"
Write-Host "Building Cpp2IL release version $fullVersionString"
Write-Host " Building Cpp2IL - Windows, Standalone .NET"
$null = dotnet publish -c Release -f "net9.0" -r "win-x64" /p:VersionSuffix=$version /p:PublishSingleFile=true --self-contained
Write-Host " Building Cpp2IL - Linux, Standalone .NET"
$null = dotnet publish -c Release -f "net9.0" -r "linux-x64" /p:VersionSuffix=$version /p:PublishSingleFile=true --self-contained
Write-Host " Building Cpp2IL - MacOS, Standalone .NET"
$null = dotnet publish -c Release -f "net9.0" -r "osx-x64" /p:VersionSuffix=$version /p:PublishSingleFile=true --self-contained
Write-Host " Building Cpp2IL - Windows, .NET Framework"
$null = dotnet publish -c Release -f "net472" -r "win-x64" /p:VersionSuffix=$version
function CopyAndRename($rid, $platform, $releasePlatformString, $extension)
{
$ridDir = Join-Path $ReleaseBuildDir $rid
$platformDir = Join-Path $ridDir $platform
$publishDir = Join-Path $platformDir "publish"
$file = Join-Path $publishDir "Cpp2IL$extension"
if(Test-Path $file)
{
# Cpp2IL-2022.1.0.pre-release-17-Windows.exe
$destFileName = "Cpp2IL-$fullVersionString-$releasePlatformString$extension"
Write-Host " Copying $destFileName..."
$newFile = Join-Path $ArtifactsDir $destFileName
Copy-Item $file $newFile
}
}
function ZipAndRename($rid, $platform, $releasePlatformString, $extension)
{
$ridDir = Join-Path $ReleaseBuildDir $rid
$platformDir = Join-Path $ridDir $platform
$publishDir = Join-Path $platformDir "publish"
# Zip all files in the publish directory
$zipFileName = "Cpp2IL-$fullVersionString-$releasePlatformString.zip"
Write-Host " Zipping $zipFileName..."
$zipFile = Join-Path $ArtifactsDir $zipFileName
$null = Compress-Archive -Path $publishDir\* -DestinationPath $zipFile
}
Write-Host "Moving files to artifacts directory"
$null = New-Item -ItemType Directory -Force -Path $ArtifactsDir
CopyAndRename "net9.0" "win-x64" "Windows" ".exe"
CopyAndRename "net9.0" "linux-x64" "Linux" ""
CopyAndRename "net9.0" "osx-x64" "OSX" ""
ZipAndRename "net472" "win-x64" "Windows-Netframework472" ".exe"
Write-Host "Done!"
Set-Location $ProjectRoot