-
Notifications
You must be signed in to change notification settings - Fork 2
132 lines (110 loc) · 4.37 KB
/
main.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
# ITNOA
# Based on https://github.com/flcdrg/VsShowMissing
name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
DOTNET_VERSION: '6.0.412' # The .NET SDK version to use
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build-and-test:
name: build-and-test-${{matrix.os}}
strategy:
matrix:
include:
- solution: BSN.IpTables.Api.sln
os: [windows-2022, ubuntu-latest]
artifact: VS2022
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}
outputs:
GitAssemblyInformationalVersion: ${{ steps.gitversion.outputs.GitAssemblyInformationalVersion }}
GitBuildVersion: ${{ steps.gitversion.outputs.GitBuildVersion }}
GitBuildVersionSimple: ${{ steps.gitversion.outputs.GitBuildVersionSimple }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install dependencies
run: dotnet restore
- name: Build
id: build
run: dotnet build --configuration Release --no-restore
- name: gitversion
id: gitversion
run: |
dir env:
echo "::set-output name=GitAssemblyInformationalVersion::$($env:GitAssemblyInformationalVersion)"
echo "::set-output name=GitBuildVersion::$($env:GitBuildVersion)"
echo "::set-output name=GitBuildVersionSimple::$($env:GitBuildVersionSimple)"
# set pr number, if it's a pr build
- name: set pr build number
id: PRNUMBER
if: ${{ github.event_name == 'pull_request' }}
uses: kkak10/[email protected]
# set report file and title
- name: Set Test Title
run: |
if ${{ github.event_name == 'pull_request' }}
then
echo "title=Test Run for PR #${{steps.PRNUMBER.outputs.pr}} (${{github.run_number}})" >> $GITHUB_ENV
echo "file_name=TestReport.${{steps.PRNUMBER.outputs.pr}}.${{github.run_number}}.md" >> $GITHUB_ENV
else
echo "title=Test Run ${{github.run_number}}" >> $GITHUB_ENV
echo "file_name=TestReport.${{github.run_number}}.md" >> $GITHUB_ENV
fi
# run tests with built project
- name: Test
run: |
dotnet test --no-restore --verbosity normal --logger trx --results-directory Build/artifacts
dotnet test --no-restore --no-build --configuration $config --logger:"liquid.md;LogFileName=${{github.workspace}}/${{env.file_name}};Title=${{env.title}};"
- name: Upload a Build Artifact
uses: actions/upload-artifact@v3
with:
# Artifact name
name: Test Results
# A file, directory or wildcard pattern that describes what to upload
path: 'Build/artifacts/*.xml'
# add report as PR comment (if PR)
- name: comment PR
uses: machine-learning-apps/pr-comment@master
if: ${{ github.event_name == 'pull_request' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
path: ${{env.file_name}}
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJson(steps) }}
run: echo "$STEPS_CONTEXT"
update_release_draft:
name: Update release draft
runs-on: ubuntu-latest
needs: [build-and-test]
env:
GitAssemblyInformationalVersion: ${{ needs.build.outputs.GitAssemblyInformationalVersion }}
GitBuildVersion: ${{ needs.build.outputs.GitBuildVersion }}
GitBuildVersionSimple: ${{ needs.build.outputs.GitBuildVersionSimple }}
if: github.ref == 'refs/heads/main' # Running this job only for master branch
steps:
- uses: actions/checkout@v3
- uses: release-drafter/release-drafter@v5
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: ${{ needs.build.outputs.GitBuildVersionSimple }}