-
Notifications
You must be signed in to change notification settings - Fork 46
246 lines (211 loc) · 8.8 KB
/
msbuild.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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
name: MSBuild
concurrency:
group: "${{ github.workflow }}:${{ github.event_name }}:${{ github.head_ref || github.ref_name }}"
cancel-in-progress: true
on:
pull_request_target:
branches: [ master ]
types: [ opened, synchronize, labeled ]
push:
tags:
- '*'
merge_group:
types: [ checks_requested ]
env:
# Path to the solution file relative to the root of the project.
SOLUTION_FILE_PATH: ./src/EasyEPlanner.sln
# Configuration type to build.
# You can convert this to a build matrix if you need coverage of multiple configuration types.
# https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
BUILD_CONFIGURATION: Release
jobs:
check:
name: Check
runs-on: windows-latest
outputs:
result: ${{ steps.pass.outputs.result }}
steps:
- id: is_organization_member
run: >
$response = (curl -L
-w '%{http_code}'
-H "Accept: application/vnd.github+json"
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"
-H "X-GitHub-Api-Version: 2022-11-28"
https://api.github.com/orgs/savushkin-r-d/members/${{ github.event.sender.login }})
echo "response=$response" >> $env:GITHUB_OUTPUT
continue-on-error: true
# --On linux--
# run: |
# response=`curl -L \
# ... \
# ...`
# echo "response=$response" >> $GITHUB_OUTPUT
- id: pass
if: >-
(github.event.action == 'labeled' && github.event.label.name == 'safe to test') ||
((github.event.action == 'synchronize' || github.event.action == 'opened') && steps.is_organization_member.outputs.response == '204') ||
github.event_name == 'merge_group' ||
startsWith(github.ref, 'refs/tags/')
run: echo "result=success" >> $env:GITHUB_OUTPUT
# On linux: >> $GITHUB_OUTPUT
- name: exit with failure
if: steps.pass.outputs.result != 'success'
run: exit 1
build:
name: Build, analyze and test
runs-on: windows-latest
needs: check
if: needs.check.outputs.result == 'success'
steps:
- name: Set Timezone
shell: powershell
run: Set-Timezone -Id 'Belarus Standard Time'
- uses: actions/checkout@v4
with:
submodules: 'recursive'
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v4
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: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Install dotnet-coverage
shell: powershell
run: |
dotnet tool install --global dotnet-coverage
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Restore NuGet packages
working-directory: ${{env.GITHUB_WORKSPACE}}
run: nuget restore ${{env.SOLUTION_FILE_PATH}}
- name: Download fetch.exe and EPLAN API binaries, copy it to the .net specific path
run: |
curl -L "https://github.com/gruntwork-io/fetch/releases/download/v0.4.2/fetch_windows_amd64.exe" -O
md src/bin/${{env.BUILD_CONFIGURATION}}
./fetch_windows_amd64.exe --github-oauth-token="${{ secrets.EPLAN_API_BIN }}" --repo="https://github.com/savushkin-r-d/EPLAN-API-bin" --tag="2.9" --release-asset=".*" "src/bin/${{env.BUILD_CONFIGURATION}}"
md submodule/EplanIdleTimeModule/EplanIdleTimeModule/bin/${{env.BUILD_CONFIGURATION}}
cp src/bin/${{env.BUILD_CONFIGURATION}}/* submodule/EplanIdleTimeModule/EplanIdleTimeModule/bin/${{env.BUILD_CONFIGURATION}}
- name: Sonar scanner begin
working-directory: ${{env.GITHUB_WORKSPACE}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
PULL_REQUEST_DATA: /d:sonar.pullrequest.key=${{ github.event.pull_request.number }} /d:sonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} /d:sonar.scm.revision=${{ github.event.pull_request.head.sha }}
run: .\.sonar\scanner\dotnet-sonarscanner begin /k:"savushkin-r-d_EasyEPLANner" /o:"savushkin-r-d" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths="EasyEplanner.Tests/coverage.xml" ${{ github.event_name == 'pull_request_target' && env.PULL_REQUEST_DATA || '' }}
- name: Build
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}}
- name: Test
working-directory: EasyEplanner.Tests
run: dotnet test --configuration ${{env.BUILD_CONFIGURATION}} --collect "Code Coverage"
- name: Test coverage merge
working-directory: EasyEplanner.Tests
run: dotnet-coverage merge -o coverage.xml -f xml -r *.coverage
- name: Sonar scanner end
working-directory: ${{env.GITHUB_WORKSPACE}}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
- name: Download sys_base_objects_description
working-directory: ${{env.GITHUB_WORKSPACE}}
run: |
md /objects_description
./fetch_windows_amd64.exe --github-oauth-token="${{ secrets.EPLAN_API_BIN }}" --repo="https://github.com/savushkin-r-d/ptusa-Lua-dairy-system" --ref="master" "/objects_description"
md src/bin/${{env.BUILD_CONFIGURATION}}/Lua/BaseObjectsDescriptionFiles
copy /objects_description/EasyEplannerObjectsDescription/sys_base_objects_description.lua src/bin/${{env.BUILD_CONFIGURATION}}/Lua/BaseObjectsDescriptionFiles/sys_base_objects_description.lua
- name: Delete extra files
working-directory: src/bin/${{env.BUILD_CONFIGURATION}}
run: |
del *.pdb
del Eplan.EplApi.*
del EplanBaseNetu.dll
del Microsoft.mshtml.dll
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: EasyEPLANner
path: src/bin/${{env.BUILD_CONFIGURATION}}
release:
if: startsWith(github.ref, 'refs/tags/')
name: Release
runs-on: windows-latest
needs: build
steps:
- name: Set Timezone
shell: powershell
run: Set-Timezone -Id 'Belarus Standard Time'
- id: get-date
run: echo "date=$(date +'%d.%m.%Y')" >> $env:GITHUB_OUTPUT
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: EasyEPLANner
path: ./bin
- name: Get assembly version
id: assembly-version
shell: powershell
working-directory: ./bin
run: |
$version=[System.Reflection.Assembly]::LoadFrom("./EPLAN.EplAddin.EasyEPlanner.dll").GetName().Version.ToString()
echo "version=$version" >> $env:GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
path: ./EasyEPLANner
submodules: 'recursive'
fetch-depth: 0
- name: Generate ChangeLog
id: change-log
shell: powershell
working-directory: ./EasyEPLANner
run: |
echo "changelog<<^D" >> $env:GITHUB_OUTPUT
$index = 1
$logs = (git log --pretty=tformat:"%b" ((git tag --sort=committerdate | Select-Object -Last 2) -join "..")) -join "`n"
foreach ($match in [Regex]::Matches($logs, '```ChangeLog\n?([\w\W]*?)\n?```')) {
echo "$index. $($match.Groups[1].Value.Trim().TrimEnd(';,.'))." >> $env:GITHUB_OUTPUT
$index = $index + 1
}
echo ^D >> $env:GITHUB_OUTPUT
- name: Pack
shell: powershell
working-directory: ./bin
run: Compress-Archive -Path .\* -Update -DestinationPath EasyEPLANner.zip
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ github.ref_name }}
body: |
**Список изменений**:
```ChangeLog
Обновление от ${{ steps.get-date.outputs.date }}. Версия надстройки - ${{ steps.assembly-version.outputs.version }}.
${{ steps.change-log.outputs.changelog }}
```
files: |
./bin/EasyEPLANner.zip
generate_release_notes: true
draft: false
prerelease: false