diff --git a/.github/workflows/build-tentacleping-dotnet.yml b/.github/workflows/build-tentacleping-dotnet.yml new file mode 100644 index 0000000..21bd30a --- /dev/null +++ b/.github/workflows/build-tentacleping-dotnet.yml @@ -0,0 +1,86 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: Build TentaclePing + +on: + pull_request: + branches: [ "main" ] + workflow_call: # This makes the workflow reusable + +jobs: + build: + strategy: + matrix: + os: [ubuntu-latest, windows-latest, ubuntu-24.04-arm] + include: + - os: ubuntu-latest + runtime: linux-x64 + framework: net8.0 + - os: windows-latest + runtime: win-x64 + framework: net8.0-windows + - os: ubuntu-24.04-arm + runtime: linux-arm64 + framework: net8.0 + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + - name: Build Publish and Archive (Linux) + if: runner.os != 'Windows' + run: | + dotnet restore source/ + + if [ "${{ github.event_name }}" = "push" ] && [[ "${{ github.ref }}" == refs/tags/v* ]]; then + VERSION="${{ github.ref_name }}" + VERSION_NUMBER="${VERSION#v}" + dotnet build source/ --no-restore -c Release -p:Version=$VERSION_NUMBER -p:AssemblyVersion=$VERSION_NUMBER -p:FileVersion=$VERSION_NUMBER + dotnet publish source/ -c Release -r ${{ matrix.runtime }} --self-contained true -f ${{ matrix.framework }} -p:IncludeNativeLibrariesForSelfExtract=true -p:PublishSingleFile=true -p:DebugType=embedded -p:PublishReadyToRun=false -p:Version=$VERSION_NUMBER -p:AssemblyVersion=$VERSION_NUMBER -p:FileVersion=$VERSION_NUMBER -p:PublishTrimmed=true + else + VERSION_PREFIX=$(grep -oP '\K[^<]+' source/TentaclePing/TentaclePing.csproj) + dotnet build source/ --no-restore -c Release -p:Version=$VERSION_PREFIX -p:AssemblyVersion=$VERSION_PREFIX -p:FileVersion=$VERSION_PREFIX + dotnet publish source/ -c Release -r ${{ matrix.runtime }} --self-contained true -f ${{ matrix.framework }} -p:IncludeNativeLibrariesForSelfExtract=true -p:PublishSingleFile=true -p:DebugType=embedded -p:PublishReadyToRun=false -p:Version=$VERSION_PREFIX -p:AssemblyVersion=$VERSION_PREFIX -p:FileVersion=$VERSION_PREFIX -p:PublishTrimmed=true + fi + + mkdir -p dists + cp ./source/TentaclePing/bin/Release/${{ matrix.framework }}/${{ matrix.runtime }}/publish/TentaclePing dists/ + cp ./source/TentaclePong/bin/Release/${{ matrix.framework }}/${{ matrix.runtime }}/publish/TentaclePong dists/ + tar -czf TentaclePing-${{ matrix.runtime }}.tar.gz -C dists . + rm -rf dists + + - name: Create Archives (Windows) + if: runner.os == 'Windows' + run: | + if ("${{ github.event_name }}" -eq "push" -and "${{ github.ref }}" -like "refs/tags/v*") { + $VERSION = "${{ github.ref_name }}" + $VERSION_NUMBER = $VERSION -replace '^v', '' + dotnet build source/ --no-restore -c Release -p:Version=$VERSION_NUMBER -p:AssemblyVersion=$VERSION_NUMBER -p:FileVersion=$VERSION_NUMBER + dotnet publish source/ -c Release -r ${{ matrix.runtime }} --self-contained true -f ${{ matrix.framework }} -p:IncludeNativeLibrariesForSelfExtract=true -p:PublishSingleFile=true -p:DebugType=embedded -p:PublishReadyToRun=false -p:Version=$VERSION_NUMBER -p:AssemblyVersion=$VERSION_NUMBER -p:FileVersion=$VERSION_NUMBER -p:PublishTrimmed=true + } else { + $VERSION_PREFIX = (Select-String -Path "source/TentaclePing/TentaclePing.csproj" -Pattern "([^<]+)").Matches.Groups[1].Value + dotnet build source/ --no-restore -c Release -p:Version=$VERSION_PREFIX -p:AssemblyVersion=$VERSION_PREFIX -p:FileVersion=$VERSION_PREFIX + dotnet publish source/ -c Release -r ${{ matrix.runtime }} --self-contained true -f ${{ matrix.framework }} -p:IncludeNativeLibrariesForSelfExtract=true -p:PublishSingleFile=true -p:DebugType=embedded -p:PublishReadyToRun=false -p:Version=$VERSION_PREFIX -p:AssemblyVersion=$VERSION_PREFIX -p:FileVersion=$VERSION_PREFIX -p:PublishTrimmed=true + } + + New-Item -ItemType Directory -Path dists -Force + Copy-Item ./source/TentaclePing/bin/Release/${{ matrix.framework }}/${{ matrix.runtime }}/publish/TentaclePing.exe dists/ + Copy-Item ./source/TentaclePong/bin/Release/${{ matrix.framework }}/${{ matrix.runtime }}/publish/TentaclePong.exe dists/ + Compress-Archive -Path dists/* -DestinationPath TentaclePing-${{ matrix.runtime }}.zip + Remove-Item -Recurse -Force dists + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: TentaclePing-${{ matrix.runtime }} + compression-level: 0 + path: | + TentaclePing-${{ matrix.runtime }}.tar.gz + TentaclePing-${{ matrix.runtime }}.zip + diff --git a/.github/workflows/release-tentacleping-dotnet.yml b/.github/workflows/release-tentacleping-dotnet.yml new file mode 100644 index 0000000..bd37e10 --- /dev/null +++ b/.github/workflows/release-tentacleping-dotnet.yml @@ -0,0 +1,68 @@ +name: Create TentaclePing Release + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +jobs: + build: + uses: ./.github/workflows/build-tentacleping-dotnet.yml + + release: + needs: build + runs-on: ubuntu-latest + permissions: + contents: write # Grant write permission to the GITHUB_TOKEN for creating a release + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use the automatically generated GITHUB_TOKEN + with: + tag_name: ${{ github.ref_name }} + release_name: ${{ github.ref_name }} + body: | + # TentaclePing ${{ github.ref_name }} + + + draft: false + prerelease: false + + - name: Upload Linux x64 TentaclePing + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: artifacts/TentaclePing-linux-x64/TentaclePing-linux-x64.tar.gz + asset_name: TentaclePing-linux-x64.tar.gz + asset_content_type: application/gzip + + - name: Upload Linux ARM64 TentaclePing + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: artifacts/TentaclePing-linux-arm64/TentaclePing-linux-arm64.tar.gz + asset_name: TentaclePing-linux-arm64.tar.gz + asset_content_type: application/gzip + + - name: Upload Windows x64 TentaclePing + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: artifacts/TentaclePing-win-x64/TentaclePing-win-x64.zip + asset_name: TentaclePing-win-x64.zip + asset_content_type: application/zip diff --git a/README.md b/README.md index 2c6fead..954a6fe 100644 --- a/README.md +++ b/README.md @@ -46,3 +46,12 @@ If you don't plan to watch TentaclePing run, you may want to pipe the results to TentaclePing.exe MyServer 10933 > Output.txt This file can then easily be sent to the Octopus support team (support@octopusdeploy.com) for analysis. + + +## Contributing + +This project is managed by Github Actions. + +Create a new branch for your changes and open a PR to main to build assests + +Pushing a tag with the format v1.2.3 will trigger a new Release to be created \ No newline at end of file diff --git a/source/TentaclePing/Program.cs b/source/TentaclePing/Program.cs index 1bd95ba..12981ff 100644 --- a/source/TentaclePing/Program.cs +++ b/source/TentaclePing/Program.cs @@ -34,7 +34,11 @@ static int Main(string[] args) { chunkSize = int.Parse(args[3]); } + + #pragma warning disable SYSLIB0039 var sslProtocol = SslProtocols.Tls; + #pragma warning restore SYSLIB0039 + if (args.Length == 5) { if (Enum.TryParse(args[4], out var parsedSslProtocol)) diff --git a/source/TentaclePing/TentaclePing.csproj b/source/TentaclePing/TentaclePing.csproj index 36d0f55..f02974e 100644 --- a/source/TentaclePing/TentaclePing.csproj +++ b/source/TentaclePing/TentaclePing.csproj @@ -8,7 +8,7 @@ TentaclePing false true - netcoreapp3.1 + net8.0;net8.0-windows EXE diff --git a/source/TentaclePong/Program.cs b/source/TentaclePong/Program.cs index aecaf90..c77130e 100644 --- a/source/TentaclePong/Program.cs +++ b/source/TentaclePong/Program.cs @@ -99,7 +99,9 @@ static void ExecuteRequest(TcpClient client) { // We don't actually validate the client, accepting anything; validation // status is reflected in validClientThumprint != null. + #pragma warning disable SYSLIB0039 ssl.AuthenticateAsServer(serverCertificate, true, SslProtocols.Tls, false); + #pragma warning restore SYSLIB0039 var reader = new StreamReader(ssl); diff --git a/source/TentaclePong/TentaclePong.csproj b/source/TentaclePong/TentaclePong.csproj index fee4401..faed41d 100644 --- a/source/TentaclePong/TentaclePong.csproj +++ b/source/TentaclePong/TentaclePong.csproj @@ -8,7 +8,7 @@ TentaclePong false true - netcoreapp3.1 + net8.0;net8.0-windows EXE