From 551f0c4ce76f776d1a54c4c6f8108a0226968cd1 Mon Sep 17 00:00:00 2001 From: Anton Zhaparov Date: Sat, 7 Dec 2024 15:22:17 +0200 Subject: [PATCH 01/15] Initial version of the release workflow --- .github/workflows/build-and-publish-nuget.yml | 138 ++++++++++++++++++ .github/workflows/build.yml | 2 + Directory.Packages.props | 4 +- build/mailtrap-nuget.props | 18 ++- .../Mailtrap.Abstractions.csproj | 3 +- src/Mailtrap/Mailtrap.csproj | 5 +- 6 files changed, 165 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/build-and-publish-nuget.yml diff --git a/.github/workflows/build-and-publish-nuget.yml b/.github/workflows/build-and-publish-nuget.yml new file mode 100644 index 00000000..4fe41599 --- /dev/null +++ b/.github/workflows/build-and-publish-nuget.yml @@ -0,0 +1,138 @@ +name: Build and Publish NuGet + +on: + workflow_dispatch: + release: + types: + - published + +# Limiting workflow concurrency +concurrency: + # Grouping by workflow, triggering event and ref name. + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + # Building, testing and packing + build: + name: Build, Test and Pack + + runs-on: ubuntu-latest + timeout-minutes: 15 + + # permissions: + # contents: read + # packages: write + + env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + DOTNET_NOLOGO: true + SOLUTION_FILE_PATH: './Mailtrap.sln' + TEST_SETTINGS_FILE_PATH: './tests/tests.runsettings' + TEST_RESULTS_DIR: './artifacts/test-results' + PACKAGE_DIR: './artifacts/packages/' + + strategy: + max-parallel: 1 + matrix: + platform: [anycpu] + configuration: [Release] + dotnet: [ '9.0.x' ] + + steps: + # https://github.com/marketplace/actions/checkout + - name: Checkout Sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 # needed to ensure MinVer will find a previous tag + filter: tree:0 # treeless checkout to speed up checkout + + # https://github.com/marketplace/actions/setup-net-core-sdk + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ matrix.dotnet }} + + - name: Restore dependencies + run: dotnet restore ${{ env.SOLUTION_FILE_PATH }} --locked-mode + + - name: Build + run: > + dotnet build ${{ env.SOLUTION_FILE_PATH }} + --configuration ${{ matrix.configuration }} + --no-restore + # -p:Version=${{ github.ref_name }} MinVer should take care of this one + + # https://github.com/marketplace/actions/upload-a-build-artifact + - name: Publish Artifacts - Binaries + uses: actions/upload-artifact@v4 + with: + name: Binaries + path: './artifacts/bin' + + - name: Test + run: > + dotnet test ${{ env.SOLUTION_FILE_PATH }} + --configuration ${{ matrix.configuration }} + --settings ${{ env.TEST_SETTINGS_FILE_PATH }} + --results-directory ${{ env.TEST_RESULTS_DIR }} + --collect "XPlat Code Coverage" + --no-build + --verbosity normal + + # https://github.com/marketplace/actions/upload-a-build-artifact + - name: Publish Artifacts - Test Results + uses: actions/upload-artifact@v4 + with: + name: Test Results + path: ${{ env.TEST_RESULTS_DIR }} + + - name: Pack NuGet Package + run: > + dotnet pack ${{ env.SOLUTION_FILE_PATH }} + --configuration ${{ matrix.configuration }} + --output ${{ env.PACKAGE_DIR }} + --no-build + # -p:Version=${{ github.ref_name }} MinVer should take care of this one + + # https://github.com/marketplace/actions/upload-a-build-artifact + - name: Publish Artifacts - Packages + uses: actions/upload-artifact@v4 + with: + name: Packages + path: ${{ env.PACKAGE_DIR }}/*.*nupkg + + + # Publishing + publish: + name: Publish to NuGet + + runs-on: ubuntu-latest + timeout-minutes: 5 + + env: + PACKAGE_DIR: 'packages' + PACKAGE_SOURCE: 'https://api.nuget.org/v3/index.json' + + # Add a dependency to the build job + needs: build + + environment: + name: nuget + + steps: + # https://github.com/marketplace/actions/download-a-build-artifact + - uses: actions/download-artifact@v4 + with: + name: Packages + path: ${{ env.PACKAGE_DIR }} + + - name: Publish NuGet Package + run: > + dotnet nuget push "${{ env.PACKAGE_DIR }}*.nupkg" + --source ${{ env.PACKAGE_SOURCE }} + --api-key ${{ secrets.NUGET_APIKEY }} + --skip-duplicate + + \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b59f57e8..0069c788 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,6 +23,8 @@ jobs: timeout-minutes: 15 env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + DOTNET_NOLOGO: true SOLUTION_FILE_PATH: './Mailtrap.sln' TEST_SETTINGS_FILE_PATH: './tests/tests.runsettings' TEST_RESULTS_DIR: './artifacts/test-results' diff --git a/Directory.Packages.props b/Directory.Packages.props index c4849270..216c7892 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,6 +5,7 @@ + @@ -14,6 +15,7 @@ + @@ -25,4 +27,4 @@ - \ No newline at end of file + diff --git a/build/mailtrap-nuget.props b/build/mailtrap-nuget.props index 77137529..77e03f10 100644 --- a/build/mailtrap-nuget.props +++ b/build/mailtrap-nuget.props @@ -6,7 +6,7 @@ MIT icon.png README.md - https://github.com/railsware/mailtrap-dotnet + https://railsware.github.io/mailtrap-dotnet https://github.com/railsware/mailtrap-dotnet @@ -10,10 +11,14 @@ + + + + From 3a4e934ea13cf1dea0ab7118e5605b4d99af83c0 Mon Sep 17 00:00:00 2001 From: Anton Zhaparov Date: Sat, 19 Jul 2025 10:28:31 +0300 Subject: [PATCH 04/15] hack to make workflow visible --- .github/workflows/build-and-publish-nuget-github.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-publish-nuget-github.yml b/.github/workflows/build-and-publish-nuget-github.yml index 7dffc716..b4ed9272 100644 --- a/.github/workflows/build-and-publish-nuget-github.yml +++ b/.github/workflows/build-and-publish-nuget-github.yml @@ -2,6 +2,7 @@ name: Build and Publish NuGet (GitHub) on: workflow_dispatch: + push: release: types: - published From 347dd0a5afd6fc1f8163c7f1bea642821cb00839 Mon Sep 17 00:00:00 2001 From: Anton Zhaparov Date: Sat, 19 Jul 2025 10:42:49 +0300 Subject: [PATCH 05/15] set minver prefix to 'v' --- build/mailtrap-nuget.props | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/mailtrap-nuget.props b/build/mailtrap-nuget.props index 77e03f10..770fc29d 100644 --- a/build/mailtrap-nuget.props +++ b/build/mailtrap-nuget.props @@ -25,10 +25,13 @@ $([MSBuild]::NormalizeDirectory('$(BaseDirectory)', 'assets')) true - true + + v + + true From 17be17c879719053a03c04fd7e78718d5b25275a Mon Sep 17 00:00:00 2001 From: Anton Zhaparov Date: Sat, 19 Jul 2025 10:43:39 +0300 Subject: [PATCH 06/15] remove temporary trigger --- .github/workflows/build-and-publish-nuget-github.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-and-publish-nuget-github.yml b/.github/workflows/build-and-publish-nuget-github.yml index b4ed9272..caf40e9d 100644 --- a/.github/workflows/build-and-publish-nuget-github.yml +++ b/.github/workflows/build-and-publish-nuget-github.yml @@ -1,8 +1,7 @@ name: Build and Publish NuGet (GitHub) on: - workflow_dispatch: - push: + workflow_dispatch: release: types: - published From 4effe44b9a9571e323499b2d774c448354ace649 Mon Sep 17 00:00:00 2001 From: Anton Zhaparov Date: Sat, 19 Jul 2025 10:58:18 +0300 Subject: [PATCH 07/15] fix paths --- .github/workflows/build-and-pack-template.yml | 2 +- .github/workflows/build-and-publish-nuget-github.yml | 3 ++- .github/workflows/build-and-publish-nuget-public.yml | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-pack-template.yml b/.github/workflows/build-and-pack-template.yml index d5f0adb3..a0224923 100644 --- a/.github/workflows/build-and-pack-template.yml +++ b/.github/workflows/build-and-pack-template.yml @@ -17,7 +17,7 @@ jobs: SOLUTION_FILE_PATH: './Mailtrap.sln' TEST_SETTINGS_FILE_PATH: './tests/tests.runsettings' TEST_RESULTS_DIR: './artifacts/test-results' - PACKAGE_DIR: './artifacts/packages/' + PACKAGE_DIR: './artifacts/packages' strategy: matrix: diff --git a/.github/workflows/build-and-publish-nuget-github.yml b/.github/workflows/build-and-publish-nuget-github.yml index caf40e9d..fe64705d 100644 --- a/.github/workflows/build-and-publish-nuget-github.yml +++ b/.github/workflows/build-and-publish-nuget-github.yml @@ -16,6 +16,7 @@ jobs: # Building, testing and packing build-test-pack: uses: ./.github/workflows/build-and-pack-template.yml + name: Build, Test and Pack NuGet # Publishing publish: @@ -47,7 +48,7 @@ jobs: - name: Publish NuGet Package run: > - dotnet nuget push "${{ env.PACKAGE_DIR }}*.nupkg" + dotnet nuget push "${{ env.PACKAGE_DIR }}/*.nupkg" --source ${{ env.PACKAGE_SOURCE }} --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate diff --git a/.github/workflows/build-and-publish-nuget-public.yml b/.github/workflows/build-and-publish-nuget-public.yml index 9f4d4a6d..a853706b 100644 --- a/.github/workflows/build-and-publish-nuget-public.yml +++ b/.github/workflows/build-and-publish-nuget-public.yml @@ -16,7 +16,7 @@ jobs: # Building, testing and packing build-test-pack: uses: ./.github/workflows/build-and-pack-template.yml - + name: Build, Test and Pack NuGet # Publishing publish: @@ -44,7 +44,7 @@ jobs: - name: Publish NuGet Package run: > - dotnet nuget push "${{ env.PACKAGE_DIR }}*.nupkg" + dotnet nuget push "${{ env.PACKAGE_DIR }}/*.nupkg" --source ${{ env.PACKAGE_SOURCE }} --api-key ${{ secrets.NUGET_APIKEY }} --skip-duplicate From 389c8aca8de8c9b883cfb504b3063fbce3d5c1fb Mon Sep 17 00:00:00 2001 From: Anton Zhaparov Date: Sat, 19 Jul 2025 11:22:02 +0300 Subject: [PATCH 08/15] Readme cosmetics --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a35ad9c7..b5195365 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ ![Mailtrap](assets/img/mailtrap-logo.svg) -[![NuGet Version](https://img.shields.io/nuget/v/Railsware.Mailtrap?label=NuGet)](https://www.nuget.org/packages/Railsware.Mailtrap) + +[![Package](https://img.shields.io/badge/Mailtrap?label=Package)](https://github.com/railsware/mailtrap-dotnet/pkgs/nuget/Mailtrap) [![CI](https://github.com/railsware/mailtrap-dotnet/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/railsware/mailtrap-dotnet/actions/workflows/build.yml) [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/railsware/mailtrap-dotnet/blob/main/LICENSE.md) From 79e1827dca4828ba70984e9f0d341e7709554585 Mon Sep 17 00:00:00 2001 From: Anton Zhaparov Date: Sat, 19 Jul 2025 11:39:53 +0300 Subject: [PATCH 09/15] WiP --- build/mailtrap-nuget.props | 2 +- src/Mailtrap.Abstractions/Mailtrap.Abstractions.csproj | 2 +- src/Mailtrap.Abstractions/README.md | 6 +++--- src/Mailtrap/Mailtrap.csproj | 2 +- src/Mailtrap/README.md | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build/mailtrap-nuget.props b/build/mailtrap-nuget.props index 770fc29d..06b025e6 100644 --- a/build/mailtrap-nuget.props +++ b/build/mailtrap-nuget.props @@ -49,7 +49,7 @@ - + True \ diff --git a/src/Mailtrap.Abstractions/Mailtrap.Abstractions.csproj b/src/Mailtrap.Abstractions/Mailtrap.Abstractions.csproj index daa5300f..8bcc7069 100644 --- a/src/Mailtrap.Abstractions/Mailtrap.Abstractions.csproj +++ b/src/Mailtrap.Abstractions/Mailtrap.Abstractions.csproj @@ -6,7 +6,7 @@ Mailtrap Mailtrap Client Abstractions - + Provides abstractions for the Mailtrap .NET SDK. Mailtrap.Abstractions mailtrap; sdk; client; email; abstractions diff --git a/src/Mailtrap.Abstractions/README.md b/src/Mailtrap.Abstractions/README.md index 4dc54431..086c5774 100644 --- a/src/Mailtrap.Abstractions/README.md +++ b/src/Mailtrap.Abstractions/README.md @@ -1,6 +1,6 @@ # Mailtrap.Abstractions -Provides abstractions for the Mailtrap .NET SDK. -Interfaces defined in this package are implemented by classes in the [Mailtrap](https://www.nuget.org/packages/Mailtrap) package. +Provides abstractions for the Mailtrap .NET SDK. +Interfaces defined in this package are implemented by classes in the [Mailtrap](https://github.com/railsware/mailtrap-dotnet/pkgs/nuget/Mailtrap) package. Please visit [documentation site](https://railsware.github.io/mailtrap-dotnet) for detailed documentation and usage examples. @@ -14,7 +14,7 @@ Please visit [documentation site](https://railsware.github.io/mailtrap-dotnet) f ## Related Packages -* [Mailtrap](https://www.nuget.org/packages/Mailtrap) +* [Mailtrap](https://github.com/railsware/mailtrap-dotnet/pkgs/nuget/Mailtrap) ## Contributing diff --git a/src/Mailtrap/Mailtrap.csproj b/src/Mailtrap/Mailtrap.csproj index f66d4594..52c41b43 100644 --- a/src/Mailtrap/Mailtrap.csproj +++ b/src/Mailtrap/Mailtrap.csproj @@ -6,7 +6,7 @@ Mailtrap Mailtrap Client - + Official Mailtrap .NET SDK. Mailtrap mailtrap; sdk; client; email diff --git a/src/Mailtrap/README.md b/src/Mailtrap/README.md index eabd0d97..9051f420 100644 --- a/src/Mailtrap/README.md +++ b/src/Mailtrap/README.md @@ -12,7 +12,7 @@ Please visit [documentation site](https://railsware.github.io/mailtrap-dotnet) f ## Related Packages -* [Mailtrap.Abstractions](https://www.nuget.org/packages/Mailtrap.Abstractions) +* [Mailtrap.Abstractions](https://github.com/railsware/mailtrap-dotnet/pkgs/nuget/Mailtrap.Abstractions) ## Contributing From a10b16ede738674d9858a3ddf645a63ba0becbbb Mon Sep 17 00:00:00 2001 From: Anton Zhaparov Date: Sat, 19 Jul 2025 11:42:26 +0300 Subject: [PATCH 10/15] Fix readme path --- build/mailtrap-nuget.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/mailtrap-nuget.props b/build/mailtrap-nuget.props index 06b025e6..e3ddb2be 100644 --- a/build/mailtrap-nuget.props +++ b/build/mailtrap-nuget.props @@ -49,7 +49,7 @@ - + True \ From 0a8fc3da20aafdef7375e11bba2dd099a2f477e3 Mon Sep 17 00:00:00 2001 From: Anton Zhaparov Date: Sat, 19 Jul 2025 11:50:19 +0300 Subject: [PATCH 11/15] Revert --- build/mailtrap-nuget.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/mailtrap-nuget.props b/build/mailtrap-nuget.props index e3ddb2be..770fc29d 100644 --- a/build/mailtrap-nuget.props +++ b/build/mailtrap-nuget.props @@ -49,7 +49,7 @@ - + True \ From 4b58ca0a5ebc5939bcf331f2a000337eba616161 Mon Sep 17 00:00:00 2001 From: Anton Zhaparov Date: Sat, 19 Jul 2025 11:59:35 +0300 Subject: [PATCH 12/15] Experiment --- build/mailtrap-nuget.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/mailtrap-nuget.props b/build/mailtrap-nuget.props index 770fc29d..963a2a73 100644 --- a/build/mailtrap-nuget.props +++ b/build/mailtrap-nuget.props @@ -7,7 +7,7 @@ icon.png README.md https://railsware.github.io/mailtrap-dotnet - https://github.com/railsware/mailtrap-dotnet + + https://github.com/railsware/mailtrap-dotnet