@@ -2,32 +2,131 @@ name: dotnet
22
33on :
44 push :
5- branches : [ master ]
5+ branches : [master]
6+ tags : ["*"]
67 pull_request :
7- branches : [ master ]
8+ branches : [master]
89
910jobs :
1011 build :
1112 runs-on : ubuntu-latest
1213
14+ outputs :
15+ fullSemVer : ${{ steps.gitversion.outputs.fullSemVer }}
16+
1317 steps :
14- - uses : actions/checkout@v2
18+ - uses : actions/checkout@v2
19+ with :
20+ fetch-depth : 0
21+
22+ -
uses :
gittools/actions/gitversion/[email protected] 23+ with :
24+ versionSpec : " 5.x"
25+
26+ - id : gitversion
27+ uses :
gittools/actions/gitversion/[email protected] 28+
29+ - uses : actions/setup-dotnet@v1
30+ with :
31+ dotnet-version : 2.1.401
32+
33+ - uses : actions/cache@v2
34+ env :
35+ NUGET_PACKAGES : ${{ github.workspace }}/.nuget/packages
36+ with :
37+ path : ~/.nuget/packages
38+ key : ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
39+ restore-keys : ${{ runner.os }}-nuget-
40+
41+ - run : dotnet restore
1542
16- - name : Setup .NET Core
17- uses : actions/setup-dotnet@v1
18- with :
19- dotnet-version : 2.1.401
43+ - run : dotnet build --configuration Release --no-restore
2044
21- - name : Install dependencies
22- run : dotnet restore
45+ - run : |
46+ dotnet test \
47+ --configuration Release \
48+ --no-build \
49+ --no-restore \
50+ -p:CollectCoverage=true \
51+ -p:CoverletOutputFormat=opencover \
52+ -p:Exclude="[JsonLD.Test*]*"
2353
24- - name : Build
25- run : dotnet build --configuration Release --no-restore
54+ - name : Codecov
55+ env :
56+ CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
57+ run : bash <(curl -s https://codecov.io/bash)
58+
59+ - run : |
60+ dotnet pack \
61+ --include-source \
62+ --configuration Release \
63+ --no-build \
64+ --no-restore \
65+ -p:PackageVersion="${{ steps.gitversion.outputs.fullSemVer }}" \
66+ src/json-ld.net/json-ld.net.csproj \
67+ --output ${{ github.workspace }}/nugets/
68+
69+ - uses : actions/upload-artifact@v2
70+ with :
71+ name : nugets
72+ path : nugets
73+
74+ nuget-push-dev :
75+ runs-on : ubuntu-latest
76+ if : github.ref == 'refs/heads/master'
77+ needs : build
78+
79+ steps :
80+ - name : download artifact
81+ uses : actions/download-artifact@v2
82+ with :
83+ name : nugets
2684
27- - name : Test
28- run : dotnet test -c Release /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[JsonLD.Test*]*"
85+ - name : setup dotnet
86+ uses : actions/setup-dotnet@v1
87+ with :
88+ dotnet-version : 3.1
89+ source-url : https://nuget.pkg.github.com/linked-data-dotnet/index.json
90+ env :
91+ NUGET_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
92+
93+ - name : nuget push
94+ run : dotnet nuget push "*.nupkg" --skip-duplicate --api-key ${{ secrets.GITHUB_TOKEN }}
95+
96+ nuget-push-prod :
97+ runs-on : ubuntu-latest
98+ if : startsWith(github.ref, 'refs/tags/')
99+ needs : build
100+
101+ steps :
102+ - uses : actions/download-artifact@v2
103+ with :
104+ name : nugets
105+
106+ - uses : actions/setup-dotnet@v1
107+ with :
108+ dotnet-version : 2.1.401
109+ source-url : https://api.nuget.org/v3/index.json
110+ env :
111+ NUGET_AUTH_TOKEN : ${{ secrets.NUGET_API_KEY }}
112+
113+ - run : dotnet nuget push nugets/*.nupkg --skip-duplicate
114+
115+ release-artifacts :
116+ runs-on : ubuntu-latest
117+ needs : build
118+ if : startsWith(github.ref, 'refs/tags/')
119+
120+ steps :
121+ - uses : actions/download-artifact@v1
122+ with :
123+ name : nugets
29124
30- - name : Codecov
31- env :
32- CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
33- run : bash <(curl -s https://codecov.io/bash)
125+ - name : Upload to stable release
126+ uses : svenstaro/upload-release-action@v1-release
127+ with :
128+ repo_token : ${{ secrets.GITHUB_TOKEN }}
129+ file : nugets
130+ asset_name : json-ld.net
131+ tag : ${{ github.ref }}
132+ overwrite : true
0 commit comments