-
Notifications
You must be signed in to change notification settings - Fork 5
116 lines (93 loc) · 3.83 KB
/
release.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
name: release
on:
release:
types: [published]
jobs:
run-tests:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet: [
{ framework: netcoreapp3.1, version: 3.1.x },
{ framework: net5.0, version: 5.0.x },
{ framework: net6.0, version: 6.0.x },
]
name: ${{ matrix.dotnet.framework }} – run tests
steps:
- uses: actions/checkout@v2
- name: Setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ matrix.dotnet.version }}
- name: Run tests
run: |
dotnet test --configuration Release --framework ${{ matrix.dotnet.framework }} ./src/Dodo.HttpClient.ResiliencePolicies.Tests/Dodo.HttpClient.ResiliencePolicies.Tests.csproj /p:Framework=${{ matrix.dotnet.framework }}
build-and-publish:
name: Build and publish library to NuGet
runs-on: ubuntu-latest
needs: run-tests
steps:
- uses: actions/checkout@v2
- name: Extract version
id: extract-version
run: |
version=$(cat ./src/Dodo.HttpClient.ResiliencePolicies/Dodo.HttpClient.ResiliencePolicies.csproj | grep "<VersionPrefix>" | sed -e "s/ *<\/*VersionPrefix>//g")
echo "Package version: $version"
if [ -z "${version// }" ]; then exit 1; fi
echo "::set-output name=package_version::$version"
- name: Extract package suffix from tag
id: extract-version-suffix
run: |
ref=${{ github.ref }}
prerelease=${{ github.event.release.prerelease }}
version=${{ steps.extract-version.outputs.package_version }}
shopt -s extglob
suffix=${ref##*/v"${version}"?(-)}
echo "Version suffix: $suffix"
if [ -z "${suffix// }" ] && [ $prerelease == "true" ]; then exit 1; fi
echo "::set-output name=version_suffix::$suffix"
- name: Setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Build and publish library to NuGet
run: |
dotnet build --configuration Release ./src/Dodo.HttpClient.ResiliencePolicies/Dodo.HttpClient.ResiliencePolicies.csproj
dotnet pack --no-restore --no-build --configuration Release --version-suffix "${{ steps.extract-version-suffix.outputs.version_suffix }}" --output out/ ./src/Dodo.HttpClient.ResiliencePolicies/Dodo.HttpClient.ResiliencePolicies.csproj
dotnet nuget push out/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
- uses: actions/upload-artifact@v2
with:
name: NuGet package
path: out/
upload-release-assets:
name: Upload release assets
runs-on: ubuntu-latest
needs: build-and-publish
steps:
- uses: actions/download-artifact@v2
with:
name: NuGet package
path: out
- name: Get package
id: get-package
run: |
echo "::set-output name=package::$(ls out/ | grep '\.nupkg')"
echo "::set-output name=symbols::$(ls out/ | grep '\.snupkg')"
- name: Upload package asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./out/${{ steps.get-package.outputs.package }}
asset_name: ${{ steps.get-package.outputs.package }}
asset_content_type: application/zip
- name: Upload symbols asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./out/${{ steps.get-package.outputs.symbols }}
asset_name: ${{ steps.get-package.outputs.symbols }}
asset_content_type: application/zip