build.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. - name: Build Unit Tests .NET
  17. run: dotnet build -f net9.0 test/Renci.SshNet.Tests/
  18. - name: Build IntegrationTests .NET
  19. run: dotnet build -f net9.0 test/Renci.SshNet.IntegrationTests/
  20. - name: Run Unit Tests .NET
  21. run: |
  22. dotnet test \
  23. -f net9.0 \
  24. --no-build \
  25. --logger "console;verbosity=normal" \
  26. --logger GitHubActions \
  27. -p:CollectCoverage=true \
  28. -p:CoverletOutputFormat=cobertura \
  29. -p:CoverletOutput=../../coverlet/linux_unit_test_net_9_coverage.xml \
  30. test/Renci.SshNet.Tests/
  31. - name: Run Integration Tests .NET
  32. run: |
  33. dotnet test \
  34. -f net9.0 \
  35. --no-build \
  36. --logger "console;verbosity=normal" \
  37. --logger GitHubActions \
  38. -p:CollectCoverage=true \
  39. -p:CoverletOutputFormat=cobertura \
  40. -p:CoverletOutput=../../coverlet/linux_integration_test_net_9_coverage.xml \
  41. test/Renci.SshNet.IntegrationTests/
  42. - name: Archive Coverlet Results
  43. uses: actions/upload-artifact@v4
  44. with:
  45. name: Coverlet Results Linux
  46. path: coverlet
  47. Windows:
  48. runs-on: windows-2025
  49. steps:
  50. - name: Checkout
  51. uses: actions/checkout@v4
  52. with:
  53. fetch-depth: 0 # needed for Nerdbank.GitVersioning
  54. - name: Setup .NET
  55. uses: actions/setup-dotnet@v4
  56. - name: Build Solution
  57. run: dotnet build Renci.SshNet.sln
  58. - name: Publish AOT Compatibility Test App
  59. run: dotnet publish -r win-x64 /warnaserror test/Renci.SshNet.AotCompatibilityTestApp/
  60. - name: Create NuGet Package
  61. run: dotnet pack
  62. - name: Archive NuGet Package
  63. uses: actions/upload-artifact@v4
  64. with:
  65. name: NuGet Package
  66. path: src/Renci.SshNet/bin/Release/*.*nupkg
  67. - name: Run Unit Tests .NET
  68. run: |
  69. dotnet test `
  70. -f net9.0 `
  71. --no-build `
  72. --logger "console;verbosity=normal" `
  73. --logger GitHubActions `
  74. -p:CollectCoverage=true `
  75. -p:CoverletOutputFormat=cobertura `
  76. -p:CoverletOutput=../../coverlet/windows_unit_test_net_9_coverage.xml `
  77. test/Renci.SshNet.Tests/
  78. - name: Run Unit Tests .NET Framework
  79. run: |
  80. dotnet test `
  81. -f net462 `
  82. --no-build `
  83. --logger "console;verbosity=normal" `
  84. --logger GitHubActions `
  85. -p:CollectCoverage=true `
  86. -p:CoverletOutputFormat=cobertura `
  87. -p:CoverletOutput=../../coverlet/windows_unit_test_net_4_6_2_coverage.xml `
  88. test/Renci.SshNet.Tests/
  89. Windows-Integration-Tests:
  90. name: Windows Integration Tests
  91. runs-on: windows-2025
  92. steps:
  93. - name: Checkout
  94. uses: actions/checkout@v4
  95. with:
  96. fetch-depth: 0 # needed for Nerdbank.GitVersioning
  97. - name: Setup .NET
  98. uses: actions/setup-dotnet@v4
  99. - name: Setup WSL2
  100. uses: Vampire/setup-wsl@f40fb59d850112c9a292b0218bca8271305b9127 # v5.0.0
  101. with:
  102. distribution: Ubuntu-24.04
  103. - name: Setup SSH Server
  104. shell: wsl-bash {0}
  105. run: |
  106. apt-get update && apt-get upgrade -y
  107. apt-get install -y podman
  108. podman build -t renci-ssh-tests-server-image -f test/Renci.SshNet.IntegrationTests/Dockerfile test/Renci.SshNet.IntegrationTests/
  109. podman run --rm -h renci-ssh-tests-server -d -p 2222:22 renci-ssh-tests-server-image
  110. - name: Run Integration Tests .NET Framework
  111. run:
  112. dotnet test `
  113. -f net48 `
  114. --logger "console;verbosity=normal" `
  115. --logger GitHubActions `
  116. -p:CollectCoverage=true `
  117. -p:CoverletOutputFormat=cobertura `
  118. -p:CoverletOutput=..\..\coverlet\windows_integration_test_net_4_8_coverage.xml `
  119. test\Renci.SshNet.IntegrationTests\
  120. - name: Archive Coverlet Results
  121. uses: actions/upload-artifact@v4
  122. with:
  123. name: Coverlet Results Windows
  124. path: coverlet
  125. Publish:
  126. runs-on: ubuntu-24.04
  127. if: github.ref == 'refs/heads/develop'
  128. permissions:
  129. packages: write
  130. needs:
  131. - Windows
  132. - Linux
  133. steps:
  134. - name: Download NuGet Package
  135. uses: actions/download-artifact@v4
  136. with:
  137. name: NuGet Package
  138. - name: Publish to GitHub NuGet Registry
  139. run: |
  140. dotnet nuget add source \
  141. --username $GITHUB_ACTOR \
  142. --password ${{ secrets.GITHUB_TOKEN }} \
  143. --store-password-in-clear-text \
  144. --name github \
  145. "https://nuget.pkg.github.com/$GITHUB_REPOSITORY_OWNER/index.json"
  146. dotnet nuget push "*.nupkg" \
  147. --source github \
  148. --api-key ${{ secrets.GITHUB_TOKEN }}