-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
buildQMOD.ps1
66 lines (64 loc) · 2.64 KB
/
buildQMOD.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
# Builds a .qmod file for loading with QuestPatcher or BMBF
if ($args.Count -eq 0) {
$ModID = "ServerBrowser"
$BSHook = "2_3_0"
$VERSION = "0.1.0"
$BS_Version = "1.17.1"
$new_VERSION = Read-Host -Prompt "Input desired mod version (leave empty for default: '$VERSION')"
$bs_hook_version = $BSHook.Replace("_", ".")
$new_BSHook = Read-Host -Prompt "Input current bs-hook version (leave empty for default: '$bs_hook_version')"
if ($new_VERSION -ne "") {
$VERSION = $new_VERSION
}
if ($new_BSHook -ne "") {
$BSHook = $new_BSHook.Replace(".", "_")
}
Write-Host "Compiling Mod"
& $PSScriptRoot/build.ps1 -Version $VERSION
& Copy-Item "./obj/local/arm64-v8a/lib$ModID.so" -Destination "./debug-builds/lib$ModID-$VERSION.so"
}
# TODO: Get the below working with Github Actions variables.
if ($args[0] -eq "--package") {
$ModID = $env:module_id
$BSHook = $env:bs_hook
$VERSION = $env:version
$BS_Version = $env:BSVersion
Write-Host "Github Actions Package started"
}
# Checks if the build was successful
if ($?) {
# Checks if any needed files are missing
if ((Test-Path "./libs/arm64-v8a/libbeatsaber-hook_$BSHook.so", "./libs/arm64-v8a/lib$ModID.so", "./mod.json") -contains $false) {
Write-Host "The following files are missing"
if (!(Test-Path "./libs/arm64-v8a/libbeatsaber-hook_$BSHook.so")) {
Write-Host "./libs/arm64-v8a/libbeatsaber-hook_$BSHook.so"
}
if (!(Test-Path "./libs/arm64-v8a/lib$ModID.so")) {
Write-Host "./libs/arm64-v8a/lib$ModID.so"
}
if (!(Test-Path ".\mod.json")) {
Write-Host ".\mod.json"
}
Write-Host "Task Failed"
exit 1;
}
else {
# If we have all files needed, go ahead and packe into qmod
if ($args.Count -eq 0 -or $args[0] -eq "--package") {
Write-Host "Upating mod.json"
$json = Get-Content $PSScriptRoot/mod.json -raw | ConvertFrom-Json
$json.packageVersion = "$BS_Version"
$json.version="$VERSION"
$json.libraryFiles=@("libbeatsaber-hook_$BSHook.so")
$json | ConvertTo-Json -depth 32| Set-Content $PSScriptRoot/mod.json
Write-Host "Packaging QMod with ModID: $ModID Version: $VERSION and BS-Hook version: $BSHook"
$packagename = $ModID + "_v" + $VERSION
Compress-Archive -Path "./libs/arm64-v8a/lib$ModID.so", "./libs/arm64-v8a/libbeatsaber-hook_$BSHook.so", ".\mod.json" -DestinationPath "./Temp$packagename.zip" -Update
Move-Item "./Temp$packagename.zip" "./$packagename.qmod" -Force
}
Write-Host "Task Completed"
}
}
else {
Write-Host "Build failed, see output"
}