-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.ps1
52 lines (43 loc) · 1.81 KB
/
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
$DistDir = "$PSScriptRoot\dist"
$BuildDir = "$DistDir\build"
$ReleaseDir = "$DistDir\release"
$xml = [xml](Get-Content $PSScriptRoot\src\LethalCredit.csproj)
$Version = $xml.Project.PropertyGroup.Version
$ZipFile = "$ReleaseDir\LethalCredit_$Version.zip"
$ReleaseAssetBundleArtifact = "$PSScriptRoot\src\Assets\lethalcreditbundle"
$ReleaseDllArtifact = "$PSScriptRoot\src\bin\Release\netstandard2.1\LethalCredit.dll"
Write-Output "Creating build for LethalCredit v$Version"
# cleanup build directory
Remove-Item $BuildDir -Recurse -Force -ErrorAction SilentlyContinue
# cleanup existing Zip file
Remove-Item $ZipFile -Force -ErrorAction SilentlyContinue
# create directories if necessary
If (-not (Test-Path $BuildDir)) {
New-Item -Type dir $BuildDir | Out-Null
}
If (-not (Test-Path $ReleaseDir)) {
New-Item -Type dir $ReleaseDir | Out-Null
}
# build the mod if needed, this will occur on a Release build in IDE
# dotnet build --configuration Release
# update manifest.json version
$ModManifestFile = "$PSScriptRoot\manifest.json"
$ModManifestTmpFile = "$PSScriptRoot\manifest_tmp.json"
Get-Content $ModManifestFile | jq --arg version "$Version" '.version_number = "$version"' > $ModManifestTmpFile
Copy-Item $ModManifestTmpFile $ModManifestFile
Remove-Item $ModManifestTmpFile
function CopyItemToBuild {
$src = $args[0]
$fileName = [System.IO.Path]::GetFileName("$src")
Copy-Item $src $BuildDir\$fileName
}
# copy required mod files
CopyItemToBuild $PSScriptRoot\assets\icon.png
CopyItemToBuild $PSScriptRoot\manifest.json
CopyItemToBuild $PSScriptRoot\README.md
CopyItemToBuild $PSScriptRoot\CHANGELOG.md
CopyItemToBuild $ReleaseAssetBundleArtifact
CopyItemToBuild $ReleaseDllArtifact
# create the zip in ReleaseDir
Get-ChildItem -Path $BuildDir | Compress-Archive -DestinationPath $ZipFile
Write-Output "Created $ZipFile"