-
-
Notifications
You must be signed in to change notification settings - Fork 33
93 lines (78 loc) · 2.74 KB
/
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
# build.yml v1.6
# 1.6:
# - Use --getProperty:Version instead of Nito.ProjProps.
# - Updates: acitons/checkout@v4
# 1.5:
# - Use bash syntax
# - Avoid set-output
# - Updates: actions/cache@v3, actions/checkout@v3, actions/upload-artifact@v3, codecov/codecov-action@v3, WyriHaximus/github-action-get-previous-tag@v1
# - Work around SDK bug (https://github.com/dotnet/sdk/issues/17461)
# - Use pre-release ProjProps.
# 1.4 - Avoid set-env.
# 1.3 - Include tag workflow in this file.
# 1.2 - Define DOTNET_SKIP_FIRST_TIME_EXPERIENCE/NUGET_XMLDOC_MODE.
# 1.1 - Use actions/cache@v2.
# 1.0 - Initial release.
name: Build
on:
- push
env:
CI: 'true'
DOTNET_CLI_TELEMETRY_OPTOUT: 'true'
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 'true'
NUGET_XMLDOC_MODE: 'skip'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Dump context
env:
CONTEXT: ${{ toJson(github) }}
run: |
echo "Context is available above"
- name: Determine cache fallbacks
if: github.event_name != 'push'
id: cache_fallbacks
run: |
echo "name=nuget::nuget-" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required by WyriHaximus/github-action-get-previous-tag@v1
- name: Cache nuget
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: nuget-${{ hashFiles('**/*.csproj') }}-${{ hashFiles('**/*.props') }}
restore-keys: ${{ steps.cache_fallbacks.outputs.nuget }}
- name: Get existing tag
id: existingtag
uses: WyriHaximus/github-action-get-previous-tag@v1
continue-on-error: true
- name: Get current version
run: |
echo "NEWTAG=v$(dotnet build $(find src -name *.csproj | head --lines=1) --getProperty:Version)"
echo "NEWTAG=v$(dotnet build $(find src -name *.csproj | head --lines=1) --getProperty:Version)" >> $GITHUB_ENV
- name: Build
run: |
dotnet build --configuration Release
dotnet test --configuration Release --no-build --collect:"XPlat Code Coverage"
dotnet pack --configuration Release --no-build
- name: Upload package artifacts
uses: actions/upload-artifact@v3
with:
name: nuget-packages
path: |
**/*.nupkg
**/*.snupkg
- name: Publish code coverage
uses: codecov/codecov-action@v3
- name: Publish packages
if: env.NEWTAG != steps.existingtag.outputs.tag
run: |
dotnet nuget push **/*.nupkg --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }}
- name: Create tag
if: env.NEWTAG != steps.existingtag.outputs.tag
run: |
git tag ${{ env.NEWTAG }}
git push --tags