|
| 1 | +param ( |
| 2 | + [switch]$help, |
| 3 | + [string]$version |
| 4 | +) |
| 5 | + |
| 6 | +$ErrorActionPreference = "Stop" |
| 7 | + |
| 8 | +if ($help) { |
| 9 | + Write-Host "Usage: do-release.ps1 [-help] [-version <version>]" |
| 10 | + Write-Host " -help: Display this help message" |
| 11 | + Write-Host " -version: The version to build" |
| 12 | + exit |
| 13 | +} |
| 14 | + |
| 15 | +if (-not $version) { |
| 16 | + Write-Host "You must specify a version to build" |
| 17 | + exit |
| 18 | +} |
| 19 | + |
| 20 | +Write-Host "===CPP2IL RELEASE SCRIPT===" |
| 21 | + |
| 22 | +$ProjectRoot = Split-Path -Parent $MyInvocation.MyCommand.Path |
| 23 | +$MainCommandLineAppDir = Join-Path $ProjectRoot "Cpp2IL" |
| 24 | +$ArtifactsDir = Join-Path $ProjectRoot "artifacts" |
| 25 | +$BuildDir = Join-Path $MainCommandLineAppDir "bin" |
| 26 | +$ReleaseBuildDir = Join-Path $BuildDir "release" |
| 27 | + |
| 28 | +Write-Host "Cleaning up old build and artifacts directories" |
| 29 | +if(Test-Path $ReleaseBuildDir) |
| 30 | +{ |
| 31 | + Remove-Item -Recurse -Force $ReleaseBuildDir |
| 32 | +} |
| 33 | + |
| 34 | +if(Test-Path $ArtifactsDir) |
| 35 | +{ |
| 36 | + Remove-Item -Recurse -Force $ArtifactsDir |
| 37 | +} |
| 38 | + |
| 39 | +cd $MainCommandLineAppDir |
| 40 | + |
| 41 | +$baseVersion = (Select-Xml -XPath "//Project/PropertyGroup/VersionPrefix" -Path ".\Cpp2IL.csproj").Node.InnerText |
| 42 | +$fullVersionString = "$baseVersion-$version" |
| 43 | +Write-Host "Building Cpp2IL release version $fullVersionString" |
| 44 | + |
| 45 | +Write-Host " Building Cpp2IL - Windows, Standalone .NET" |
| 46 | + |
| 47 | +$null = dotnet publish -c Release -f "net7.0" -r "win-x64" /p:VersionSuffix=$version /p:PublishSingleFile=true --self-contained |
| 48 | + |
| 49 | +Write-Host " Building Cpp2IL - Linux, Standalone .NET" |
| 50 | + |
| 51 | +$null = dotnet publish -c Release -f "net7.0" -r "linux-x64" /p:VersionSuffix=$version /p:PublishSingleFile=true --self-contained |
| 52 | + |
| 53 | +Write-Host " Building Cpp2IL - MacOS, Standalone .NET" |
| 54 | + |
| 55 | +$null = dotnet publish -c Release -f "net7.0" -r "osx-x64" /p:VersionSuffix=$version /p:PublishSingleFile=true --self-contained |
| 56 | + |
| 57 | +Write-Host " Building Cpp2IL - Windows, .NET Framework" |
| 58 | + |
| 59 | +$null = dotnet publish -c Release -f "net472" -r "win-x64" /p:VersionSuffix=$version |
| 60 | + |
| 61 | +function CopyAndRename($rid, $platform, $releasePlatformString, $extension) |
| 62 | +{ |
| 63 | + $ridDir = Join-Path $ReleaseBuildDir $rid |
| 64 | + $platformDir = Join-Path $ridDir $platform |
| 65 | + $publishDir = Join-Path $platformDir "publish" |
| 66 | + $file = Join-Path $publishDir "Cpp2IL$extension" |
| 67 | + |
| 68 | + if(Test-Path $file) |
| 69 | + { |
| 70 | + # Cpp2IL-2022.1.0.pre-release-17-Windows.exe |
| 71 | + $destFileName = "Cpp2IL-$fullVersionString-$releasePlatformString$extension" |
| 72 | + Write-Host " Copying $destFileName..." |
| 73 | + $newFile = Join-Path $ArtifactsDir $destFileName |
| 74 | + Copy-Item $file $newFile |
| 75 | + } |
| 76 | +} |
| 77 | + |
| 78 | +function ZipAndRename($rid, $platform, $releasePlatformString, $extension) |
| 79 | +{ |
| 80 | + $ridDir = Join-Path $ReleaseBuildDir $rid |
| 81 | + $platformDir = Join-Path $ridDir $platform |
| 82 | + $publishDir = Join-Path $platformDir "publish" |
| 83 | + |
| 84 | + # Zip all files in the publish directory |
| 85 | + $zipFileName = "Cpp2IL-$fullVersionString-$releasePlatformString.zip" |
| 86 | + Write-Host " Zipping $zipFileName..." |
| 87 | + $zipFile = Join-Path $ArtifactsDir $zipFileName |
| 88 | + $null = Compress-Archive -Path $publishDir\* -DestinationPath $zipFile |
| 89 | +} |
| 90 | + |
| 91 | +Write-Host "Moving files to artifacts directory" |
| 92 | + |
| 93 | +$null = New-Item -ItemType Directory -Force -Path $ArtifactsDir |
| 94 | + |
| 95 | +CopyAndRename "net7.0" "win-x64" "Windows" ".exe" |
| 96 | +CopyAndRename "net7.0" "linux-x64" "Linux" "" |
| 97 | +CopyAndRename "net7.0" "osx-x64" "OSX" "" |
| 98 | +ZipAndRename "net472" "win-x64" "Windows-Netframework472" ".exe" |
| 99 | + |
| 100 | +Write-Host "Done!" |
| 101 | +Set-Location $ProjectRoot |
0 commit comments