-
Notifications
You must be signed in to change notification settings - Fork 5
250 lines (216 loc) · 8.08 KB
/
cicd-push.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
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
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: CI-CD-Pipeline
on:
push:
branches: [ "main" ]
paths:
- '**/Si_*/**'
- '!*.md'
- '!*.json'
env:
BUILD_TYPE: Release
jobs:
get-commit-number:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate the commit number
id: commit-number
run: |
echo "comnum=$(git log --oneline | wc -l)" >> "$GITHUB_OUTPUT"
outputs:
comnum: ${{ steps.commit-number.outputs.comnum }}
find-if-nuget-update-is-needed:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: checkAdminMod
with:
filters: |
admin-updated:
- 'Si_AdminMod/**'
# run only if 'workflows' files were changed
- name: adminmod updated
if: steps.checkAdminMod.outputs.admin-updated == 'true'
run: echo "AdminMod Update Found."
# run only if not 'workflows' files were changed
- name: no adminmod updates
if: steps.checkAdminMod.outputs.admin-updated != 'true'
run: echo "No AdminMod Update Found. Skipping nuget packages..."
outputs:
admin-updated: ${{ steps.checkAdminMod.outputs.admin-updated }}
create-package:
needs: [ find-if-nuget-update-is-needed, get-commit-number ]
if: needs.find-if-nuget-update-is-needed.outputs.admin-updated == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: References
uses: actions/checkout@v4
with:
repository: ${{ secrets.PRIV_R }}
token: ${{ secrets.FGAT_PRIV_R }}
path: references
- name: Copy References
run: |
cp -r references/. include
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Restore
run: |
cd Si_AdminMod
dotnet restore
- name: Build
run: |
cd Si_AdminMod
dotnet build --no-restore -c ${{env.BUILD_TYPE}}
- name: Test
run: |
cd Si_AdminMod
dotnet test -c ${{env.BUILD_TYPE}} --no-build
- name: Pack NuGet
run: |
cd Si_AdminMod
dotnet pack -c ${{env.BUILD_TYPE}} --no-build --output . /p:Version=2.0.${{ needs.get-commit-number.outputs.comnum }}
- name: Push to NuGet
run: |
cd Si_AdminMod
dotnet nuget push "*.nupkg" --api-key ${{secrets.NUGET_ADMINMOD_API_KEY}} --source https://api.nuget.org/v3/index.json
- name: Wait for publishing
uses: juliangruber/[email protected]
with:
time: 10m
fanout:
if: ${{ !failure() && !cancelled() }}
needs: [ find-if-nuget-update-is-needed, create-package ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate matrix with all modules of the repo
id: set-matrix
run: |
echo "matrix=$(ls -l | grep '^d' | awk -F ' ' '{print $9}' | grep -Po 'Si.*' | jq -R -s -c 'split("\n") | map(select(length > 0))')" >> "$GITHUB_OUTPUT"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
build:
if: ${{ !failure() && !cancelled() }}
needs: fanout
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
path: ${{ fromJson(needs.fanout.outputs.matrix) }}
steps:
- name: Prepare environment sha
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Prepare environment pwd
shell: bash
run: echo "START_DIR=`pwd`" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: References
uses: actions/checkout@v4
with:
repository: ${{ secrets.PRIV_R }}
token: ${{ secrets.FGAT_PRIV_R }}
path: references
- name: Copy References
run: |
cp -r references/. include
- name: Download QList
uses: robinraju/[email protected]
with:
repository: "dodad-2/QList"
latest: true
fileName: "QList.dll"
tarBall: false
zipBall: false
- name: Move QList
run: |
mv QList.dll include/
- name: Setup .NET 6
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: |
cd ${{ matrix.path }}
dotnet restore
- name: Build
run: |
cd ${{ matrix.path }}
dotnet build --no-restore -c ${{env.BUILD_TYPE}}
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.path }}-build-${{ env.GITHUB_SHA_SHORT }}
path: ${{ matrix.path }}/bin/${{env.BUILD_TYPE}}/**/${{ matrix.path }}.dll
- uses: actions/upload-artifact@v4
with:
name: dedicated-server-${{ matrix.path }}-build-${{ env.GITHUB_SHA_SHORT }}
path: ${{ matrix.path }}/bin/${{env.BUILD_TYPE}}/netstandard2.1/${{ matrix.path }}.dll
- uses: actions/upload-artifact@v4
with:
name: listen-server-${{ matrix.path }}-build-${{ env.GITHUB_SHA_SHORT }}
path: ${{ matrix.path }}/bin/${{env.BUILD_TYPE}}/net6.0/${{ matrix.path }}.dll
publish:
if: github.event_name == 'push' && ${{ !failure() && !cancelled() }}
permissions:
contents: write
needs: [ get-commit-number, build, fanout ]
runs-on: ubuntu-latest
steps:
- name: Prepare env
shell: bash
run: echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
sparse-checkout: .
- name: Make output paths
run: |
mkdir -p release/dedi/Mods/disabled
mkdir -p release/listen/Mods/disabled
mkdir -p release/dedi/UserData
mkdir -p release/listen/UserData
cp rungame.bat release/dedi/rungame.bat
cp launch.bat release/dedi/launch.bat
cp LICENSE release/dedi/UserData/Mod-License.txt
cp LICENSE release/listen/UserData/Mod-License.txt
- uses: actions/download-artifact@v4
with:
pattern: dedicated-server-*
merge-multiple: true
path: release/dedi/Mods
- uses: actions/download-artifact@v4
with:
pattern: listen-server-*
merge-multiple: true
path: release/listen/Mods
- name: Disable some mods
run: |
# AutoTeamsSelect was addressed with a game update to vote on the next mode
mv release/dedi/Mods/Si_AutoTeamsSelect.dll release/dedi/Mods/disabled
mv release/listen/Mods/Si_AutoTeamsSelect.dll release/listen/Mods/disabled
# FriendlyFireLimits is disabled by default
mv release/dedi/Mods/Si_FriendlyFireLimits.dll release/dedi/Mods/disabled
mv release/listen/Mods/Si_FriendlyFireLimits.dll release/listen/Mods/disabled
# Tech Glitch is disabled because the discrepancy is happening on the server side (not client side)
mv release/dedi/Mods/Si_TechGlitch.dll release/dedi/Mods/disabled
mv release/listen/Mods/Si_TechGlitch.dll release/listen/Mods/disabled
- name: Zip Builds
run: |
(cd release/dedi && zip -qq -r ../../DedicatedServer-v${{ needs.get-commit-number.outputs.comnum }}-${{ env.GITHUB_SHA_SHORT }}.zip *)
(cd release/listen && zip -qq -r ../../ListenServer-v${{ needs.get-commit-number.outputs.comnum }}-${{ env.GITHUB_SHA_SHORT }}.zip *)
- name: Release
uses: softprops/action-gh-release@975c1b265e11dd76618af1c374e7981f9a6ff44a
with:
tag_name: v${{ needs.get-commit-number.outputs.comnum }}
files: |
DedicatedServer-v${{ needs.get-commit-number.outputs.comnum }}-${{ env.GITHUB_SHA_SHORT }}.zip
ListenServer-v${{ needs.get-commit-number.outputs.comnum }}-${{ env.GITHUB_SHA_SHORT }}.zip