-
Notifications
You must be signed in to change notification settings - Fork 5
220 lines (189 loc) · 6.7 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
# 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: .NET
on:
push:
branches: [ "main" ]
paths:
- '**/Si_*/**'
- '!*.md'
- '!*.json'
env:
BUILD_TYPE: Release
jobs:
get-commit-number:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
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@v3
- uses: dorny/paths-filter@v2
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@v3
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
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@v3
- 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@v3
- 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@v3
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}}
- name: Make output paths
run: |
cd ${{ env.START_DIR }}
mkdir -p dedi/Mods
mkdir -p listen/Mods
mkdir -p dedi/Mods/disabled
mkdir -p listen/Mods/disabled
mkdir -p dedi/UserData
mkdir -p listen/UserData
cp LICENSE dedi/UserData/Mod-License.txt
cp LICENSE listen/UserData/Mod-License.txt
cp ${{ env.START_DIR }}/${{ matrix.path }}/bin/${{env.BUILD_TYPE}}/netstandard2.1/*.dll dedi/Mods
cp ${{ env.START_DIR }}/${{ matrix.path }}/bin/${{env.BUILD_TYPE}}/net6.0/*.dll listen/Mods
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.path }}-build-${{ env.GITHUB_SHA_SHORT }}
path: ${{ matrix.path }}/bin/${{env.BUILD_TYPE}}/**/*.dll
- uses: actions/upload-artifact@v3
with:
name: dedicated-server-${{ env.GITHUB_SHA_SHORT }}
path: ${{ env.START_DIR }}/dedi
- uses: actions/upload-artifact@v3
with:
name: listen-server-${{ env.GITHUB_SHA_SHORT }}
path: ${{ env.START_DIR }}/listen
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
- name: Make output paths
run: |
mkdir -p release/dedi
mkdir -p release/listen
- uses: actions/download-artifact@v3
with:
name: dedicated-server-${{ env.GITHUB_SHA_SHORT }}
path: release/dedi
- uses: actions/download-artifact@v3
with:
name: listen-server-${{ env.GITHUB_SHA_SHORT }}
path: release/listen
- 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@v1
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