-
-
Notifications
You must be signed in to change notification settings - Fork 12
199 lines (181 loc) · 7.95 KB
/
test-and-publish.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
name: Test and Publish Module
on:
repository_dispatch:
types: [game_version_update, game_version_update_patch]
push:
branches:
- master
- dev
paths:
- '.github/workflows/test-and-publish.yml'
- 'src/**'
- 'build/**'
- 'tests/**'
pull_request:
branches:
- dev
# will be triggereg when undrafting or requesting review
types: [review_requested, ready_for_review]
paths:
- '.github/workflows/test-and-publish.yml'
- 'src/**'
- 'build/**'
- 'tests/**'
env:
# Disable the .NET logo in the console output.
DOTNET_NOLOGO: true
# Disable the .NET first time experience to skip caching NuGet packages and speed up the build.
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Disable sending .NET CLI telemetry to Microsoft.
DOTNET_CLI_TELEMETRY_OPTOUT: true
TEST_FILTERS: "+[MCMv*]* -[MCM*.*Tests]* -[MCMv*]MCM.LightInject* -[*]System.Diagnostics.CodeAnalysis* -[*]BUTR.DependencyInjection* -[*]Bannerlord.BUTR.Shared* -[*]HarmonyLib.BUTR*"
jobs:
test:
name: Test Module
runs-on: windows-latest
steps:
- name: Tests Setup
uses: butr/actions-tests-setup@v1
with:
github-token: ${{secrets.GITHUB_TOKEN}}
steam-login: ${{secrets.STEAM_LOGIN}}
steam-password: ${{secrets.STEAM_PASSWORD}}
stable-version: ${{vars.GAME_VERSION_STABLE}}
beta-version: ${{vars.GAME_VERSION_BETA}}
stable-directory: 'bannerlord-stable'
beta-directory: 'bannerlord-beta'
- name: Build MCM Test
run: >-
$stable_version=$env:STABLE_VERSION;
$stable_version=$stable_version.substring(1);
$beta_version=$env:BETA_VERSION;
$beta_version=$beta_version.substring(1);
dotnet build "tests/MCM.Tests/MCM.Tests.csproj" --configuration Stable_Debug -p:GameVersion=$stable_version -p:GameFolder="$PWD/bannerlord-stable";
dotnet build "tests/MCM.Tests/MCM.Tests.csproj" --configuration Stable_Release -p:GameVersion=$stable_version -p:GameFolder="$PWD/bannerlord-stable";
dotnet build "tests/MCM.Tests/MCM.Tests.csproj" --configuration Beta_Debug -p:GameVersion=$beta_version -p:GameFolder="$PWD/bannerlord-beta";
dotnet build "tests/MCM.Tests/MCM.Tests.csproj" --configuration Beta_Release -p:GameVersion=$beta_version -p:GameFolder="$PWD/bannerlord-beta";
env:
STABLE_VERSION: ${{vars.GAME_VERSION_STABLE}}
BETA_VERSION: ${{vars.GAME_VERSION_BETA}}
shell: pwsh
- name: Test MCM with Coverage
run: >-
opencover/OpenCover.Console.exe -register -target:"dotnet.exe" -targetargs:"test tests/MCM.Tests/MCM.Tests.csproj --configuration Stable_Debug --no-build" -filter:"${{env.TEST_FILTERS}}" -excludebyattribute:"*.ExcludeFromCodeCoverage*" -output:coverage_mcm_stable_debug.xml -mergebyhash;
opencover/OpenCover.Console.exe -register -target:"dotnet.exe" -targetargs:"test tests/MCM.Tests/MCM.Tests.csproj --configuration Stable_Release --no-build" -filter:"${{env.TEST_FILTERS}}" -excludebyattribute:"*.ExcludeFromCodeCoverage*" -output:coverage_mcm_stable_release.xml -mergebyhash;
opencover/OpenCover.Console.exe -register -target:"dotnet.exe" -targetargs:"test tests/MCM.Tests/MCM.Tests.csproj --configuration Beta_Debug --no-build" -filter:"${{env.TEST_FILTERS}}" -excludebyattribute:"*.ExcludeFromCodeCoverage*" -output:coverage_mcm_beta_debug.xml -mergebyhash;
opencover/OpenCover.Console.exe -register -target:"dotnet.exe" -targetargs:"test tests/MCM.Tests/MCM.Tests.csproj --configuration Beta_Release --no-build" -filter:"${{env.TEST_FILTERS}}" -excludebyattribute:"*.ExcludeFromCodeCoverage*" -output:coverage_mcm_beta_release.xml -mergebyhash;
shell: pwsh
- name: ReportGenerator
uses: danielpalme/ReportGenerator-GitHub-Action@5.2.0
with:
reports: 'coverage_mcm_stable_debug.xml;coverage_mcm_stable_release.xml;coverage_mcm_beta_debug.xml;coverage_mcm_beta_release.xml'
targetdir: 'coveragereport'
reporttypes: 'HtmlInline;Cobertura'
sourcedirs: './'
tag: '${{ github.run_number }}_${{ github.run_id }}' # Optional tag or build version.
- name: Upload ReportGenerator to GitHub
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coveragereport
- name: Upload ReportGenerator to CodeCov
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}
file: coveragereport/Cobertura.xml
fail_ci_if_error: true
build-module:
if: ${{ github.ref == 'refs/heads/master' }}
needs: ["test"]
name: Build Module
runs-on: ubuntu-latest
steps:
- name: Setup
uses: butr/actions-common-setup@v2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
# ignore Stable_Release and treat it as Release
- name: Build MCM (Release)
run: >-
mkdir bannerlord;
dotnet build src/MCM.Publish/MCM.Publish.csproj --configuration Stable_Release -p:GameFolder="$PWD/bannerlord";
shell: pwsh
- name: Install and Run ChangelogParser
id: changelog
run: |
dotnet tool install -g Bannerlord.ChangelogParser
vers="$(bannerlord_changelog_parser latestversion -f "$PWD/changelog.txt")"
echo "::set-output name=mod_version::$vers"
desc="$(bannerlord_changelog_parser fulldescription -f "$PWD/changelog.txt")"
desc="${desc//'%'/'%25'}"
desc="${desc//$'\n'/'%0A'}"
desc="${desc//$'\r'/'%0D'}"
echo "::set-output name=mod_description::$desc"
- name: Upload Bannerlord folder
if: ${{ github.ref == 'refs/heads/master' }}
uses: actions/upload-artifact@v4
with:
name: bannerlord
path: ./bannerlord/
###########################
# NUGET/GPR #
###########################
publish-on-nuget:
needs: ["build-module"]
uses: BUTR/workflows/.github/workflows/release-nuget.yml@master
with:
project_path: src/MCM/MCM.csproj
secrets:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
###########################
# NUGET/GPR #
###########################
publish-on-nuget-source:
needs: ["build-module"]
uses: BUTR/workflows/.github/workflows/release-nuget.yml@master
with:
project_path: src/MCM.Source/MCM.Source.csproj
secrets:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
###########################
# NEXUSMODS #
###########################
publish-on-nexusmods:
needs: ["build-module"]
uses: BUTR/workflows/.github/workflows/release-nexusmods.yml@master
with:
nexusmods_game_id: mountandblade2bannerlord
nexusmods_mod_id: 612
mod_filename: Mod Configuration Menu
mod_version: ${{ needs.build-module.outputs.mod_version }}
mod_description: ${{ needs.build-module.outputs.mod_description }}
artifact_name: bannerlord
secrets:
NEXUSMODS_APIKEY: ${{ secrets.NEXUSMODS_APIKEY }}
NEXUSMODS_SESSION_COOKIE: ${{ secrets.NEXUSMODS_SESSION_COOKIE }}
###########################
# STEAM #
###########################
publish-on-steam:
needs: ["build-module"]
uses: BUTR/workflows/.github/workflows/release-steam.yml@master
with:
workshop_id: 2859238197
mod_id: Bannerlord.MBOptionScreen
mod_description: ${{ needs.build-module.outputs.mod_description }}
artifact_name: bannerlord
secrets:
STEAM_LOGIN: ${{ secrets.STEAM_WORKSHOP_LOGIN }}
STEAM_PASSWORD: ${{ secrets.STEAM_WORKSHOP_PASSWORD }}
STEAM_AUTH_CODE: ${{ secrets.STEAM_WORKSHOP_AUTH_CODE }}
###########################
# GITHUB #
###########################
publish-on-github:
needs: ["build-module"]
uses: BUTR/workflows/.github/workflows/release-github.yml@master
with:
mod_id: Bannerlord.MBOptionScreen
mod_version: ${{ needs.build-module.outputs.mod_version }}
mod_description: ${{ needs.build-module.outputs.mod_description }}
artifact_name: bannerlord