main.yml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. name: Publish donet project to nuget
  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@v4
  14. - name: Setup .NET Core SDK
  15. uses: actions/setup-dotnet@v1
  16. with:
  17. dotnet-version: 3.1.100
  18. - uses: actions/cache@v2
  19. with:
  20. path: ~/.nuget/packages
  21. key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
  22. restore-keys: |
  23. ${{ runner.os }}-nuget-
  24. - name: Pack
  25. run: dotnet pack TestLib --configuration Release -o finalpackage --no-build
  26. - name: Publish artifact
  27. uses: actions/upload-artifact@master
  28. with:
  29. name: nupkg
  30. path: finalpackage
  31. deploy:
  32. needs: build
  33. name: Deploy Packages
  34. runs-on: windows-latest # using windows agent due to nuget can't sign on linux yet
  35. steps:
  36. - name: Download Package artifact
  37. uses: actions/download-artifact@master
  38. with:
  39. name: nupkg
  40. - name: Setup NuGet
  41. uses: NuGet/setup-nuget@v1.0.2
  42. with:
  43. nuget-api-key: ${{ secrets.NUGET_API_KEY }}
  44. nuget-version: latest
  45. - name: Setup .NET Core SDK
  46. uses: actions/setup-dotnet@v1
  47. with:
  48. dotnet-version: 3.1.100
  49. - name: Get certificate
  50. id: cert_file
  51. uses: timheuer/base64-to-file@master
  52. with:
  53. fileName: 'certfile.pfx'
  54. encodedString: ${{ secrets.SIGNING_CERT }}
  55. # Sign the package
  56. - name: Sign NuGet Package
  57. run: nuget sign nupkg\*.nupkg -CertificatePath ${{ steps.cert_file.outputs.filePath }} -CertificatePassword ${{ secrets.CERT_PWD }} -Timestamper http://timestamp.digicert.com –NonInteractive
  58. - name: Push to NuGet
  59. run: dotnet nuget push nupkg\*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://nuget.org