-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.ps1
49 lines (39 loc) · 2.47 KB
/
build.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
$addonVersionLineCata = Select-String -Pattern "## Version" -Path ".\AutoBiographer_Cata.toc"
$addonVersionCata = $addonVersionLineCata.ToString().Substring($addonVersionLineCata.ToString().LastIndexOf(" ") + 1)
$addonVersionLineTbc = Select-String -Pattern "## Version" -Path ".\AutoBiographer_TBC.toc"
$addonVersionTbc = $addonVersionLineTbc.ToString().Substring($addonVersionLineTbc.ToString().LastIndexOf(" ") + 1)
$addonVersionLineVanilla = Select-String -Pattern "## Version" -Path ".\AutoBiographer_Vanilla.toc"
$addonVersionVanilla = $addonVersionLineVanilla.ToString().Substring($addonVersionLineVanilla.ToString().LastIndexOf(" ") + 1)
$addonVersionLineWotlk = Select-String -Pattern "## Version" -Path ".\AutoBiographer_Wrath.toc"
$addonVersionWotlk = $addonVersionLineWotlk.ToString().Substring($addonVersionLineWotlk.ToString().LastIndexOf(" ") + 1)
if ($addonVersionVanilla -ne $addonVersionTbc -or $addonVersionTbc -ne $addonVersionWotlk -or $addonVersionWotlk -ne $addonVersionCata) {
throw "Versions don't match in TOC files."
}
$outputDirectoryPath = ".\Deploys"
$outputFileName = "AutoBiographer_$addonVersionVanilla"
if ((git branch).IndexOf("* master") -lt 0 -or (git status --porcelain).length -ne 0) {
Write-Host "You are on a development branch or have uncommited changes."
$currentDateTime = Get-Date -Format "yyyy-MM-dd-HH-mm-ss"
$outputFileName = "$outputFileName-dev-$currentDateTime"
}
$outputFilePath = "$outputDirectoryPath\$outputFileName.zip"
if (Test-Path -Path "$outputFilePath") {
throw "Output file with the same name already exists."
}
$tempDirectoryPath = "$outputDirectoryPath\Temp"
$tempSubDirectoryPath = "$tempDirectoryPath\AutoBiographer"
New-Item -Path ".\Deploys\Temp" -Name "AutoBiographer" -ItemType "directory" | Out-Null
Copy-Item ".\*" -Destination "$tempSubDirectoryPath" -Include *.lua,*.md,*.toc,*.xml
Copy-Item ".\Classes" -Destination "$tempSubDirectoryPath" -Recurse
Copy-Item ".\Data" -Destination "$tempSubDirectoryPath" -Recurse
Copy-Item ".\Icons" -Destination "$tempSubDirectoryPath" -Recurse
Copy-Item ".\Libs" -Destination "$tempSubDirectoryPath" -Recurse
Copy-Item ".\UI" -Destination "$tempSubDirectoryPath" -Recurse
$7zipPath = "$env:ProgramFiles\7-Zip\7z.exe"
if (-not (Test-Path -Path $7zipPath -PathType Leaf)) {
throw "7 zip file '$7zipPath' not found"
}
Set-Alias 7zip $7zipPath
7zip a $outputFilePath $tempSubDirectoryPath
Remove-Item $tempDirectoryPath -Recurse
Write-Host "Successfully created deployment package: '$outputFilePath'"