-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (91 loc) · 2.75 KB
/
build-and-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
name: 'Build, test and publish packages'
on:
push:
tags:
- v*.*
pull_request:
tags:
- v*.*
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
# Set the build number in MinVer.
MINVERBUILDMETADATA: build.${{github.run_number}}
jobs:
build:
name: Build-${{matrix.os}}
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- name: 'Checkout'
uses: actions/checkout@v2
- name: 'Setup .NET Core'
uses: actions/[email protected]
with:
dotnet-version: '6.0.x'
- uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: 'Install dependencies'
run: dotnet restore
- name: 'Build'
run: dotnet build --configuration Release --no-restore
- name: 'Test'
run: dotnet test --no-restore --verbosity normal
- name: 'Pack'
run: dotnet pack --no-build --configuration Release src/Delobytes.NetCore.EntityReportGeneration.csproj --output distr
- name: 'Upload package'
uses: actions/[email protected]
with:
name: ${{matrix.os}}
path: "distr"
if-no-files-found: error
retention-days: 1
check-tag:
name: 'Check tag'
runs-on: ubuntu-latest
outputs:
tagName: ${{ steps.tagName.outputs.tag }}
steps:
- name: 'Get tag'
id: tag
uses: dawidd6/action-get-tag@v1
with:
strip_v: true
- name: 'Fail if no tag'
if: ${{ steps.tag.outputs.tag == '' }}
run: exit 1
push-github-package:
name: 'Push GitHub Package'
needs: [build, check-tag]
if: success()
runs-on: ubuntu-latest
steps:
- name: 'Download Artefact'
uses: actions/[email protected]
with:
name: 'ubuntu-latest'
- name: 'Dotnet NuGet Push'
run: |
dotnet nuget push *.nupkg --source https://nuget.pkg.github.com/Delobytes.NetCore.EntityReportGeneration/index.json --skip-duplicate --api-key ${{ github.token }}
push-nuget-package:
name: 'Push NuGet Package'
needs: [build, check-tag]
runs-on: ubuntu-latest
steps:
- name: 'Download Artefact'
uses: actions/[email protected]
with:
name: 'ubuntu-latest'
- name: 'Dotnet NuGet Push'
run: |
dotnet nuget push *.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_API_KEY}}