-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrelease.ps1
87 lines (69 loc) · 2.17 KB
/
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
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)]
[ValidateSet("windows-2019", "ubuntu-20.04", "macos-11")]
[string]$Runner,
[Parameter(Mandatory=$true)]
[string]$Version
)
$ErrorActionPreference = "Stop"
function Write-Output
{
param ( [string]$name, [string]$value )
Write-Host ("::set-output name=$name::$value")
}
function Get-Sem-Version
{
param ( [string]$version )
$index = $version.LastIndexOf("-")
if ($index -eq -1) {
return $version
}
$numbers = $version.Remove($index).Split("-")
$numbers = @($numbers | ForEach-Object {
if ($_ -eq "2020") {
"20"
} else {
$_
}
})
return [string]::Join(".", $numbers)
}
New-Item -Path . -Name "output" -ItemType "directory" -Force
switch($Runner)
{
ubuntu-20.04
{
cargo install cargo-deb
cargo deb --manifest-path=cli/Cargo.toml --output=output
$artifactName = ls output
$finalName = "EventStoreDB.Cloud.CLI-$Version-1.${Runner}_amd64.deb"
Push-Location "output"
Move-Item -Path $artifactName $finalName
Write-Output "artifact_name" $finalName
Write-Output "content_type" "application/vnd.debian.binary-package"
Pop-Location
}
windows-2019
{
cargo build --bin esc --release
Move-Item -Path (Join-Path "target" (Join-Path "release" "esc.exe")) (Join-Path "output" "esc.exe")
Push-Location output
$artifactName = "EventStoreDB.Cloud.CLI-Windows-x64-$Version.zip"
Write-Output "artifact_name" $artifactName
Write-Output "content_type" "application/zip"
Compress-Archive -Path "esc.exe" -DestinationPath $artifactName
Pop-Location
}
macos-11
{
cargo build --bin esc --release
$packageName = "EventStoreDB.Cloud.CLI-OSX-$Version.pkg"
$semVer = Get-Sem-Version $Version
New-Item -Path . -Name "macbuild" -ItemType "directory"
Copy-Item -Path "target/release/esc" "macbuild"
pkgbuild --root macbuild --identifier com.eventstore.cloud.cli --ownership recommended --version $semVer --install-location /usr/local/bin "output/$packageName"
Write-Output "artifact_name" $packageName
Write-Output "content_type" "application/octet-stream"
}
}