-
Notifications
You must be signed in to change notification settings - Fork 8
/
bskycli_publish.ps1
74 lines (65 loc) · 1.73 KB
/
bskycli_publish.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
param(
[Parameter()]
[ValidateSet('clean', 'gitversion', 'bskycli_windows', 'all')]
[string]$Target = 'all'
)
# Configuration
$ROOT = $PSScriptRoot
$BSKYCLI_ROOT = Join-Path $ROOT "apps\bskycli"
$BSKYCLI_PROJECT = Join-Path $BSKYCLI_ROOT "bskycli.csproj"
$BUILD_TYPE = "Release"
$ARTIFACTS_DIR = Join-Path $ROOT "artifacts"
# Helper function to create directory if it doesn't exist
function EnsureDirectory {
param([string]$path)
if (-not (Test-Path $path)) {
New-Item -ItemType Directory -Path $path -Force | Out-Null
}
}
# Helper function to remove directory if it exists
function RemoveDirectory {
param([string]$path)
if (Test-Path $path) {
Remove-Item -Path $path -Recurse -Force
}
}
# Install GitVersion.Tool
function Install-GitVersion {
Write-Host "Installing GitVersion.Tool..."
dotnet tool install --global GitVersion.Tool
dotnet-gitversion /output buildserver
}
# Build for Windows (x64)
function Build-WindowsX64 {
Write-Host "Building for Windows x64..."
# Clean previous build
RemoveDirectory "$ARTIFACTS_DIR\win-x64"
# Build and publish
dotnet build $BSKYCLI_PROJECT -c $BUILD_TYPE -r win-x64
dotnet publish $BSKYCLI_PROJECT -c $BUILD_TYPE -r win-x64 -o "$ARTIFACTS_DIR\win-x64"
}
# Clean build artifacts
function Clean-Build {
Write-Host "Cleaning build artifacts..."
RemoveDirectory $OUTPUT_DIR
RemoveDirectory $ARTIFACTS_DIR
}
# Main execution
switch ($Target) {
'clean' {
Clean-Build
}
'gitversion' {
Install-GitVersion
}
'bskycli_windows' {
Build-WindowsX64
}
'all' {
Build-WindowsX64
}
default {
Write-Host "Invalid target specified"
exit 1
}
}