-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild_launcher.ps1
65 lines (52 loc) · 1.53 KB
/
build_launcher.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
Param(
[Parameter(Mandatory=$false)]
[Switch] $Overwrite,
[Parameter(Mandatory=$false)]
[string] $Branch
)
$ErrorActionPreference = "Stop"
$SOURCE_DIR = "./Launcher"
$SOURCE_REPO = "https://github.com/sp-tarkov/launcher.git"
$BuildOnCommit = $Commit.Length -gt 0
if (Test-Path -Path $SOURCE_DIR) {
if ($Overwrite -or (Read-Host "$SOURCE_DIR exists, delete? [y/n]") -eq 'y') {
Write-Output "$SOURCE_DIR exists, removing"
Remove-Item -Recurse -Force $SOURCE_DIR
}
else
{
Exit 1
}
}
Write-Output "clone repo"
if ( $Branch.Length -gt 0 )
{
Write-Output "Cloning branch $Branch"
git clone --depth 1 -b $Branch $SOURCE_REPO $SOURCE_DIR
}
else
{
Write-Output "Branch not given, using default branch"
git clone --depth 1 $SOURCE_REPO $SOURCE_DIR
}
Set-Location $SOURCE_DIR
if ($BuildOnCommit) {
Write-Output "Checking out the commit $Commit"
git fetch --depth=1 $SOURCE_REPO $Commit
git checkout $Commit
if ($LASTEXITCODE -ne 0) {
throw ("Commit $Commit checkout failed. It doesn't exist? git exit code $LASTEXITCODE")
}
}
$Head = git rev-parse --short HEAD
$CTime = git log -1 --format="%at"
$CTimeS = (([System.DateTimeOffset]::FromUnixTimeSeconds($CTime)).DateTime).ToString("yyyyMMddHHmmss")
Write-Output "Current HEAD is at $Head in $Branch committed at $CTimeS"
Write-Output "build"
Set-Location ./project
dotnet restore
dotnet build SPT.Build
if ($LASTEXITCODE -ne 0) {
throw ("dotnet build failed, exit code $LASTEXITCODE")
}
Get-ChildItem ./Build