-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (57 loc) · 1.77 KB
/
master.yml
File metadata and controls
65 lines (57 loc) · 1.77 KB
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
name: master
on:
push:
branches:
- master
jobs:
Build:
env:
BUILD_CONFIG: 'Release'
SOLUTION: 'ServiceInjection.sln'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore $SOLUTION
- name: Build
run: dotnet build $SOLUTION --configuration Release
- name: Run tests
run: dotnet test --configuration $BUILD_CONFIG --no-restore --no-build --verbosity normal
Tag-Version:
needs: Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get last tag
id: lasttag
run: echo "LAST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_ENV
- name: Check if version was changed
id: check_file
run: |
if git diff --name-only ${{ env.LAST_TAG }} ${{ github.sha }} | grep -q 'Directory.Build.props'; then
echo "FILE_CHANGED=true" >> $GITHUB_ENV
else
echo "FILE_CHANGED=false" >> $GITHUB_ENV
fi
- name: Extract version and create tag
if: env.FILE_CHANGED == 'true'
run: |
$xml = [xml](Get-Content Directory.Build.props)
$VERSION_PREFIX = $xml.Project.PropertyGroup.VersionPrefix
$VERSION_SUFFIX = $xml.Project.PropertyGroup.VersionSuffix
$FULL_VERSION = "v$VERSION_PREFIX"
if (-not [string]::IsNullOrEmpty($VERSION_SUFFIX)) {
$FULL_VERSION += "-$VERSION_SUFFIX"
}
git tag $FULL_VERSION
git push origin --tags
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}