-
Notifications
You must be signed in to change notification settings - Fork 1
223 lines (192 loc) · 8.46 KB
/
publish.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
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
name: Publish
on:
push:
paths:
- '.github/workflows/publish.yml'
- 'src/Bannerlord.LauncherEx/**.*'
- 'src/Bannerlord.BLSE/**.*'
- 'src/Bannerlord.BLSE.Shared/**.*'
- 'src/Bannerlord.BLSE.Loaders.Standalone/**.*'
- 'src/Bannerlord.BLSE.Loaders.Launcher/**.*'
- 'src/Bannerlord.BLSE.Loaders.LauncherEx/**.*'
workflow_dispatch:
env:
# Disable the .NET logo in the console output.
DOTNET_NOLOGO: true
# Disable the .NET first time experience to skip caching NuGet packages and speed up the build.
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Disable sending .NET CLI telemetry to Microsoft.
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
get-changelog:
name: Get Changelog
runs-on: ubuntu-latest
outputs:
mod_version: ${{ steps.changelog.outputs.mod_version }}
mod_description: ${{ steps.changelog.outputs.mod_description }}
steps:
- uses: actions/checkout@v4
- name: Install and Run ChangelogParser
id: changelog
run: |
dotnet tool install -g Bannerlord.ChangelogParser
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "mod_version=$(bannerlord_changelog_parser latestversion -f "$PWD/changelog.txt")" >> $GITHUB_OUTPUT
echo "mod_description<<$EOF" >> $GITHUB_OUTPUT
echo "$(bannerlord_changelog_parser fulldescription -f "$PWD/changelog.txt")" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
shell: bash
build:
name: Build ${{matrix.project}} (${{matrix.configuration}})
runs-on: ubuntu-latest
strategy:
matrix:
project: [ 'Bannerlord.BLSE.Loaders.Standalone', 'Bannerlord.BLSE.Loaders.Launcher', 'Bannerlord.BLSE.Loaders.LauncherEx', 'Bannerlord.BLSE.Shared' ]
configuration: [ 'Win64_Shipping_Client', 'Gaming.Desktop.x64_Shipping_Client' ]
steps:
- uses: actions/checkout@v4
- name: Setup
uses: butr/actions-common-setup@v2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
- name: ${{matrix.project}} (${{matrix.configuration}})
run: |
mkdir bannerlord;
dotnet build src/${{matrix.project}}/${{matrix.project}}.csproj --configuration Release -p:GameConfiguration="${{matrix.configuration}}" -p:GameFolder="$PWD/bannerlord" -p:BuildShared="false" /nowarn:MSB4011;
env:
BANNERLORD_BUTR_COMPATIBILITY_SCORE_URL: ${{ secrets.BANNERLORD_BUTR_COMPATIBILITY_SCORE_URL }}
shell: pwsh
- name: Upload Bannerlord folder
uses: actions/upload-artifact@v4
with:
name: bannerlord-tmp-${{matrix.project}}-${{matrix.configuration}}
path: ./bannerlord/
gpu-hint:
name: Add GPU Hints
needs: [build]
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup
uses: butr/actions-common-setup@v2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
- name: Download Bannerlord Temp artifact Pattern
uses: actions/download-artifact@v4
with:
pattern: bannerlord-tmp-*
merge-multiple: true
path: ./bannerlord
continue-on-error: true
- name: Add Dedicated GPU Hint
run: |
echo "Downloading ILAsm";
Invoke-WebRequest https://globalcdn.nuget.org/packages/runtime.win-x64.microsoft.netcore.ilasm.8.0.0.nupkg -OutFile ilasm.nupkg;
Invoke-WebRequest https://globalcdn.nuget.org/packages/runtime.win-x64.microsoft.netcore.ildasm.8.0.0.nupkg -OutFile ildasm.nupkg;
echo "Extracting ILAsm";
Expand-Archive ilasm.nupkg -d tools/ilasm;
Expand-Archive ildasm.nupkg -d tools/ildasm;
#echo "chmod ILAsm";
#chmod +x tools/ilasm/runtimes/linux-x64/native/ilasm;
#chmod +x tools/ildasm/runtimes/linux-x64/native/ildasm;
# So what is happening here?
# We're not able to export global variables from C#
# But ILAsm is able to do it
# So we compile our .exe files from C#
# Then we decompile them with ILDasm
# Then we compile them back to .exe with ILAsm and with the .il file for exporting the global variable
# Then we set the icon back because ILAsm doesn't support setting the icon
$workingDir = "$PWD";
mkdir tmp;
cd build/set-icon;
yarn ci;
cd $workingDir;
$fileNames = Get-ChildItem -Path "bannerlord/" -Recurse -Include *.exe;
foreach ($f in $fileNames) {
cd $workingDir/tmp;
echo $f.FullName;
$runtime = "";
If ($f.FullName.Contains("Win64_Shipping_Client")) {
$runtime = "Win64_Shipping_Client";
}
If ($f.FullName.Contains("Gaming.Desktop.x64_Shipping_Client")) {
$runtime = "Gaming.Desktop.x64_Shipping_Client";
}
$fileDirname = $f.DirectoryName;
$dirname = [System.IO.Path]::GetFileNameWithoutExtension($f.FullName);
New-Item -ItemType Directory -Path $dirname/$runtime -Force
cd $dirname/$runtime;
# Decompile to IL Code
& "$workingDir/tools/ildasm/runtimes/win-x64/native/ildasm.exe" "$f" /OUT=Code.il
#& "$workingDir/tools/ildasm/runtimes/linux-x64/native/ildasm" "$f" -OUT="Code.il"
Copy-Item -Path $workingDir/build/ForceDedicatedGraphicCard.il -Destination ForceDedicatedGraphicCard.il;
# Recompile to .exe
& "$workingDir/tools/ilasm/runtimes/win-x64/native/ilasm.exe" -QUIET -NOLOGO -OPTIMIZE -EXE /X64 -OUTPUT="$dirname.exe" Code.il ForceDedicatedGraphicCard.il
#& "$workingDir/tools/ilasm/runtimes/linux-x64/native/ilasm" -QUIET -NOLOGO -OPTIMIZE -EXE -X64 -OUTPUT="$dirname.exe" Code.il ForceDedicatedGraphicCard.il
# Set Icon
cd $workingDir/build/set-icon;
node index.js "$workingDir/tmp/$dirname/$runtime/$dirname.exe" "$workingDir/resources/BLSE_SMALL.ico";
Copy-Item -Path "$workingDir/tmp/$dirname/$runtime/$dirname.exe" -Destination "$fileDirname/$dirname.exe" -force
}
cd $workingDir;
rmdir tmp -Recurse -Force;
shell: pwsh
- name: Upload Bannerlord folder
uses: actions/upload-artifact@v4
with:
name: bannerlord
path: ./bannerlord/
###########################
# NEXUSMODS #
###########################
publish-on-nexusmods:
if: github.ref == 'refs/heads/master'
needs: [get-changelog, build, gpu-hint]
uses: BUTR/workflows/.github/workflows/release-nexusmods.yml@master
with:
nexusmods_game_id: mountandblade2bannerlord
nexusmods_mod_id: 1
mod_filename: 'Bannerlord Software Extender (BLSE)'
mod_version: ${{ needs.get-changelog.outputs.mod_version }}
mod_description: ${{ needs.get-changelog.outputs.mod_description }}
artifact_name: bannerlord
secrets:
NEXUSMODS_APIKEY: ${{ secrets.ARAGAS_NEXUSMODS_API_KEY }}
NEXUSMODS_COOKIES: ${{ secrets.ARAGAS_NEXUSMODS_COOKIE_SID_DEVELOP }}
###########################
# GITHUB #
###########################
publish-on-github:
if: github.ref == 'refs/heads/master'
needs: [get-changelog, build, gpu-hint]
uses: BUTR/workflows/.github/workflows/release-github.yml@master
with:
mod_id: Bannerlord.BLSE
mod_version: ${{ needs.get-changelog.outputs.mod_version }}
mod_description: ${{ needs.get-changelog.outputs.mod_description }}
artifact_name: bannerlord
###########################
# STEAM #
###########################
publish-on-steam:
if: false && github.ref == 'refs/heads/master'
needs: [get-changelog, build, gpu-hint]
runs-on: ubuntu-latest
steps:
- name: Download Module artifact
uses: actions/download-artifact@v4
with:
name: bannerlord
path: ./artifact
- uses: game-ci/steam-deploy@v3
with:
username: ${{ secrets.STEAM_USERNAME }}
password: ${{ secrets.STEAM_PASSWORD }}
configVdf: ${{ secrets.STEAM_CONFIG_VDF }}
ssfnFileName: ${{ secrets.STEAM_SSFN_FILE_NAME }}
ssfnFileContents: ${{ secrets.STEAM_SSFN_FILE_CONTENTS }}
appId: ${{ secrets.STEAM_APPID }}
buildDescription: ${{ needs.get-changelog.outputs.mod_version }}
rootPath: build
depot1Path: ./artifact
releaseBranch: prerelease