-
Notifications
You must be signed in to change notification settings - Fork 5
165 lines (159 loc) · 8.82 KB
/
create-release.yml
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
name: create-release
on:
push:
branches:
- master
paths-ignore:
- 'docs/**'
- 'README.md'
jobs:
Release:
name: Creating a Release on Github
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download and Extract MPQEditor
run: |
Invoke-WebRequest -Uri "http://www.zezula.net/download/mpqeditor_en.zip" -OutFile "./mpqeditor_en.zip"
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory("./mpqeditor_en.zip", "./mpqeditor")
Copy-Item "./mpqeditor/x64/MPQEditor.exe" -Destination "C:"
- name: Clone the Repo
run: |
& git clone "https://github.com/jamiephan/HeroesOfTheStorm_TryMode2.0.git" "C:/repo"
- name: Build the trymode20.stormmap
run: |
& echo "new C:/trymode20.stormmap" >> C:/script.mpqscript
& echo "add C:/trymode20.stormmap C:/repo/(10)trymemode.stormmap /r" >> C:/script.mpqscript
& echo close >> C:/script.mpqscript
& echo x >> C:/script.mpqscript
& "C:/MPQEditor.exe" /console "C:/script.mpqscript"
- name: Build Multiple Maps
run: |
git clone "https://github.com/jamiephan/HeroesOfTheStorm_S2MA.git" "C:/map_repo"
git clone "https://github.com/jamiephan/HeroesOfTheStorm_AIMaps.git" "C:/map_AI_repo"
Get-ChildItem C:/map_AI_repo/maps/5v5/ | Copy-Item -Destination { "C:/map_repo/maps/" + $_.Name.Replace(".stormmap", " AI.stormmap") }
Push-Location "C:/map_repo"
function PrepareInsertIntoMPQ($path, $mpq) {
if (Test-Path "_add_.mpqscript") {
Add-Content "_add_.mpqscript" "add `"$mpq`" `"$path`""
}
else {
Write-Output "add `"$mpq`" `"$path`"" | Set-Content "_add_.mpqscript" | Out-Null
}
}
function ExecuteInsertIntoMPQ() {
# .\MPQEditor.exe /console "_add_.mpqscript" | Out-Null
Start-Process -WindowStyle Hidden ".\MPQEditor.exe" -Wait -ArgumentList "/console `"_add_.mpqscript`""
Remove-Item "_add_.mpqscript" -Force -Confirm:$false
}
function CheckMPQFileExist($path, $mpq) {
New-Item -Confirm:$false -Force -ItemType Directory "./_checktemp_" | Out-Null
Start-Process -WindowStyle Hidden ".\MPQEditor.exe" -Wait -ArgumentList "extract `"$mpq`" `"$path`" `"./_checktemp_`""
# .\MPQEditor.exe extract "$mpq" "$path" "./_checktemp_" | Out-Null
$result = Test-Path "./_checktemp_/*"
Remove-Item -Confirm:$false -Force -Recurse "./_checktemp_"
return $result
}
function GetMPQFileContent($path, $mpq) {
New-Item -Confirm:$false -Force -ItemType Directory "./_gettemp_" | Out-Null
Start-Process -WindowStyle Hidden ".\MPQEditor.exe" -Wait -ArgumentList "extract `"$mpq`" `"$path`" `"./_gettemp_`""
# .\MPQEditor.exe extract "$mpq" "$path" "./_checktemp_" | Out-Null
$result = Get-ChildItem "./_gettemp_" -Force -Recurse -File | Select-Object -First 1 | Get-Content
Remove-Item -Confirm:$false -Force -Recurse "./_gettemp_"
return $result
}
# Copy required files
Copy-Item "C:\repo\(10)trymemode.stormmap\base.stormassets" . -Recurse -Force
Copy-Item "C:\repo\(10)trymemode.stormmap\base.stormdata" . -Recurse -Force
# Remove extra files from try mode
Remove-Item "./base.stormdata/ai" -Recurse -Force -Confirm:$false
Remove-Item "./base.stormdata/cutscenes" -Recurse -Force -Confirm:$false
Remove-Item "./base.stormdata/gamedata" -Recurse -Force -Confirm:$false
Remove-Item "./base.stormdata/ui" -Recurse -Force -Confirm:$false
# Replacing the MapScript.galaxy File
Get-ChildItem "./maps" -Filter "*.stormmap" | Foreach-Object {
$mapName = "$($_.BaseName).stormmap"
$mapPath = "maps/$mapName"
Write-Output "Patching MapScript.galaxy in $mapName"
Start-Process -WindowStyle Hidden ".\MPQEditor.exe" -Wait -ArgumentList "extract `"$mapPath`" MapScript.galaxy"
(Get-Content .\MapScript.galaxy) -replace 'include "TriggerLibs/SupportLib"', "$&`ninclude `"LibTryMeMode`"" | Set-Content .\MapScript.galaxy
(Get-Content .\MapScript.galaxy) -replace "libSprt_InitLib\(\);$", "$&`n libTRYM_InitLib();" | Set-Content .\MapScript.galaxy
(Get-Content .\MapScript.galaxy) -replace "libStEx_InitLib\(\);$", "//libStEx_InitLib();" | Set-Content .\MapScript.galaxy
PrepareInsertIntoMPQ "MapScript.galaxy" $mapPath
ExecuteInsertIntoMPQ
Remove-Item "./MapScript.galaxy" -Force -Confirm:$false
}
# Generate Insert Script and apply to the maps
Write-Output "Generating Insert Script for MPQ"
Start-Sleep -s 5
Get-ChildItem "./base.storm*" -Recurse | Where-Object { ! $_.PSIsContainer } | ForEach-Object {
$filePathPS = $_ | Resolve-Path -Relative
$filePath = $filePathPS -replace '\.\\', ''
# Special Case
if ($filePath -ieq "base.stormdata\includes.xml") {
return
}
if ($filePath -ieq "base.stormdata\gamedata.xml") {
return
}
Get-ChildItem "./maps" -Filter "*.stormmap" | Foreach-Object {
$mapName = "$($_.BaseName).stormmap"
$mapPath = "maps/$mapName"
PrepareInsertIntoMPQ $filePath $mapPath
}
}
ExecuteInsertIntoMPQ
Write-Output "Handing Special Case for Gamedata.xml and Includes.xml"
# Special case for GameData.xml and Include.xml
$originalIncludeXML = Get-Content "./base.stormdata/includes.xml"
$originalGamedataXML = Get-Content "./base.stormdata/gamedata.xml"
$IncludeXMLInnerXML = [regex]::Match($originalIncludeXML, '<Includes id="Mods/HeroesData.StormMod">(.*)</Includes>').Groups[1].Value
$GameDataXMLInnerXML = [regex]::Match($originalGamedataXML, '<Includes>(.*)</Includes>').Groups[1].Value
Get-ChildItem "./maps" -Filter "*.stormmap" | Foreach-Object {
$mapName = "$($_.BaseName).stormmap"
$mapPath = "maps/$mapName"
if(CheckMPQFileExist "base.stormdata\includes.xml" $mapPath ) {
Write-Output "$mapPath has includes"
$newIncludeXML = $(GetMPQFileContent "base.stormdata\includes.xml" $mapPath) -replace '</Includes>',"$IncludeXMLInnerXML</Includes>"
Set-Content -Path "./base.stormdata\includes.xml" -Value $newIncludeXML
PrepareInsertIntoMPQ "base.stormdata\includes.xml" $mapPath
} else {
Set-Content -Path "./base.stormdata\includes.xml" -Value $originalIncludeXML
PrepareInsertIntoMPQ "base.stormdata\includes.xml" $mapPath
}
if(CheckMPQFileExist "base.stormdata\gamedata.xml" $mapPath ) {
Write-Output "$mapPath has gamedata"
$newGameDataXML = $(GetMPQFileContent "base.stormdata\gamedata.xml" $mapPath) -replace '</Includes>',"$GameDataXMLInnerXML</Includes>"
Set-Content -Path "base.stormdata\gamedata.xml" -Value $newGameDataXML
PrepareInsertIntoMPQ "base.stormdata\gamedata.xml" $mapPath
} else {
Set-Content -Path "./base.stormdata\gamedata.xml" -Value $originalGamedataXML
PrepareInsertIntoMPQ "base.stormdata\gamedata.xml" $mapPath
}
ExecuteInsertIntoMPQ
Set-Content -Path "./base.stormdata\includes.xml" -Value $originalIncludeXML
Set-Content -Path "./base.stormdata\gamedata.xml" -Value $originalGamedataXML
}
Write-Output "All Maps Patching Completed"
Pop-Location
New-Item -Confirm:$false -Force -ItemType Directory "C:/maps" | Out-Null
Copy-Item "C:/map_repo/maps/*" "C:/maps"
Copy-Item "C:/trymode20.stormmap" "C:/maps"
Start-Sleep -s 5
- name: Create Github Release
uses: softprops/action-gh-release@v1
with:
tag_name: release-${{ github.event.head_commit.id }}
name: ${{ github.event.head_commit.message }}
body: |
Commit Message: `${{ github.event.head_commit.message }}`
Built time: `${{ github.event.head_commit.timestamp }}`
Maps with the name `.AI` indicates the map will be filled with AI players.
For instructions on how to run the maps below, Please refer to [installation guide](https://jamiephan.github.io/HeroesOfTheStorm_TryMode2.0/install.html).
draft: false
prerelease: false
files: "C:/maps/*"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}