-
Notifications
You must be signed in to change notification settings - Fork 9
168 lines (163 loc) · 6.46 KB
/
test_and_build.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
name: PugSharp_test_and_build
on:
push:
branches:
- main
- develop
tags: [ v**]
paths:
- '**'
- '!README.md'
- '!Makefile'
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
- develop
- 'feature/**'
tags: [ v**]
paths:
- '**'
- '!README.md'
- '!Makefile'
env:
DOTNET_RUNTIME_URL: https://download.visualstudio.microsoft.com/download/pr/dc2c0a53-85a8-4fda-a283-fa28adb5fbe2/8ccade5bc400a5bb40cd9240f003b45c/aspnetcore-runtime-7.0.11-linux-x64.tar.gz
DOTNET_RUNTIME_VERSION: 7.0.11
jobs:
test_linux_x64:
runs-on: ubuntu-latest
if: ${{ !startsWith( github.event.pull_request.head.label, 'lan2play-weblate' ) }}
steps:
- name : machine echo github
env : { CONTENT : "${{ toJson(github) }}" }
run : "echo $CONTENT"
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ./sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v3
with:
path: ./sonar/scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: pwsh
run: |
New-Item -Path ./sonar/scanner -ItemType Directory
dotnet tool install dotnet-sonarscanner --tool-path ./sonar/scanner
- name: Update SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'false'
shell: pwsh
run: |
dotnet tool update dotnet-sonarscanner --tool-path ./sonar/scanner
- name: Restore dependencies
run: dotnet restore
- name: start sonarscanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./sonar/scanner/dotnet-sonarscanner begin /k:"Lan2Play_PugSharp" /o:"lan2play" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="./**/*.opencover.xml"
- name: dotnet build
run: dotnet build --no-restore
- name: dotnet test
run: dotnet test --no-build --no-restore --collect "XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
- name: stop sonarscanner
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
build_linux_x64:
runs-on: ubuntu-latest
if: ${{ !startsWith( github.event.pull_request.head.label, 'lan2play-weblate' ) }}
needs:
- test_linux_x64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: set Version
if: ${{ (startsWith(github.ref, 'refs/tags/v')) }}
run: echo "PUGSHARPNETVER=$(echo ${GITHUB_REF} | sed 's|refs/heads/||g' | sed 's|refs/tags/v||g' )" >> $GITHUB_ENV
- name: set Version
if: ${{ !(startsWith(github.ref, 'refs/tags/v')) }}
run: echo "PUGSHARPNETVER=0.0.1-alpha" >> $GITHUB_ENV
- name: set Pugsharp version
run: sed -i "s|0.0.1|$PUGSHARPNETVER|g" PugSharp/PugSharp.cs
- name: Build Pugsharp
run: dotnet publish
- name: cleanup build
run: rm -rf PugSharp/bin/Debug/net7.0/publish/CounterStrikeSharp.API.dll
- name: prepare package structure
run: mkdir -p packagebuild/addons/counterstrikesharp/plugins/PugSharp
- name: copy included counterstrikesharp
run: cp -rf PugSharp/counterstrikesharp packagebuild/addons/
- name: copy included counterstrikesharp vdf
run: cp -rf PugSharp/metamod packagebuild/addons/metamod
- name: copy package content
run: cp -rf PugSharp/bin/Debug/net7.0/publish/* packagebuild/addons/counterstrikesharp/plugins/PugSharp
- name: Add dotnet runtime
run: |
mkdir -p packagebuild/addons/counterstrikesharp/dotnet
curl -s -L $DOTNET_RUNTIME_URL \
| tar xvz -C packagebuild/addons/counterstrikesharp/dotnet
mv packagebuild/addons/counterstrikesharp/dotnet/shared/Microsoft.NETCore.App/$DOTNET_RUNTIME_VERSION/* packagebuild/addons/counterstrikesharp/dotnet/shared/Microsoft.NETCore.App/
- name: build package
run: zip -r PugSharp_$PUGSHARPNETVER.zip addons
working-directory: ./packagebuild
- name: move package
run: mv PugSharp_$PUGSHARPNETVER.zip ../
working-directory: ./packagebuild
- name: replace version variable in meta files
run: sed -i "s|%%VERSION%%|$PUGSHARPNETVER|g" ./release.json;
- name: replace CounterStrikeSharpVersion variable in meta files
run: sed -i "s|%%COUNTERSTRIKESHARPVERSION%%|0.0.1|g" ./release.json;
- name: replace CS2VERSION variable in meta files
run: sed -i "s|%%CS2VERSION%%|1.39.6.5/13965 9842|g" ./release.json;
- name: replace METAMODVERSION variable in meta files
run: sed -i "s|%%METAMODVERSION%%|2.0 - 1256|g" ./release.json;
- name: Release
if: ${{ (startsWith(github.ref, 'refs/tags/v')) && !(contains(github.ref, '-beta')) }}
uses: softprops/action-gh-release@v1
with:
files: |
./release.json
./packagebuild/PugSharp_*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: pre Release
if: ${{ (startsWith(github.ref, 'refs/tags/v')) && (contains(github.ref, '-beta')) }}
uses: softprops/action-gh-release@v1
with:
prerelease: true
files: |
./release.json
./PugSharp_*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: upload pre - pre release
uses: actions/upload-artifact@v3
with:
name: latest_alpha
path: |
./release.json
./PugSharp_*.zip
retention-days: 10