build.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. name: Build
  2. on:
  3. - push
  4. - pull_request
  5. - workflow_dispatch
  6. jobs:
  7. Linux:
  8. runs-on: ubuntu-24.04
  9. steps:
  10. - name: Checkout
  11. uses: actions/checkout@v4
  12. with:
  13. fetch-depth: 0 # needed for Nerdbank.GitVersioning
  14. - name: Setup .NET
  15. uses: actions/setup-dotnet@v4
  16. with:
  17. dotnet-version: 8.0.x
  18. - name: Build Unit Tests .NET
  19. run: dotnet build -f net8.0 test/Renci.SshNet.Tests/
  20. - name: Build IntegrationTests .NET
  21. run: dotnet build -f net8.0 test/Renci.SshNet.IntegrationTests/
  22. - name: Build IntegrationTests .NET Framework
  23. run: dotnet build -f net48 test/Renci.SshNet.IntegrationTests/
  24. - name: Run Unit Tests .NET
  25. run: |
  26. dotnet test \
  27. -f net8.0 \
  28. --no-build \
  29. --logger "console;verbosity=normal" \
  30. --logger GitHubActions \
  31. -p:CollectCoverage=true \
  32. -p:CoverletOutputFormat=cobertura \
  33. -p:CoverletOutput=../../coverlet/linux_unit_test_net_8_coverage.xml \
  34. test/Renci.SshNet.Tests/
  35. - name: Run Integration Tests .NET
  36. run: |
  37. dotnet test \
  38. -f net8.0 \
  39. --no-build \
  40. --logger "console;verbosity=normal" \
  41. --logger GitHubActions \
  42. -p:CollectCoverage=true \
  43. -p:CoverletOutputFormat=cobertura \
  44. -p:CoverletOutput=../../coverlet/linux_integration_test_net_8_coverage.xml \
  45. test/Renci.SshNet.IntegrationTests/
  46. # Also run a subset of the integration tests targeting netfx using mono. This is a temporary measure to get
  47. # some coverage until a proper solution for running the .NET Framework integration tests in CI is found.
  48. # Running all the tests causes problems which are not worth solving in this rare configuration.
  49. # See https://github.com/sshnet/SSH.NET/pull/1462 and related links
  50. - name: Run Integration Tests Mono
  51. run: |
  52. sudo apt-get install ca-certificates gnupg
  53. sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
  54. echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
  55. sudo apt-get update
  56. sudo apt-get install mono-devel
  57. dotnet test \
  58. -f net48 \
  59. --no-build \
  60. --logger "console;verbosity=normal" \
  61. --logger GitHubActions \
  62. -p:CollectCoverage=true \
  63. -p:CoverletOutputFormat=cobertura \
  64. -p:CoverletOutput=../../coverlet/linux_integration_test_net_48_coverage.xml \
  65. --filter "Name~Ecdh|Name~ECDsa|Name~Zlib|Name~Gcm" \
  66. test/Renci.SshNet.IntegrationTests/
  67. - name: Archive Coverlet Results
  68. uses: actions/upload-artifact@v4
  69. with:
  70. name: Coverlet Results Linux
  71. path: coverlet
  72. Windows:
  73. runs-on: windows-2022
  74. steps:
  75. - name: Checkout
  76. uses: actions/checkout@v4
  77. with:
  78. fetch-depth: 0 # needed for Nerdbank.GitVersioning
  79. - name: Setup .NET
  80. uses: actions/setup-dotnet@v4
  81. with:
  82. dotnet-version: 9.0.x
  83. - name: Build Solution
  84. run: dotnet build Renci.SshNet.sln
  85. - name: Publish AOT Compatibility Test App
  86. run: dotnet publish -r win-x64 /warnaserror test/Renci.SshNet.AotCompatibilityTestApp/
  87. - name: Create NuGet Package
  88. run: dotnet pack
  89. - name: Archive NuGet Package
  90. uses: actions/upload-artifact@v4
  91. with:
  92. name: NuGet Package
  93. path: src/Renci.SshNet/bin/Release/*.*nupkg
  94. - name: Run Unit Tests .NET
  95. run: |
  96. dotnet test `
  97. -f net8.0 `
  98. --no-build `
  99. --logger "console;verbosity=normal" `
  100. --logger GitHubActions `
  101. -p:CollectCoverage=true `
  102. -p:CoverletOutputFormat=cobertura `
  103. -p:CoverletOutput=../../coverlet/windows_unit_test_net_8_coverage.xml `
  104. test/Renci.SshNet.Tests/
  105. - name: Run Unit Tests .NET Framework
  106. run: |
  107. dotnet test `
  108. -f net462 `
  109. --no-build `
  110. --logger "console;verbosity=normal" `
  111. --logger GitHubActions `
  112. -p:CollectCoverage=true `
  113. -p:CoverletOutputFormat=cobertura `
  114. -p:CoverletOutput=../../coverlet/windows_unit_test_net_4_6_2_coverage.xml `
  115. test/Renci.SshNet.Tests/
  116. - name: Archive Coverlet Results
  117. uses: actions/upload-artifact@v4
  118. with:
  119. name: Coverlet Results Windows
  120. path: coverlet
  121. Publish:
  122. runs-on: ubuntu-24.04
  123. if: github.ref == 'refs/heads/develop'
  124. permissions:
  125. packages: write
  126. needs:
  127. - Windows
  128. - Linux
  129. steps:
  130. - name: Download NuGet Package
  131. uses: actions/download-artifact@v4
  132. with:
  133. name: NuGet Package
  134. - name: Publish to GitHub NuGet Registry
  135. run: |
  136. dotnet nuget add source \
  137. --username $GITHUB_ACTOR \
  138. --password ${{ secrets.GITHUB_TOKEN }} \
  139. --store-password-in-clear-text \
  140. --name github \
  141. "https://nuget.pkg.github.com/$GITHUB_REPOSITORY_OWNER/index.json"
  142. dotnet nuget push "*.nupkg" \
  143. --source github \
  144. --api-key ${{ secrets.GITHUB_TOKEN }}