-
Notifications
You must be signed in to change notification settings - Fork 1
178 lines (154 loc) · 4.98 KB
/
ci.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
name: Continuous Integration
on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
branches:
- main
paths-ignore:
- '**.md'
workflow_dispatch:
jobs:
compile:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
permissions:
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Build
run: dotnet build --configuration Debug
- name: Code Analysis
uses: JetBrains/ReSharper-InspectCode@v0.8
with:
solution: ./NWNX.NET.sln
tool-version: 2024.3.0
test:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip ci')"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build and Run Tests
uses: devcontainers/ci@v0.3
with:
push: never
env: |
NWNX_DOTNET_ASSEMBLY=/workspaces/NWNX.NET/NWNX.NET.Tests/bin/Release/NWNX.NET.Tests
NWNX_DOTNET_TEST_RESULT_PATH=/workspaces/NWNX.NET/NWNX.NET.Tests/bin/Release/NWNX.NET.Tests/results
runCmd: |
dotnet build --configuration Release
cd /nwn/data/bin/linux-amd64
/nwn/run-server.sh
- name: Upload Event File
uses: actions/upload-artifact@v4
if: always()
with:
name: Event File
path: ${{ github.event_path }}
- name: Upload Results
uses: actions/upload-artifact@v4
if: always()
with:
name: Test Results
path: NWNX.NET.Tests/bin/Release/NWNX.NET.Tests/results/*.xml
build:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
needs: [compile, test]
outputs:
version: ${{ steps.vars.outputs.VERSION }}
tag: ${{ steps.vars.outputs.TAG }}
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Version and Tag
id: bump_version
uses: anothrNick/github-tag-action@1.71.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BUMP: patch
RELEASE_BRANCHES: main
WITH_V: true
PRERELEASE_SUFFIX: alpha
PRERELEASE: ${{ github.ref != 'main' }}
TAG_CONTEXT: branch
VERBOSE: true
- name: Prepare Outputs
id: vars
run: |
echo "VERSION=$(echo ${{ steps.bump_version.outputs.tag }} | sed 's/[v]//g')" >> "$GITHUB_OUTPUT"
echo "TAG=$(echo ${{ steps.bump_version.outputs.tag }})" >> "$GITHUB_OUTPUT"
- name: Build Release Binaries
id: build
run: dotnet build NWNX.NET/NWNX.NET.csproj --configuration Release -p:Version=${{ steps.vars.outputs.VERSION }}
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: Binaries
path: NWNX.NET/bin/Release
if-no-files-found: error
release:
runs-on: ubuntu-latest
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'
needs: build
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Release Artifacts
uses: actions/download-artifact@v4
with:
name: Binaries
path: binaries
- name: Zip Binaries
run: zip -r ../NWNX.NET.zip ./*
working-directory: binaries
- name: Upload Release Binaries
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ needs.build.outputs.tag }} --title "Release ${{ needs.build.outputs.version }}"
gh release upload ${{ needs.build.outputs.tag }} NWNX.NET.zip
nuget:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Download Release Artifacts
uses: actions/download-artifact@v4
with:
name: Binaries
path: bin/Release
- name: NuGet Publish
run: dotnet nuget push bin/Release/*.nupkg --api-key ${{ secrets.NUGET_KEY }} --source https://api.nuget.org/v3/index.json
- name: GitHub Publish
run: dotnet nuget push bin/Release/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/nwn-dotnet/index.json