44 push :
55 pull_request :
66 branches : [ main ]
7+ release :
8+ types :
9+ - published
10+
11+ env :
12+ DOTNET_SKIP_FIRST_TIME_EXPERIENCE : true
13+ DOTNET_CLI_TELEMETRY_OPTOUT : true
14+
15+ VSTEST_CONNECTION_TIMEOUT : 900
16+ SOLUTION_NAME : GeoJSON.Text
17+
18+ # Project name to pack and publish
19+ PROJECT_NAME : GeoJSON.Text
20+
21+ # Official NuGet Feed settings
22+ NUGET_FEED : https://api.nuget.org/v3/index.json
23+ NUGET_KEY : ${{ secrets.NUGET_KEY }}
724
825jobs :
9- Build :
26+ build :
1027
1128 name : ' Build and Test'
1229 runs-on : ubuntu-latest
13- defaults :
14- run :
15- working-directory : ./src
16-
17- env :
18- VSTEST_CONNECTION_TIMEOUT : 900
19-
30+
2031 steps :
2132 - uses : actions/checkout@v2
22- - name : Setup .NET Core
33+ - name : Setup .NET
2334 uses : actions/setup-dotnet@v1
2435 with :
2536 dotnet-version : |
2637 3.1.x
2738 5.0.x
2839 6.0.x
2940 - name : Install dependencies
30- run : dotnet restore
41+ run : dotnet restore src/${{ env.PROJECT_NAME }}.sln
3142 - name : Build solution
32- run : dotnet build -c Release --no-restore /p:Version=1.2.3.4
43+ run : dotnet build src/${{ env.PROJECT_NAME }}.sln -c Release --no-restore
3344 - name : Test
34- run : dotnet test -c Release --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=../coverage/
45+ run : dotnet test src/${{ env.PROJECT_NAME }}.sln -c Release --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=../coverage/
3546 - uses : codecov/codecov-action@v2
3647 if : ${{ github.event_name == 'push' }}
3748 with :
3849 token : ${{ secrets.CODECOV_TOKEN }}
3950 directory : src/coverage
4051 flags : unittests
41-
42-
52+ - name : Upload Artifact
53+ uses : actions/upload-artifact@v2
54+ with :
55+ name : nupkg
56+ path : src/${{ env.PROJECT_NAME }}/bin/Release/*.nupkg
57+
58+ deploy :
59+ name : ' Deploy to Nuget'
60+ if : github.event_name == 'release'
61+ needs : build
62+ runs-on : ubuntu-latest
63+
64+ steps :
65+ - uses : actions/checkout@v2
66+ - name : Setup .NET Core
67+ uses : actions/setup-dotnet@v1
68+ with :
69+ dotnet-version : |
70+ 3.1.x
71+ 5.0.x
72+ 6.0.x
73+ - name : Create Release NuGet package
74+ run : |
75+ arrTag=(${GITHUB_REF//\// })
76+ VERSION="${arrTag[2]}"
77+ VERSION="${VERSION//v}"
78+ dotnet pack -v normal -c Release --include-symbols --include-source -p:PackageVersion=$VERSION -o nupkg src/$PROJECT_NAME/$PROJECT_NAME.*proj
79+ - name : Push to Nuget
80+ run : dotnet nuget push nuget/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_KEY}} --skip-duplicate
0 commit comments