-
-
Notifications
You must be signed in to change notification settings - Fork 49
395 lines (336 loc) · 14.3 KB
/
build_application.yml
File metadata and controls
395 lines (336 loc) · 14.3 KB
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
name: Application build
on:
push:
branches: [ develop, release/pre, master ]
paths:
- Application/**
- WebfrontCore/**
- Data/**
- SharedLibraryCore/**
- Plugins/**
- Integrations/**
- .github/workflows/build_application.yml
pull_request:
branches: [ develop ]
paths:
- Application/**
- WebfrontCore/**
- Data/**
- SharedLibraryCore/**
- Plugins/**
workflow_dispatch:
inputs:
buildNumber:
description: 'Manual build number (optional)'
required: false
type: string
env:
releaseType: prerelease
jobs:
update_revision_number:
runs-on: ubuntu-latest
outputs:
revision_number: ${{ steps.revision.outputs.revision_number }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Restore cache
id: cache
uses: actions/cache@v4
with:
path: cache_dir
key: revision-number
- name: Get current date
id: date
run: echo "current_date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Check and update revision number
id: revision
run: |
FILENAME=cache_dir/revision_number.txt
DATEFILE=cache_dir/previous_date.txt
mkdir -p cache_dir
if [ -f "$DATEFILE" ]; then
prev_date=$(cat "$DATEFILE")
rev_number=$(cat "$FILENAME")
else
prev_date=""
rev_number=0
fi
if [ "$current_date" = "$prev_date" ]; then
rev_number=$((rev_number + 1))
else
rev_number=1
fi
echo "New revision number: $rev_number"
echo $rev_number > "$FILENAME"
echo $current_date > "$DATEFILE"
echo "revision_number=$rev_number" >> $GITHUB_OUTPUT
- name: Save cache
uses: actions/cache@v4
with:
path: cache_dir
key: revision-number
make_version:
runs-on: ubuntu-latest
needs: [ update_revision_number ]
outputs:
build_num: ${{ steps.generate_build_number.outputs.build_num }}
env:
revisionNumber: ${{ needs.update_revision_number.outputs.revision_number }}
steps:
- name: Make build number
id: generate_build_number
run: |
build_num=$(date +'%Y.%-m.%-d').${{ env.revisionNumber }}
echo "build_num=$build_num" >> $GITHUB_OUTPUT
echo "Build number is $build_num"
build:
runs-on: ubuntu-latest
needs: [ make_version ]
env:
solution: IW4MAdmin.sln
buildConfiguration: Prerelease
isPreRelease: false
buildPlatform: Any CPU
outputFolder: ${{ github.workspace }}/Publish/Prerelease
buildNumber: ${{ needs.make_version.outputs.build_num }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Restore NuGet packages
run: dotnet restore ${{ env.solution }}
- name: Generate Tailwind CSS
run: |
curl -sL https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 -o tailwindcss
chmod +x tailwindcss
cd WebfrontCore
../tailwindcss -i wwwroot/css/src/app.css -o wwwroot/css/app.css --minify
- name: Build webfront
run: dotnet build WebfrontCore/WebfrontCore.csproj -c ${{ env.buildConfiguration }} /p:Configuration=${{ env.buildConfiguration }} /p:Platform="x64"
- name: Patch Phosphor CSS font paths
run: |
cd WebfrontCore/wwwroot/lib/phosphor-icons/src
sed -i 's|url("./Phosphor|url("/font/phosphor/Phosphor|g' regular/style.css
sed -i 's|url("./Phosphor|url("/font/phosphor/Phosphor|g' bold/style.css
sed -i 's|url("./Phosphor|url("/font/phosphor/Phosphor|g' fill/style.css
- name: Compile SCSS files
run: |
dotnet tool install Excubo.WebCompiler --global
webcompiler -r WebfrontCore/wwwroot/css/src -o WebfrontCore/wwwroot/css/ -m disable -z disable
- name: Bundle JS files
run: |
echo 'Getting dotnet bundle'
curl -o ${{ github.workspace }}/dotnet-bundle.zip https://raidmax.org/IW4MAdmin/res/dotnet-bundle.zip
echo 'Unzipping download'
unzip ${{ github.workspace }}/dotnet-bundle.zip -d ${{ github.workspace }}/bundle
echo 'Executing dotnet-bundle'
cd ${{ github.workspace }}/bundle
dotnet dotnet-bundle.dll clean ${{ github.workspace }}/WebfrontCore/bundleconfig.json
dotnet dotnet-bundle.dll ${{ github.workspace }}/WebfrontCore/bundleconfig.json
- name: Build plugins
run: |
cd Plugins
find . -name "*.csproj" -print0 | xargs -0 -I {} dotnet publish {} -c ${{ env.buildConfiguration }} -o ../BUILD/Plugins /p:Configuration=${{ env.buildConfiguration }} /p:Platform="x64" /p:DeployOnBuild=false /p:PackageAsSingleFile=false /p:SkipInvalidConfigurations=true /p:Version=${{ env.buildNumber }} --no-restore
- name: Build application
run: dotnet publish Application/Application.csproj -c ${{ env.buildConfiguration }} -o ${{ env.outputFolder }} /p:Version=${{ env.buildNumber }} /p:Configuration=${{ env.buildConfiguration }} /p:Platform="x64" --no-restore
- name: Download translations
run: |
mkdir -p "${{ env.outputFolder }}/Localization"
localizations=("en-US" "ru-RU" "es-EC" "pt-BR" "de-DE")
for localization in "${localizations[@]}"
do
url="https://master.iw4.zip/localization/$localization"
filePath="${{ env.outputFolder }}/Localization/IW4MAdmin.$localization.json"
curl -s "$url" -o "$filePath"
done
- name: Download geolocation database
run: |
mkdir -p ${{ env.outputFolder }}/Resources
wget -O ${{ env.outputFolder }}/Resources/GeoLite2-Country.mmdb https://github.com/P3TERX/GeoLite.mmdb/raw/download/GeoLite2-Country.mmdb
- name: Clean up publish files
run: |
chmod +x ${{ github.workspace }}/Application/BuildScripts/PostBuild.sh
bash ${{ github.workspace }}/Application/BuildScripts/PostBuild.sh ${{ env.outputFolder }} ${{ github.workspace }}
- name: Generate start scripts
run: |
cat << EOF > "${{ env.outputFolder }}/StartIW4MAdmin.cmd"
@echo off
@title IW4MAdmin
set DOTNET_CLI_TELEMETRY_OPTOUT=1
dotnet Lib\IW4MAdmin.dll
pause
EOF
cat << EOF > "${{ env.outputFolder }}/StartIW4MAdmin.sh"
#!/bin/bash
export DOTNET_CLI_TELEMETRY_OPTOUT=1
dotnet Lib/IW4MAdmin.dll
EOF
- name: Move extra content into publish directory
run: |
cp ${{ github.workspace }}/Plugins/ScriptPlugins/*.js ${{ env.outputFolder }}/Plugins/ 2>/dev/null || true
cp ${{ github.workspace }}/Plugins/ScriptPlugins/*.cs ${{ env.outputFolder }}/Plugins/ 2>/dev/null || true
cp ${{ github.workspace }}/BUILD/Plugins/*.dll ${{ env.outputFolder }}/Plugins/
mkdir -p ${{ env.outputFolder }}/wwwroot/css
mkdir -p ${{ env.outputFolder }}/wwwroot/css/user
cp ${{ github.workspace }}/WebfrontCore/wwwroot/css/app.min.css ${{ env.outputFolder }}/wwwroot/css/app.min.css
cp ${{ github.workspace }}/WebfrontCore/wwwroot/css/user/user.css ${{ env.outputFolder }}/wwwroot/css/user/user.css
mkdir -p ${{ env.outputFolder }}/wwwroot/js
mkdir -p ${{ env.outputFolder }}/wwwroot/js/user
cp ${{ github.workspace }}/WebfrontCore/wwwroot/js/app.min.js ${{ env.outputFolder }}/wwwroot/js/app.min.js
cp ${{ github.workspace }}/WebfrontCore/wwwroot/js/user/user.js ${{ env.outputFolder }}/wwwroot/js/user/user.js
mkdir -p ${{ env.outputFolder }}/wwwroot/font
mkdir -p ${{ env.outputFolder }}/wwwroot/font/phosphor
rsync -ar ${{ github.workspace }}/WebfrontCore/wwwroot/font/phosphor/ ${{ env.outputFolder }}/wwwroot/font/phosphor/
mkdir -p ${{ env.outputFolder }}/GameFiles
rsync -ar ${{ github.workspace }}/GameFiles/ ${{ env.outputFolder }}/GameFiles
mkdir -p ${{ env.outputFolder }}/wwwroot/images/
rsync -ar ${{ github.workspace }}/WebfrontCore/wwwroot/images/ ${{ env.outputFolder }}/wwwroot/images/
cp ${{ github.workspace }}/DeploymentFiles/UpdateIW4MAdmin.ps1 ${{ env.outputFolder }}/UpdateIW4MAdmin.ps1
cp ${{ github.workspace }}/DeploymentFiles/UpdateIW4MAdmin.sh ${{ env.outputFolder }}/UpdateIW4MAdmin.sh
- name: Upload artifact for analysis
uses: actions/upload-artifact@v4
with:
name: IW4MAdmin-${{ env.buildNumber }}-${{ env.releaseType }}
path: ${{ env.outputFolder }}
build_and_push_docker_dev:
runs-on: ubuntu-latest
needs: [ make_version, build ]
if: ${{ github.ref == 'refs/heads/develop' }}
permissions:
contents: read
packages: write
env:
buildNumber: ${{ needs.make_version.outputs.build_num }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download application artifact
uses: actions/download-artifact@v4
with:
name: IW4MAdmin-${{ env.buildNumber }}-${{ env.releaseType }}
path: ${{ github.workspace }}/publish
- name: Prepare Docker build context
run: |
cp Dockerfile entrypoint.sh ${{ github.workspace }}/publish/
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/iw4madmin
tags: |
# push to develop branch: tags as 'develop'
type=raw,value=develop
# tag with the build number and -dev suffix (e.g., 2025.8.13.1-dev)
type=raw,value=${{ env.buildNumber }}-dev
# tag with the short git sha (e.g., f15fbd3)
type=sha,prefix=
labels: |
org.opencontainers.image.version=${{ env.buildNumber }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ github.workspace }}/publish
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build_and_push_docker_release:
runs-on: ubuntu-latest
needs: [ make_version, build ]
environment: prerelease
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/release/pre' }}
permissions:
contents: read
packages: write
env:
buildNumber: ${{ needs.make_version.outputs.build_num }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download application artifact
uses: actions/download-artifact@v4
with:
name: IW4MAdmin-${{ env.buildNumber }}-${{ env.releaseType }}
path: ${{ github.workspace }}/publish
- name: Prepare Docker build context
run: |
cp Dockerfile entrypoint.sh ${{ github.workspace }}/publish/
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/iw4madmin
tags: |
# push to master or release/pre branch: tags as 'latest'
type=raw,value=latest
# tag with the build number (e.g., 2025.8.13.1)
type=raw,value=${{ env.buildNumber }}
# tag with the short git sha (e.g., f15fbd3)
type=sha,prefix=
labels: |
org.opencontainers.image.version=${{ env.buildNumber }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ github.workspace }}/publish
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
release_github:
runs-on: ubuntu-latest
needs: [ make_version, build ]
permissions:
contents: write
environment: prerelease
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/release/pre' }}
env:
buildNumber: ${{ needs.make_version.outputs.build_num }}
steps:
- name: Download build
uses: actions/download-artifact@v4
with:
name: IW4MAdmin-${{ env.buildNumber }}-${{ env.releaseType }}
path: ${{ github.workspace }}/artifact
- name: Zip build
run: |
cd ${{ github.workspace }}/artifact
zip -r IW4MAdmin-${{ env.buildNumber }}.zip .
- name: Make release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.buildNumber }}-${{ env.releaseType }}
name: IW4MAdmin ${{ env.buildNumber }}
draft: false
prerelease: true
body: Automated rolling release - changelog below. [Updating Instructions](https://github.com/RaidMax/IW4M-Admin/wiki/Getting-Started#updating)
generateReleaseNotes: true
artifacts: ${{ github.workspace }}/artifact/*.zip
artifactErrorsFailBuild: true
update_master_version:
runs-on: ubuntu-latest
needs: [ make_version, build, release_github ]
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/release/pre' }}
env:
buildNumber: ${{ needs.make_version.outputs.build_num }}
steps:
- name: Update master version
run: |
curl --header "Content-Type: application/json" \
--request POST \
--data '{"current-version-${{ env.releaseType }}":"${{ env.buildNumber }}","jwt-secret": "${{ secrets.JWTSecret }}"}' \
http://api.raidmax.org:5000/version