2
0

build.yml 5.0 KB

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