-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
build-host-release.ps1
59 lines (45 loc) · 1.72 KB
/
build-host-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
#!pwsh
<#
OpenSSL is already installed on windows-latest virtual environment.
If you need OpenSSL, consider install it by:
choco install openssl
#>
param(
[Parameter(HelpMessage = "extra features")]
[Alias('f')]
[string]$Features
)
$ErrorActionPreference = "Stop"
$TargetTriple = (rustc -Vv | Select-String -Pattern "host: (.*)" | ForEach-Object { $_.Matches.Value }).split()[-1]
Write-Host "Started building release for ${TargetTriple} ..."
if ([string]::IsNullOrEmpty($Features)) {
cargo build --release
}
else {
cargo build --release --features "${Features}"
}
if (!$?) {
exit $LASTEXITCODE
}
$Version = (Select-String -Pattern '^version *= *"([^"]*)"$' -Path "${PSScriptRoot}\..\Cargo.toml" | ForEach-Object { $_.Matches.Value }).split()[-1]
$Version = $Version -replace '"'
$PackageReleasePath = "${PSScriptRoot}\release"
$PackageName = "shadowsocks-v${Version}.${TargetTriple}.zip"
$PackagePath = "${PackageReleasePath}\${PackageName}"
Write-Host $Version
Write-Host $PackageReleasePath
Write-Host $PackageName
Write-Host $PackagePath
Push-Location "${PSScriptRoot}\..\target\release"
$ProgressPreference = "SilentlyContinue"
New-Item "${PackageReleasePath}" -ItemType Directory -ErrorAction SilentlyContinue
$CompressParam = @{
LiteralPath = "sslocal.exe", "ssserver.exe", "ssurl.exe", "ssmanager.exe"
DestinationPath = "${PackagePath}"
}
Compress-Archive @CompressParam
Write-Host "Created release packet ${PackagePath}"
$PackageChecksumPath = "${PackagePath}.sha256"
$PackageHash = (Get-FileHash -Path "${PackagePath}" -Algorithm SHA256).Hash
"${PackageHash} ${PackageName}" | Out-File -FilePath "${PackageChecksumPath}"
Write-Host "Created release packet checksum ${PackageChecksumPath}"