1+ name : Deploy
2+
3+ on :
4+ release :
5+ types : [created]
6+
7+ defaults :
8+ run :
9+ shell : pwsh
10+
11+ env :
12+ baseVersion : 1.0.0
13+
14+ jobs :
15+ build-and-test :
16+ runs-on : windows-latest
17+ steps :
18+ - uses : actions/checkout@v3
19+ - name : Setup .NET
20+ uses : actions/setup-dotnet@v2
21+ with :
22+ dotnet-version : |
23+ 3.1.x
24+ 6.x
25+ - name : Restore dependencies
26+ run : dotnet restore
27+ - name : Set Version
28+ run : |
29+ echo "${{ github.ref }}"
30+ if ("${{ github.ref }}".startsWith("refs/tags/v")) {
31+ $tagVersion = "${{ github.ref }}".substring(11)
32+ echo "buildVersion=$tagVersion.${{ github.run_number }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
33+ echo "nugetVersion=$tagVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
34+ echo "preRelease=false" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
35+ } else {
36+ echo "buildVersion=${{ env.baseVersion }}.${{ github.run_number }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
37+ echo "nugetVersion=${{ env.baseVersion }}-ci${{ github.run_number }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
38+ }
39+ - name : Build
40+ run : dotnet build -p:Version=${{ env.buildVersion }} -p:ContinuousIntegrationBuild=True --no-restore --configuration Release
41+ - name : Test
42+ run : dotnet test --no-build --configuration Release --verbosity normal
43+ - name : Pack
44+ if : startsWith(github.ref, 'refs/tags/v')
45+ run : dotnet pack -p:PackageVersion=${{ env.nugetVersion }} --configuration Release -o ${{env.DOTNET_ROOT}}/IntelliTect.ListingManagerPack --no-build
46+ - name : Upload Artifacts
47+ if : startsWith(github.ref, 'refs/tags/v')
48+ uses : actions/upload-artifact@v2
49+ with :
50+ name : NuGet
51+ path : ${{env.DOTNET_ROOT}}/IntelliTect.ListingManagerPack
52+
53+ deploy :
54+ if : startsWith(github.ref, 'refs/tags/v')
55+ runs-on : ubuntu-latest
56+ needs : build-and-test
57+ environment :
58+ name : ' Production'
59+ url : ' https://www.nuget.org/packages/IntelliTect.EssentialCSharp.ListingManager'
60+ steps :
61+ - name : Download artifact from build job
62+ uses : actions/download-artifact@v2
63+ with :
64+ name : NuGet
65+ - name : Push NuGet
66+ run : |
67+ $tagVersion = "${{ github.ref }}".substring(11)
68+ echo "::set-output name=TAG_VERSION::$tagVersion"
69+ dotnet nuget push IntelliTect.EssentialCSharp.ListingManager.$tagVersion.nupkg --source https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }} --skip-duplicate
70+ id : tag-version
71+ - name : Upload nupkg to Releases
72+ uses : softprops/action-gh-release@v1
73+ with :
74+ fail_on_unmatched_files : true
75+ generate_release_notes : true
76+ files : IntelliTect.EssentialCSharp.ListingManager.${{ steps.tag-version.outputs.TAG_VERSION }}.nupkg
0 commit comments