main.yml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. name: CI
  2. on:
  3. push:
  4. branches: [ master ]
  5. pull_request:
  6. branches: [ master ]
  7. jobs:
  8. build:
  9. if: github.event_name == 'push' && contains(toJson(github.event.commits), '***NO_CI***') == false && contains(toJson(github.event.commits), '[ci skip]') == false && contains(toJson(github.event.commits), '[skip ci]') == false
  10. name: Build Package
  11. runs-on: ubuntu-latest
  12. steps:
  13. - uses: actions/checkout@v2
  14.     - name: Setup .NET Core SDK
  15.       uses: actions/setup-dotnet@v1
  16.       with:
  17.         dotnet-version: 3.1.100
  18. - name: Pack
  19. run: dotnet pack TestLib --configuration Release -o finalpackage --no-build
  20. - name: Publish artifact
  21. uses: actions/upload-artifact@master
  22. with:
  23. name: nupkg
  24. path: finalpackage
  25. deploy:
  26. needs: build
  27. name: Deploy Packages
  28. runs-on: windows-latest # using windows agent due to nuget can't sign on linux yet
  29. steps:
  30. - name: Download Package artifact
  31. uses: actions/download-artifact@master
  32. with:
  33. name: nupkg
  34. - name: Setup NuGet
  35. uses: NuGet/setup-nuget@v1.0.2
  36. with:
  37. nuget-api-key: ${{ secrets.NUGET_API_KEY }}
  38. nuget-version: latest
  39. - name: Setup .NET Core SDK
  40. uses: actions/setup-dotnet@v1
  41. with:
  42. dotnet-version: 3.1.100
  43. - name: Get certificate
  44. id: cert_file
  45. uses: timheuer/base64-to-file@master
  46. with:
  47. fileName: 'certfile.pfx'
  48. encodedString: ${{ secrets.SIGNING_CERT }}
  49. # Sign the package
  50. - name: Sign NuGet Package
  51. run: nuget sign nupkg\*.nupkg -CertificatePath ${{ steps.cert_file.outputs.filePath }} -CertificatePassword ${{ secrets.CERT_PWD }} -Timestamper http://timestamp.digicert.com –NonInteractive
  52. - name: Push to NuGet
  53. run: dotnet nuget push nupkg\*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://nuget.org