2222
2323jobs :
2424 compile :
25- runs-on : ubuntu-20.04
25+ runs-on : ubuntu-latest
2626 if : " !contains(github.event.head_commit.message, 'skip ci')"
2727 permissions :
2828 security-events : write
2929 steps :
3030 - name : Checkout
31- uses : actions/checkout@v2
31+ uses : actions/checkout@v4
3232 with :
3333 submodules : recursive
3434
35- - name : Check Line Endings
36- uses : erclu/check-crlf@v1
35+ - name : Setup .NET
36+ uses : actions/setup-dotnet@v4
3737 with :
38- path : NWN.Anvil
39-
40- - name : Setup .NET Core
41- uses : actions/setup-dotnet@v1.9.0
42- with :
43- dotnet-version : ' 8.0.x'
38+ global-json-file : global.json
4439
4540 - name : Build
4641 run : dotnet build --configuration Debug
4742
48- - name : Prepare Outputs
49- id : vars
50- run : echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
51-
52- - name : Code Analysis Cache
53- uses : actions/cache@v2
54- with :
55- path : ~/.local/share/JetBrains
56- key : analysis-cache-${{ steps.vars.outputs.sha_short }}
57- restore-keys : |
58- analysis-cache
59-
6043 - name : Code Analysis
61- uses : JetBrains/ReSharper-InspectCode@v0.3
44+ uses : JetBrains/ReSharper-InspectCode@v0.8
6245 with :
6346 solution : ./NWN.Anvil.sln
64- tool-version : 2024.1 .0
47+ tool-version : 2024.3 .0
6548
6649 test :
67- runs-on : ubuntu-20.04
50+ runs-on : ubuntu-latest
6851 if : " !contains(github.event.head_commit.message, 'skip ci')"
6952 steps :
7053 - name : Checkout
71- uses : actions/checkout@v2
54+ uses : actions/checkout@v4
7255 with :
7356 submodules : recursive
7457
75- - name : Setup .NET Core
76- uses : actions/setup-dotnet@v1.9.0
77- with :
78- dotnet-version : ' 8.0.x'
79-
80- - name : Build
81- run : dotnet build --configuration Release
82-
83- - name : Load Environment Variables
84- id : env_vars
85- uses : falti/dotenv-action@v0.2.7
86-
87- - name : Run Tests
58+ - name : Create Output Directories
8859 run : |
89- docker compose --project-directory . -f NWN.Anvil.Tests/bin/Release/docker-compose.yml build --build-arg NWNX_VERSION=${{ steps.env_vars.outputs.nwnx_version }} --build-arg BINARY_PATH=NWN.Anvil/bin/Release/net8.0
90- docker compose --project-directory . -f NWN.Anvil.Tests/bin/Release/docker-compose.yml up
91-
92- - name : Install NUnit
93- run : nuget install NUnit.Console -Version 3.12.0
94-
95- - name : Fetch transform code
96- run : wget https://raw.githubusercontent.com/nunit/nunit-transforms/master/nunit3-junit/nunit3-junit.xslt
97- shell : bash
60+ mkdir -p test_results
9861
99- - name : Transform NUnit3 to JUnit
100- run : |
101- $xslt = New-Object System.Xml.Xsl.XslCompiledTransform;
102- $xslt.Load("nunit3-junit.xslt");
103- $xslt.Transform("NWN.Anvil.Tests/bin/Release/results/NWN.Anvil.Tests/TestResult.xml", "TestResult.junit.xml");
104- shell : pwsh
62+ - name : Build and Run Tests
63+ uses : devcontainers/ci@v0.3
64+ with :
65+ push : never
66+ env : |
67+ NWNX_DOTNET_ASSEMBLY=/workspaces/NWN.Anvil/NWN.Anvil/bin/Release/net8.0/NWN.Anvil
68+ ANVIL_ADD_PLUGIN_PATHS=/workspaces/NWN.Anvil/NWN.Anvil.TestRunner/bin/Release:/workspaces/NWN.Anvil/NWN.Anvil.Tests/bin/Release
69+ runCmd : |
70+ git config --global --add safe.directory /workspaces/NWN.Anvil
71+ dotnet build --configuration Release
72+ cd /nwn/data/bin/linux-amd64
73+ /nwn/run-server.sh
10574
10675 - name : Upload Event File
10776 uses : actions/upload-artifact@v4
@@ -115,29 +84,29 @@ jobs:
11584 if : always()
11685 with :
11786 name : Test Results
118- path : TestResult.junit .xml
87+ path : test_results/NWN.Anvil.Tests/* .xml
11988
12089 build :
121- runs-on : ubuntu-20.04
90+ runs-on : ubuntu-latest
12291 if : github.event_name == 'push' || github.event_name == 'workflow_dispatch'
12392 needs : [compile, test]
12493 outputs :
125- version : ${{ steps.vars.outputs.version }}
126- tag : ${{ steps.vars.outputs.tag }}
127- sha_short : ${{ steps.vars.outputs.sha_short }}
128- image_repository : ${{ steps.vars.outputs.image_repository }}
129- created : ${{ steps.build.outputs.created }}
94+ version : ${{ steps.vars.outputs.VERSION }}
95+ tag : ${{ steps.vars.outputs.TAG }}
96+ sha_short : ${{ steps.vars.outputs.SHA_SHORT }}
97+ image_repository : ${{ steps.vars.outputs.IMAGE_REPOSITORY }}
98+ created : ${{ steps.build.outputs.CREATED }}
13099 steps :
131100 - name : Checkout
132- uses : actions/checkout@v2
101+ uses : actions/checkout@v4
133102 with :
134103 fetch-depth : 0
135104 submodules : recursive
136105
137- - name : Setup .NET Core
138- uses : actions/setup-dotnet@v1.9.0
106+ - name : Setup .NET
107+ uses : actions/setup-dotnet@v4
139108 with :
140- dotnet-version : ' 8.0.x '
109+ global-json-file : global.json
141110
142111 - name : Tag Commit
143112 if : github.event.inputs.tag != ''
@@ -147,24 +116,24 @@ jobs:
147116 id : vars
148117 run : |
149118 if [[ "${{github.base_ref}}" == "main" || "${{github.ref}}" == "refs/heads/main" ]]; then
150- echo "::set-output name=tag:: $(git describe --tags)"
151- echo "::set-output name=version:: $(git describe --tags | sed 's/^v//')"
119+ echo "TAG= $(git describe --tags)" >> "$GITHUB_OUTPUT "
120+ echo "VERSION= $(git describe --tags | sed 's/^v//')" >> "$GITHUB_OUTPUT "
152121 else
153122 DESCRIBE=`git describe --tags --long`
154- VERSION =`echo $DESCRIBE | awk '{split($0,a,"-"); print a[1]}'`
123+ BASE_VERSION =`echo $DESCRIBE | awk '{split($0,a,"-"); print a[1]}'`
155124 META=`echo $DESCRIBE | awk '{split($0,a,"-"); print a[2]}'`
156125 BUILD=`echo $DESCRIBE | awk '{split($0,a,"-"); print a[3]}'`
157126 COMMIT=`echo $DESCRIBE | awk '{split($0,a,"-"); print a[4]}'`
158- echo "::set-output name=version:: $(echo ${VERSION }-${META}.${BUILD}.r${COMMIT:1} | sed 's/^v//')"
127+ echo "VERSION= $(echo ${BASE_VERSION }-${META}.${BUILD}.r${COMMIT:1} | sed 's/^v//')" >> "$GITHUB_OUTPUT "
159128 fi
160- echo "::set-output name=sha_short:: $(git rev-parse --short HEAD)"
161- echo "::set-output name=image_repository:: $(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')"
129+ echo "SHA_SHORT= $(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT "
130+ echo "IMAGE_REPOSITORY= $(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT "
162131
163132 - name : Build Release Binaries
164133 id : build
165134 run : |
166- dotnet build --configuration Release -p:Version=${{ steps.vars.outputs.version }}
167- echo "::set-output name=created:: $(echo date -u +'%Y-%m-%dT%H:%M:%SZ')"
135+ dotnet build --configuration Release -p:Version=${{ steps.vars.outputs.VERSION }}
136+ echo "CREATED= $(echo date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT "
168137
169138 - name : Upload NuGet Artifacts
170139 uses : actions/upload-artifact@v4
@@ -198,10 +167,15 @@ jobs:
198167 if-no-files-found : error
199168
200169 release :
201- runs-on : ubuntu-20.04
170+ runs-on : ubuntu-latest
202171 if : (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'
203172 needs : build
173+ permissions :
174+ contents : write
204175 steps :
176+ - name : Checkout
177+ uses : actions/checkout@v4
178+
205179 - name : Download Release Artifacts
206180 uses : actions/download-artifact@v4
207181 with :
@@ -212,37 +186,25 @@ jobs:
212186 run : zip -r ../NWN.Anvil.zip ./*
213187 working-directory : binaries
214188
215- - name : Create Release
216- id : create_release
217- uses : actions/create-release@v1
218- env :
219- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
220- with :
221- release_name : Release ${{ needs.build.outputs.version }}
222- draft : false
223- prerelease : false
224- tag_name : ${{ needs.build.outputs.tag }}
225-
226189 - name : Upload Release Binaries
227- id : upload-release-asset
228- uses : actions/upload-release-asset@v1
229190 env :
230191 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
231- with :
232- upload_url : ${{ steps.create_release.outputs.upload_url }}
233- asset_path : ./NWN.Anvil.zip
234- asset_name : NWN.Anvil.zip
235- asset_content_type : application/zip
192+ run : |
193+ gh release create ${{ needs.build.outputs.tag }} --title "Release ${{ needs.build.outputs.version }}" --generate-notes
194+ gh release upload ${{ needs.build.outputs.tag }} NWN.Anvil.zip
236195
237196 nuget :
238- runs-on : ubuntu-20.04
197+ runs-on : ubuntu-latest
239198 if : github.event_name == 'push' || github.event_name == 'workflow_dispatch'
240199 needs : build
241200 steps :
242- - name : Setup .NET Core
243- uses : actions/setup-dotnet@v1.9.0
201+ - name : Checkout
202+ uses : actions/checkout@v4
203+
204+ - name : Setup .NET
205+ uses : actions/setup-dotnet@v4
244206 with :
245- dotnet-version : ' 8.0.x '
207+ global-json-file : global.json
246208
247209 - name : Download Release Artifacts
248210 uses : actions/download-artifact@v4
@@ -257,12 +219,12 @@ jobs:
257219 run : dotnet nuget push 'binaries/**/*.nupkg' --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/nwn-dotnet/index.json
258220
259221 docker :
260- runs-on : ubuntu-20.04
222+ runs-on : ubuntu-latest
261223 if : github.event_name == 'push' || github.event_name == 'workflow_dispatch'
262224 needs : build
263225 steps :
264226 - name : Checkout
265- uses : actions/checkout@v2
227+ uses : actions/checkout@v4
266228 with :
267229 submodules : recursive
268230
@@ -273,31 +235,26 @@ jobs:
273235 path : binaries
274236
275237 - name : Login to DockerHub
276- uses : docker/login-action@v1
238+ uses : docker/login-action@v3
277239 with :
278240 username : ${{ secrets.DOCKER_HUB_USERNAME }}
279241 password : ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
280242
281243 - name : Login to GitHub Container Registry
282- uses : docker/login-action@v1
244+ uses : docker/login-action@v3
283245 with :
284246 registry : ghcr.io
285247 username : ${{ github.actor }}
286248 password : ${{ secrets.GITHUB_TOKEN }}
287249
288- - name : Load Environment Variables
289- id : env_vars
290- uses : falti/dotenv-action@v0.2.7
291-
292250 - name : Build and push
293251 id : docker_build
294- uses : docker/build-push-action@v2
252+ uses : docker/build-push-action@v6
295253 with :
296254 context : ./
297255 file : ./dockerfile
298256 push : true
299257 build-args : |
300- NWNX_VERSION=${{ steps.env_vars.outputs.nwnx_version }}
301258 BINARY_PATH=/binaries/net8.0
302259 labels : |
303260 org.opencontainers.image.title=Anvil
0 commit comments