diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..abf05de --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,39 @@ +# Build and test on pull requests and pushes to Development +# (replaces azure-pipelines-mergetest.yml) +name: Build + +on: + pull_request: + push: + branches: [ Development ] + paths-ignore: + - '**.md' + workflow_dispatch: + +env: + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + SOLUTION: DSoft.Portable.WebClient.slnx + BUILD_CONFIGURATION: Release + +jobs: + build: + # windows is required for the WPF TestHarness (net10.0-windows) and the net462 targets + runs-on: windows-latest + + steps: + - uses: actions/checkout@v5 + + - name: Install .NET SDK + uses: actions/setup-dotnet@v5 + with: + dotnet-version: 10.0.x + + - name: Restore packages + run: dotnet restore ${{ env.SOLUTION }} + + - name: Build + run: dotnet build ${{ env.SOLUTION }} --no-restore --configuration ${{ env.BUILD_CONFIGURATION }} + + - name: Test + run: dotnet test UnitTester/UnitTester.csproj --no-build --configuration ${{ env.BUILD_CONFIGURATION }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8f2c1d9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,164 @@ +# Build, test, package, publish to nuget.org and tag the release on pushes to master +# (replaces the Azure DevOps build and release pipelines) +# +# Publishing uses NuGet Trusted Publishing (OIDC), so no API key is stored in GitHub. +# One-time setup: +# 1. nuget.org > Trusted Publishing: add a GitHub Actions policy for +# owner newky2k, repository PortableWebClient, workflow file release.yml, environment nuget +# 2. GitHub > Settings > Environments: create an environment named "nuget" +# (optionally add required reviewers to approve each publish) +# 3. GitHub > Settings > Secrets and variables > Actions: add a secret NUGET_USER +# containing your nuget.org user name (profile name, not email) +name: Release + +on: + push: + branches: [ master ] + paths-ignore: + - '**.md' + - '.github/workflows/build.yml' + workflow_dispatch: + inputs: + publish: + description: 'Publish the packages to nuget.org' + type: boolean + default: true + +env: + DOTNET_NOLOGO: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + SOLUTION: DSoft.Portable.WebClient.slnx + BUILD_CONFIGURATION: Release + MAJOR_MINOR: '7.0' + # set to '-prerelease' while working on a beta, or '' for a stable release + RELEASE_SUFFIX: '-prerelease' + +concurrency: + group: release + cancel-in-progress: false + +permissions: + contents: read + actions: read + +jobs: + release: + # windows is required for the WPF TestHarness (net10.0-windows) and the net462 targets + runs-on: windows-latest + outputs: + version: ${{ steps.version.outputs.version }}${{ env.RELEASE_SUFFIX }} + + steps: + - uses: actions/checkout@v5 + + - name: Install .NET SDK + uses: actions/setup-dotnet@v5 + with: + dotnet-version: 10.0.x + + # Same scheme as the old Azure pipeline: {major}.{minor}.{yyMM}.{dd}{daily revision} + - name: Calculate version + id: version + shell: pwsh + env: + GH_TOKEN: ${{ github.token }} + run: | + $now = [DateTime]::UtcNow + $since = $now.ToString('yyyy-MM-dd') + $runs = gh run list --repo "${{ github.repository }}" --workflow release.yml --created ">=$since" --limit 100 --json databaseId,createdAt | ConvertFrom-Json + $rev = @($runs | Where-Object { $_.databaseId -le ${{ github.run_id }} }).Count + if ($rev -lt 1) { $rev = 1 } + $version = "$env:MAJOR_MINOR.$($now.ToString('yyMM')).$($now.ToString('dd'))$rev" + "version=$version" >> $env:GITHUB_OUTPUT + Write-Host "Version: $version$env:RELEASE_SUFFIX" + + - name: Restore packages + run: dotnet restore ${{ env.SOLUTION }} + + - name: Build + run: > + dotnet build ${{ env.SOLUTION }} --no-restore + --configuration ${{ env.BUILD_CONFIGURATION }} + /p:Version=${{ steps.version.outputs.version }}${{ env.RELEASE_SUFFIX }} + /p:AssemblyVersion=${{ steps.version.outputs.version }} + /p:FileVersion=${{ steps.version.outputs.version }} + + - name: Test + run: dotnet test UnitTester/UnitTester.csproj --no-build --configuration ${{ env.BUILD_CONFIGURATION }} + + - name: Collect packages + shell: pwsh + run: | + New-Item -ItemType Directory -Force -Path artifacts | Out-Null + Get-ChildItem -Recurse -Include 'DSoft.*.nupkg','DSoft.*.snupkg' -Path . | + Where-Object { $_.FullName -notmatch '[\\/]artifacts[\\/]' } | + Copy-Item -Destination artifacts + Get-ChildItem artifacts + + - name: Upload packages + uses: actions/upload-artifact@v4 + with: + name: drop + path: artifacts/* + + publish: + needs: release + if: ${{ github.event_name == 'push' || inputs.publish }} + runs-on: ubuntu-latest + environment: nuget + permissions: + id-token: write # required for NuGet trusted publishing + + steps: + - name: Download packages + uses: actions/download-artifact@v4 + with: + name: drop + path: artifacts + + - name: Install .NET SDK + uses: actions/setup-dotnet@v5 + with: + dotnet-version: 10.0.x + + - name: NuGet login (OIDC) + id: login + uses: NuGet/login@v1 + with: + user: ${{ secrets.NUGET_USER }} + + - name: Push to nuget.org + run: > + dotnet nuget push "artifacts/*.nupkg" + --api-key ${{ steps.login.outputs.NUGET_API_KEY }} + --source https://api.nuget.org/v3/index.json + --skip-duplicate + + tag: + # tag the commit and create a GitHub release once the packages are on nuget.org + needs: [ release, publish ] + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Download packages + uses: actions/download-artifact@v4 + with: + name: drop + path: artifacts + + - name: Create tag and GitHub release + env: + GH_TOKEN: ${{ github.token }} + TAG: v${{ needs.release.outputs.version }} + PRERELEASE: ${{ env.RELEASE_SUFFIX != '' }} + run: | + flags=() + if [ "$PRERELEASE" = "true" ]; then flags+=(--prerelease); else flags+=(--latest); fi + gh release create "$TAG" artifacts/*.nupkg \ + --repo "$GITHUB_REPOSITORY" \ + --target "$GITHUB_SHA" \ + --title "$TAG" \ + --generate-notes \ + "${flags[@]}" diff --git a/DSoft.Portable.WebClient.Encryption/DSoft.Portable.WebClient.Encryption.csproj b/DSoft.Portable.WebClient.Encryption/DSoft.Portable.WebClient.Encryption.csproj index 859d558..bc21e13 100644 --- a/DSoft.Portable.WebClient.Encryption/DSoft.Portable.WebClient.Encryption.csproj +++ b/DSoft.Portable.WebClient.Encryption/DSoft.Portable.WebClient.Encryption.csproj @@ -1,23 +1,12 @@ - true - true - newky2k newky2k - MIT Encrypted payload communications classes for the DSoft.Portable.WebClient - https://github.com/newky2k/PortableWebClient - https://github.com/newky2k/PortableWebClient - git Web Client - v3.1 - Release - - true - DSoft.snk + v5.2 - Add .NET 10 Support, removed .NET 8.0 false - Copyright © 2021 DSoft - README.md + README.md @@ -28,8 +17,8 @@ - - + + diff --git a/DSoft.Portable.WebClient.Grpc.Encryption/DSoft.Portable.WebClient.Grpc.Encryption.csproj b/DSoft.Portable.WebClient.Grpc.Encryption/DSoft.Portable.WebClient.Grpc.Encryption.csproj index b4df488..76181bf 100644 --- a/DSoft.Portable.WebClient.Grpc.Encryption/DSoft.Portable.WebClient.Grpc.Encryption.csproj +++ b/DSoft.Portable.WebClient.Grpc.Encryption/DSoft.Portable.WebClient.Grpc.Encryption.csproj @@ -15,9 +15,9 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/DSoft.Portable.WebClient.Grpc.Extensions/DSoft.Portable.WebClient.Grpc.Extensions.csproj b/DSoft.Portable.WebClient.Grpc.Extensions/DSoft.Portable.WebClient.Grpc.Extensions.csproj index db17a9c..5d224b6 100644 --- a/DSoft.Portable.WebClient.Grpc.Extensions/DSoft.Portable.WebClient.Grpc.Extensions.csproj +++ b/DSoft.Portable.WebClient.Grpc.Extensions/DSoft.Portable.WebClient.Grpc.Extensions.csproj @@ -17,7 +17,7 @@ - + diff --git a/DSoft.Portable.WebClient.Grpc/DSoft.Portable.WebClient.Grpc.csproj b/DSoft.Portable.WebClient.Grpc/DSoft.Portable.WebClient.Grpc.csproj index 5547646..c472e97 100644 --- a/DSoft.Portable.WebClient.Grpc/DSoft.Portable.WebClient.Grpc.csproj +++ b/DSoft.Portable.WebClient.Grpc/DSoft.Portable.WebClient.Grpc.csproj @@ -17,9 +17,9 @@ - - - + + + diff --git a/DSoft.Portable.WebClient.Rest/DSoft.Portable.WebClient.Rest.csproj b/DSoft.Portable.WebClient.Rest/DSoft.Portable.WebClient.Rest.csproj index 654c397..620c085 100644 --- a/DSoft.Portable.WebClient.Rest/DSoft.Portable.WebClient.Rest.csproj +++ b/DSoft.Portable.WebClient.Rest/DSoft.Portable.WebClient.Rest.csproj @@ -17,12 +17,12 @@ - + - - + + diff --git a/DSoft.Portable.WebClient.slnx b/DSoft.Portable.WebClient.slnx index ba953b2..d17d6c9 100644 --- a/DSoft.Portable.WebClient.slnx +++ b/DSoft.Portable.WebClient.slnx @@ -22,8 +22,8 @@ - - + + diff --git a/Directory.Build.props b/Directory.Build.props index a5ce506..fb0aac8 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -38,10 +38,10 @@ - + - + true diff --git a/README.md b/README.md index 235a688..a10178b 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ In v3.1 and above the InitVector key is passed explicilty to the `IEncryptionPro `IWebClient` has been removed and now constructors for `GrpcServiceClientBase` and `RestServiceClientBase` receive `GrpcClientOptions` and `RestApiClientOptions` to provide configuration data. ## Build status -[![Build Status](https://dev.azure.com/humbatt/Daves%20Projects/_apis/build/status/PortableWebClient/PortableWebClient%20-%20Release?branchName=master)](https://dev.azure.com/humbatt/Daves%20Projects/_build/latest?definitionId=49&branchName=master) +[![Release](https://github.com/newky2k/PortableWebClient/actions/workflows/release.yml/badge.svg?branch=master)](https://github.com/newky2k/PortableWebClient/actions/workflows/release.yml) diff --git a/RpcSample/RpcSample.csproj b/RpcSample/RpcSample.csproj index 02e8dea..bf48541 100644 --- a/RpcSample/RpcSample.csproj +++ b/RpcSample/RpcSample.csproj @@ -8,10 +8,10 @@ - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/SampleApiClient/SampleApiClient.csproj b/SampleApiClient/SampleApiClient.csproj index 0707a17..f39e6f8 100644 --- a/SampleApiClient/SampleApiClient.csproj +++ b/SampleApiClient/SampleApiClient.csproj @@ -8,7 +8,7 @@ - + diff --git a/SampleWebApp/SampleWebApp.csproj b/SampleWebApp/SampleWebApp.csproj index d58efd2..a3d96a0 100644 --- a/SampleWebApp/SampleWebApp.csproj +++ b/SampleWebApp/SampleWebApp.csproj @@ -9,10 +9,10 @@ - - - - + + + + diff --git a/UnitTester/UnitTester.csproj b/UnitTester/UnitTester.csproj index ec429bb..6ca547d 100644 --- a/UnitTester/UnitTester.csproj +++ b/UnitTester/UnitTester.csproj @@ -11,16 +11,16 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/azure-pipelines-mergetest.yml b/azure-pipelines-mergetest.yml deleted file mode 100644 index 4479905..0000000 --- a/azure-pipelines-mergetest.yml +++ /dev/null @@ -1,38 +0,0 @@ -# .NET Desktop -# Build and run tests for .NET Desktop or Windows classic desktop solutions. -# Add steps that publish symbols, save build artifacts, and more: -# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net - -trigger: none - -pool: - vmImage: 'windows-latest' - -variables: - solution: '**/*.slnx' - buildPlatform: 'Any CPU' - buildConfiguration: 'Release' - netVersion: '10.x' - -steps: -- task: NuGetToolInstaller@1 - displayName: Install Latest Nuget - -- task: UseDotNet@2 - displayName: 'Install .NET sdk' - inputs: - packageType: 'sdk' - version: $(netVersion) - -- task: DotNetCoreCLI@2 - displayName: Restore Packages - inputs: - command: 'restore' - projects: '$(solution)' - -- task: DotNetCoreCLI@2 - displayName: dotnet build - inputs: - projects: '$(solution)' - arguments: '--configuration=$(buildConfiguration) /p:Platform="$(buildPlatform)"' - diff --git a/azure-pipelines-release.yml b/azure-pipelines-release.yml deleted file mode 100644 index a27af79..0000000 --- a/azure-pipelines-release.yml +++ /dev/null @@ -1,63 +0,0 @@ -# .NET Desktop -# Build and run tests for .NET Desktop or Windows classic desktop solutions. -# Add steps that publish symbols, save build artifacts, and more: -# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net - -trigger: - batch: true - branches: - include: - - master - paths: - exclude: - - azure-pipelines-release.yml - - readme.md - -pool: - vmImage: 'windows-latest' - -variables: - solution: '**/*.slnx' - buildPlatform: 'Any CPU' - buildConfiguration: 'Release' - releaseSuffix: '-prerelease' - netVersion: '10.x' - -name: 7.0.$(date:yyMM).$(date:dd)$(rev:r) - -steps: -- task: NuGetToolInstaller@1 - displayName: Install Latest Nuget - -- task: UseDotNet@2 - displayName: 'Install .NET sdk' - inputs: - packageType: 'sdk' - version: $(netVersion) - -- task: DotNetCoreCLI@2 - displayName: Restore Packages - inputs: - command: 'restore' - projects: '$(solution)' - -- task: DotNetCoreCLI@2 - displayName: dotnet build - inputs: - projects: '$(solution)' - arguments: '--configuration=$(buildConfiguration) /p:Platform="$(buildPlatform)" /p:Version=$(Build.BuildNumber)$(releaseSuffix) /p:AssemblyVersion=$(Build.BuildNumber) /p:FileVersion=$(Build.BuildNumber) ' - -- task: CopyFiles@2 - displayName: Copy Files to $(build.artifactstagingdirectory) - inputs: - SourceFolder: '$(system.defaultworkingdirectory)' - Contents: '**/Dsoft.*.nupkg' - TargetFolder: '$(build.artifactstagingdirectory)' - flattenFolders: true - -- task: PublishBuildArtifacts@1 - displayName: Publish Artifacts drop - inputs: - PathtoPublish: '$(Build.ArtifactStagingDirectory)' - ArtifactName: 'drop' - publishLocation: 'Container'