-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathpublish.ps1
236 lines (187 loc) · 10.4 KB
/
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
param($Channel)
if ($Channel -ne "Devel" -And $Channel -ne "Release" -And $Channel -ne "NextVersion") {
Write-Error -Message "Usage: publish.ps1 <Channel>"
Exit 1
}
$GameChannel = $Channel
$EditorChannel = $Channel + "Editor"
$S3Bucket = "nb-stor"
$S3RootPath = "bg3-updater-v3/Channels"
$CloudFrontRootPath = "/Channels"
$CloudFrontRootURL = "https://bg3se-updates.norbyte.dev/Channels"
$CloudFrontDistributionID = "EVZRUV2YONUZF"
$S3ManifestPath = "Manifest.json"
$PublishingRoot = Join-Path "D:\Dev\LS\BG3PublishingRoot" "$Channel"
$SigningKey = Join-Path "D:\Dev\LS\BG3PublishingRoot" "package-signer.key"
$BuildRoot = Join-Path "$PublishingRoot" "Build"
$PDBRoot = Join-Path "$PublishingRoot" "PDB"
$RootPath = (Get-Location).Path
$GameManifestPath = Join-Path $PublishingRoot "GameManifest.json"
$EditorManifestPath = Join-Path $PublishingRoot "EditorManifest.json"
$GameBuildZipPath = Join-Path $BuildRoot "GameLatest.zip"
$GameOfflineBuildZipPath = Join-Path $BuildRoot "GameLatestOffline.zip"
$GameDebugAdapterBuildZipPath = Join-Path $BuildRoot "DebugAdapter.zip"
$EditorBuildZipPath = Join-Path $BuildRoot "EditorLatest.zip"
$GameDllPath = Join-Path $RootPath "x64\Game Release\BG3ScriptExtender.dll"
$EditorDllPath = Join-Path $RootPath "x64\Editor Release\BG3EditorScriptExtender.dll"
$GameBuildDir = Join-Path "$BuildRoot" "TempGameBuild"
$GameOfflineBuildDir = Join-Path "$BuildRoot" "TempGameOfflineBuild"
$GameDebugAdapterBuildDir = Join-Path "$BuildRoot" "TempGameDebugAdapter"
$EditorBuildDir = Join-Path "$BuildRoot" "TempEditorBuild"
$PDBDir = Join-Path "$PDBRoot" "TempPDB"
$EditorMinVersion = "4.57.26.0"
$EditorMaxVersion = "-"
$GameMinVersion = "4.57.26.0"
$GameMaxVersion = "-"
function Build-Extender
{
# Force a build date refresh
(gci BG3Extender/Extender/Shared/Console.cpp).LastWriteTime = Get-Date
(gci BG3Extender/Extender/BuildInfo.h).LastWriteTime = Get-Date
if ($Channel -eq "Release") {
echo "#undef SE_IS_DEVELOPER_BUILD" | Out-File -FilePath BG3Extender/Extender/BuildInfo.h
} else {
echo "#define SE_IS_DEVELOPER_BUILD" | Out-File -FilePath BG3Extender/Extender/BuildInfo.h
}
Write-Output " ===== BUILDING GAME EXTENDER ===== "
msbuild BG3Tools.sln "/p:Configuration=Game Release" /t:Build /m /nologo /verbosity:quiet /consoleloggerparameters:summary
x64\Release\SymbolTableGenerator.exe "x64\Game Release\BG3ScriptExtender.pdb" "BG3Extender\GameHooks\BG3ScriptExtender.symtab"
msbuild BG3Tools.sln "/p:Configuration=Game Release" /t:Build /m /nologo /verbosity:quiet /consoleloggerparameters:summary
# Write-Output " ===== BUILDING EDITOR EXTENDER ===== "
# msbuild BG3Tools.sln "/p:Configuration=Editor Release" /t:Build /m /nologo /verbosity:quiet /consoleloggerparameters:summary
}
function Create-PDBDir
{
Remove-Item $PDBDir -Recurse -ErrorAction SilentlyContinue
New-Item $PDBDir -ItemType "directory"
Copy-Item "x64\Release\CrashReporter.pdb" -Destination $PDBDir\CrashReporter.pdb
Copy-Item "x64\Game Release\BG3ScriptExtender.pdb" -Destination $PDBDir\BG3ScriptExtender.pdb
#Copy-Item "x64\Editor Release\BG3EditorScriptExtender.pdb" -Destination $PDBDir\BG3EditorScriptExtender.pdb
Copy-Item "x64\Release\CrashReporter.exe" -Destination $PDBDir\CrashReporter.exe
Copy-Item "x64\Game Release\BG3ScriptExtender.dll" -Destination $PDBDir\BG3ScriptExtender.dll
#Copy-Item "x64\Editor Release\BG3EditorScriptExtender.dll" -Destination $PDBDir\BG3EditorScriptExtender.dll
Copy-Item External\protobuf\bin\libprotobuf-lite.dll -Destination $PDBDir\libprotobuf-lite.dll
if ($Channel -eq "Devel" -Or $Channel -eq "NextVersion") {
New-Item $PDBDir\DAP -ItemType "directory"
Copy-Item "LuaDebugger\bin\Release\Google.Protobuf.dll" -Destination $PDBDir\DAP\Google.Protobuf.dll
Copy-Item "LuaDebugger\bin\Release\Newtonsoft.Json.dll" -Destination $PDBDir\DAP\Newtonsoft.Json.dll
Copy-Item "LuaDebugger\bin\Release\LuaDebugger.exe" -Destination $PDBDir\DAP\LuaDebugger.exe
Copy-Item "LuaDebugger\bin\Release\LuaDebugger.exe.config" -Destination $PDBDir\DAP\LuaDebugger.exe.config
}
}
function Create-Update-Package ($BuildDir, $ZipPath, $HasEditor, $HasGame)
{
Remove-Item $BuildDir -Recurse -ErrorAction SilentlyContinue
New-Item $BuildDir -ItemType "directory"
git show -s --format="BG3SE Version: Commit %H, %cD" > $BuildDir\Version.txt
Copy-Item "x64\Release\CrashReporter.exe" -Destination $BuildDir\CrashReporter.exe
Copy-Item External\protobuf\bin\libprotobuf-lite.dll -Destination $BuildDir\libprotobuf-lite.dll
if ($HasEditor)
{
Copy-Item "x64\Editor Release\BG3EditorScriptExtender.dll" -Destination $BuildDir\BG3EditorScriptExtender.dll
}
if ($HasGame)
{
Copy-Item "x64\Game Release\BG3ScriptExtender.dll" -Destination $BuildDir\BG3ScriptExtender.dll
}
Remove-Item $ZipPath -ErrorAction SilentlyContinue
Compress-Archive -Path $BuildDir\* -DestinationPath $ZipPath -CompressionLevel Optimal -Force
}
function Create-Offline-Package ($BuildDir, $ZipPath)
{
Remove-Item $BuildDir -Recurse -ErrorAction SilentlyContinue
New-Item $BuildDir -ItemType "directory"
Copy-Item External\protobuf\bin\libprotobuf-lite.dll -Destination $BuildDir\libprotobuf-lite.dll
Copy-Item "x64\Game Release\BG3ScriptExtender.dll" -Destination $BuildDir\DWrite.dll
Remove-Item $ZipPath -ErrorAction SilentlyContinue
Compress-Archive -Path $BuildDir\* -DestinationPath $ZipPath -CompressionLevel Optimal -Force
}
function Create-DebugAdapter-Package ($BuildDir, $ZipPath)
{
Remove-Item $BuildDir -Recurse -ErrorAction SilentlyContinue
New-Item $BuildDir -ItemType "directory"
Copy-Item "LuaDebugger\bin\Release\Google.Protobuf.dll" -Destination $BuildDir\Google.Protobuf.dll
Copy-Item "LuaDebugger\bin\Release\Newtonsoft.Json.dll" -Destination $BuildDir\Newtonsoft.Json.dll
Copy-Item "LuaDebugger\bin\Release\LuaDebugger.exe" -Destination $BuildDir\LuaDebugger.exe
Copy-Item "LuaDebugger\bin\Release\LuaDebugger.exe.config" -Destination $BuildDir\LuaDebugger.exe.config
Remove-Item $ZipPath -ErrorAction SilentlyContinue
Compress-Archive -Path $BuildDir\* -DestinationPath $ZipPath -CompressionLevel Optimal -Force
}
function Archive-Build ($Digest, $ZipPath)
{
Write-Output "Digest: " $Digest
Write-Output "Zip path: " $ZipPath
$ArchivePDBDir = Join-Path "$PDBRoot" "$Digest"
New-Item $ArchivePDBDir -ItemType directory -ErrorAction SilentlyContinue
Copy-Item $PDBDir\* -Destination $ArchivePDBDir
Copy-Item $ZipPath -Destination $BuildRoot\$Digest.zip
}
function Build-Package ($BuildDir, $ZipPath, $DllPath, $Channel, $IsGame, $IsEditor)
{
Create-Update-Package $BuildDir $ZipPath $IsEditor $IsGame
x64\Release\UpdateSigner.exe sign $SigningKey $ZipPath
x64\Release\UpdateSigner.exe verify $ZipPath
if ($IsEditor)
{
x64\Release\UpdateSigner.exe update-manifest "$EditorManifestPath" ScriptExtender "$ZipPath" "$DllPath" $EditorMinVersion $EditorMaxVersion "$CloudFrontRootURL/$Channel/Packages/"
}
if ($IsGame)
{
x64\Release\UpdateSigner.exe update-manifest "$GameManifestPath" ScriptExtender "$ZipPath" "$DllPath" $GameMinVersion $GameMaxVersion "$CloudFrontRootURL/$Channel/Packages/"
}
}
function Publish-Package ($ZipPath, $OfflineZipPath, $DigestPath, $Channel, $ManifestPath)
{
$OfflineDigestPath = $DigestPath.replace('.package', '-offline.zip')
$S3Path = "s3://$S3Bucket/$S3RootPath/$Channel/Packages/$DigestPath"
$OfflineS3Path = "s3://$S3Bucket/$S3RootPath/$Channel/Packages/$OfflineDigestPath"
Write-Output " ==== UPDATER PACKAGE ===== "
Write-Output "S3 path: $S3Path"
Write-Output "CloudFront path: $CloudFrontRootPath/$Channel/Packages/$DigestPath"
Write-Output "URL: $CloudFrontRootURL/$Channel/Packages/$DigestPath"
Write-Output "Offline URL: $CloudFrontRootURL/$Channel/Packages/$OfflineDigestPath"
aws s3 cp $ZipPath "$S3Path"
aws s3api put-object-acl --bucket nb-stor --key "$S3RootPath/$Channel/Packages/$DigestPath" --acl public-read
aws s3 cp $OfflineZipPath "$OfflineS3Path"
aws s3api put-object-acl --bucket nb-stor --key "$S3RootPath/$Channel/Packages/$OfflineDigestPath" --acl public-read
aws s3 cp $ManifestPath "s3://$S3Bucket/$S3RootPath/$Channel/$S3ManifestPath"
aws s3api put-object-acl --bucket nb-stor --key "$S3RootPath/$Channel/$S3ManifestPath" --acl public-read
aws cloudfront create-invalidation --distribution-id $CloudFrontDistributionID --paths "$CloudFrontRootPath/$Channel/$S3ManifestPath" "$CloudFrontRootPath/$Channel/Packages/$DigestPath"
}
function Publish-Latest-Offline-Package ($ZipPath, $Channel)
{
Write-Output " ==== LATEST OFFLINE PACKAGE ===== "
Write-Output "S3 path: s3://$S3Bucket/$S3RootPath/$Channel/ManualInstall.zip"
Write-Output "CloudFront path: $CloudFrontRootPath/$Channel/ManualInstall.zip"
Write-Output "URL: $CloudFrontRootURL/$Channel/ManualInstall.zip"
aws s3 cp $ZipPath "s3://$S3Bucket/$S3RootPath/$Channel/ManualInstall.zip"
aws s3api put-object-acl --bucket nb-stor --key "$S3RootPath/$Channel/ManualInstall.zip" --acl public-read
}
function Publish-DebugAdapter-Package ($ZipPath, $Channel)
{
aws s3 cp $ZipPath "s3://$S3Bucket/$S3RootPath/$Channel/DebugAdapter.zip"
aws s3api put-object-acl --bucket nb-stor --key "$S3RootPath/$Channel/DebugAdapter.zip" --acl public-read
}
Build-Extender
Build-Package $GameBuildDir $GameBuildZipPath $GameDllPath $GameChannel 1 0
Create-Offline-Package $GameOfflineBuildDir $GameOfflineBuildZipPath
Create-DebugAdapter-Package $GameDebugAdapterBuildDir $GameDebugAdapterBuildZipPath
# Build-Package $EditorBuildDir $EditorBuildZipPath $EditorDllPath $EditorChannel 0 1
Create-PDBDir
$GameDigestPath = (x64\Release\UpdateSigner.exe compute-path "$GameBuildZipPath" "$GameDllPath")
# $EditorDigestPath = (x64\Release\UpdateSigner.exe compute-path "$EditorBuildZipPath" "$EditorDllPath")
Archive-Build $GameDigestPath $GameBuildZipPath
# Archive-Build $EditorDigestPath $EditorBuildZipPath
Write-Output "Build completed."
Write-Output "."
Write-Output "*********************************************************************************"
Write-Output ""
Write-Output " ABOUT TO PUBLISH ON CHANNEL $Channel!"
Write-Output ""
Write-Output "*********************************************************************************"
Read-Host
Write-Output " ===== UPLOADING PACKAGES ===== "
Publish-Package $GameBuildZipPath $GameOfflineBuildZipPath $GameDigestPath $GameChannel $GameManifestPath
Publish-Latest-Offline-Package $GameOfflineBuildZipPath $GameChannel
Publish-DebugAdapter-Package $GameDebugAdapterBuildZipPath $GameChannel
# Publish-Package $EditorBuildZipPath $EditorDigestPath $EditorChannel $EditorManifestPath