-
Notifications
You must be signed in to change notification settings - Fork 573
86 lines (73 loc) · 2.49 KB
/
ci.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
name: CI
on:
workflow_dispatch: {}
push:
branches:
- master
tags:
- v[0-9]+.[0-9]+.[0-9]+*
pull_request:
branches:
- master
jobs:
build:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
2.1.x
3.1.x
5.0.x
6.0.x
- name: Install tools
run: |
dotnet tool restore
- name: Build Release
run: dotnet build src -c Release /p:ContinuousIntegrationBuild=true
- name: Build Debug
run: dotnet build src -c Debug
- name: Start stripe-mock
run: docker run -d -p 12111-12112:12111-12112 stripe/stripe-mock && sleep 5
- name: Run test suite
run: dotnet test --no-build src/StripeTests/StripeTests.csproj -c Release
- name: Collect coverage
run: dotnet test --no-build -c Debug -f netcoreapp3.1 src/StripeTests/StripeTests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:ExcludeByAttribute=CompilerGenerated
- name: Send code coverage report to coveralls.io
run: |
# Secure env vars are not available on all branches, so make sure the
# token is available before invoking Coveralls.
if [ ! -z "${COVERALLS_REPO_TOKEN}" ];
then
dotnet tool run csmacnz.Coveralls --opencover -i src/StripeTests/coverage.netcoreapp3.1.opencover.xml --useRelativePaths
fi
env:
CI_NAME: github-actions
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
- name: Pack
run: dotnet pack src -c Release --no-build --output nuget
- name: 'Upload Artifact'
uses: actions/upload-artifact@v2
with:
name: nuget
path: nuget/
publish:
name: Publish
if: (((github.event_name == 'push') || (github.event_name == 'workflow_dispatch')) && startsWith(github.ref, 'refs/tags/v') && endsWith(github.actor, '-stripe'))
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v2
with:
name: nuget
path: nuget
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Publish NuGet packages to NuGet
run: dotnet nuget push nuget/*.nupkg --api-key ${{ secrets.NUGET_KEY }} --source "nuget.org"