-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (119 loc) · 5.61 KB
/
Copy pathrelease.yml
File metadata and controls
140 lines (119 loc) · 5.61 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
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
133
134
135
136
137
138
139
140
name: Release
on:
# Triggers the workflow on push or pull request events but only for SEMVER tags that start with 'v'
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+-?*"
env:
NUGET_FEED_URL: https://api.nuget.org/v3/index.json
COVERAGE_GIST_ID: d8e43c117fc1d20ffb8f3e9f170ee1c4
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
packages: write
contents: write
steps:
- name: report
run: |
echo github.actor:${{ github.actor }}
echo github.job:${{ github.job }}
echo github.ref:${{ github.ref }}
echo github.ref_name:${{ github.ref_name }}
echo github.ref_protected:${{ github.ref_protected }}
echo github.ref_type:${{ github.ref_type }}
echo github.path:${{ github.path }}
echo github.repository:${{ github.repository }}
echo github.repository_owner:${{ github.repository_owner }}
echo github.repositoryUrl:${{ github.repositoryUrl }}
echo github.run_id:${{ github.run_id }}
echo github.run_number:${{ github.run_number }}
echo github.triggering_actor:${{ github.triggering_actor }}
echo github.workflow:${{ github.workflow }}
echo github.workspace:${{ github.workspace }}
- name: Clone source
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set VERSION variable from tag
run: |
echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
echo Build version ${{ env.VERSION }}
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release /p:Version=${{ env.VERSION }}
- name: Test
run: |
dotnet test --no-restore --no-build --filter Category!=Integration --verbosity normal --configuration Release -p:CollectCoverage=true -p:CoverletOutput=TestResults/ -p:CoverletOutputFormat=opencover
- name: Create packages
run: |
dotnet pack --no-restore --no-build --configuration Release /p:Version=${{ env.VERSION }}
- name: Get total code coverage
uses: simon-k/dotnet-code-coverage-badge@v1.0.0
id: code-coverage
with:
path: Tests/TestResults/coverage.opencover.xml
- name: Print code coverage
run: |
echo "{\"schemaVersion\": 1, \"label\": \"coverage\", \"message\": \"${{steps.code-coverage.outputs.percentage}}%\", \"color\": \"green\"}" > coverage.shields.json
- name: upload code coverage badge data
uses: exuanbo/actions-deploy-gist@v1
with:
token: ${{ secrets.GIST_TOKEN }}
gist_id: d8e43c117fc1d20ffb8f3e9f170ee1c4
file_path: coverage.shields.json
file_type: text
- name: Create Github release
uses: actions/create-release@v1
id: create-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: false
prerelease: false
release_name: v${{ env.VERSION }}
tag_name: ${{ github.ref }}
body_path: CHANGELOG.md
- name: upload shields coverage json
id: upload-shields-coverage-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: coverage.shields.json
asset_name: coverage.shields.json
asset_content_type: application/json
- name: upload Primitives nuget package
id: upload-primitives-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: Primitives/bin/Release/PRI.Messaging.Primitives.${{ env.VERSION }}.nupkg
asset_name: PRI.Messaging.Primitives.${{ env.VERSION }}.nupkg
asset_content_type: application/octet-stream
- name: upload Patterns nuget package
id: upload-patterns-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: Patterns/bin/Release/PRI.Messaging.Patterns.${{ env.VERSION }}.nupkg
asset_name: PRI.Messaging.Patterns.${{ env.VERSION }}.nupkg
asset_content_type: application/octet-stream
- name: Publish Nuget to Github Packages
run: |
dotnet nuget add source --username ${{ github.triggering_actor }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
dotnet nuget push Primitives/bin/Release/PRI.Messaging.Primitives.${{ env.VERSION }}.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "github"
dotnet nuget push Patterns/bin/Release/PRI.Messaging.Patterns.${{ env.VERSION }}.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "github"
dotnet nuget push Primitives/bin/Release/PRI.Messaging.Primitives.${{ env.VERSION }}.nupkg -k ${{ secrets.NUGET_API_KEY }} -s $NUGET_FEED_URL
dotnet nuget push Patterns/bin/Release/PRI.Messaging.Patterns.${{ env.VERSION }}.nupkg -k ${{ secrets.NUGET_API_KEY }} -s $NUGET_FEED_URL