Skip to content
Draft
90 changes: 90 additions & 0 deletions .github/workflows/build-and-pack-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Build and Pack NuGet

on:
workflow_call: # Allows you to call this workflow from other workflows

jobs:
# Building, testing and packing
build-test-pack:
name: Build, Test and Pack NuGet

runs-on: ubuntu-latest
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'
PACKAGE_DIR: './artifacts/packages'

strategy:
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

55 changes: 55 additions & 0 deletions .github/workflows/build-and-publish-github-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build and Publish NuGet (GitHub)

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: false

jobs:
# Building, testing and packing
build-test-pack:
uses: ./.github/workflows/build-and-pack-template.yml
name: Build, Test and Pack NuGet

# Publishing
publish:
name: Publish to NuGet (GitHub)

runs-on: ubuntu-latest
timeout-minutes: 5

env:
PACKAGE_DIR: 'packages'
PACKAGE_SOURCE: 'https://nuget.pkg.github.com/railsware/index.json'

# Add a dependency to the build job
needs: build-test-pack

environment:
name: github-packages-railsware

permissions:
contents: read
packages: write

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.GITHUB_TOKEN }}
--skip-duplicate

52 changes: 52 additions & 0 deletions .github/workflows/build-and-publish-nuget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build and Publish NuGet (Public Feed)

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: false

jobs:
# Building, testing and packing
build-test-pack:
uses: ./.github/workflows/build-and-pack-template.yml
name: Build, Test and Pack NuGet

# 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-test-pack

environment:
name: nuget-railsware

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


65 changes: 65 additions & 0 deletions .github/workflows/build-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build and Test

on:
workflow_call: # Allows you to call this workflow from other workflows
inputs:
upload_artifacts:
description: 'Upload build and test artifacts'
type: boolean
required: true
default: false

jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
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'

strategy:
matrix:
platform: [anycpu]
configuration: [Release]
dotnet: ['9.0.x']

steps:
# https://github.com/marketplace/actions/checkout
- name: Checkout Sources
uses: actions/checkout@v4

# 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

# https://github.com/marketplace/actions/upload-a-build-artifact
- name: Publish Artifacts - Binaries
uses: actions/upload-artifact@v4
if: ${{ inputs.upload_artifacts }}
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
if: ${{ inputs.upload_artifacts }}
with:
name: Test Results
path: ${{ env.TEST_RESULTS_DIR }}
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 5 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>

<ItemGroup>
<!-- MS -->
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0" />
Expand All @@ -10,10 +11,14 @@
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="9.7.0" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="9.0.7" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.DotNet.ApiCompat.Task" Version="9.0.303" />
<PackageVersion Include="System.Net.Http.Json" Version="8.0.1" />
<PackageVersion Include="System.Text.Json" Version="9.0.7" />

<!-- 3rd party -->
<PackageVersion Include="FluentValidation" Version="11.11.0" />
<PackageVersion Include="MinVer" Version="6.0.0" />

<!-- Testing -->
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="NUnit" Version="4.3.2" />
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
<!-- [![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)

Expand Down
21 changes: 20 additions & 1 deletion build/mailtrap-nuget.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>icon.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageProjectUrl>https://github.com/railsware/mailtrap-dotnet</PackageProjectUrl>
<PackageProjectUrl>https://railsware.github.io/mailtrap-dotnet</PackageProjectUrl>
<RepositoryUrl>https://github.com/railsware/mailtrap-dotnet</RepositoryUrl>

<!--
Expand All @@ -25,13 +25,27 @@
<PackageAssetsDirectory>$([MSBuild]::NormalizeDirectory('$(BaseDirectory)', 'assets'))</PackageAssetsDirectory>

<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<EnablePackageValidation>true</EnablePackageValidation>
</PropertyGroup>

<PropertyGroup Label="MinVer Settings">
<MinVerTagPrefix>v</MinVerTagPrefix>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.DotNet.ApiCompat.Task">
<TreatAsUsed>true</TreatAsUsed>
</PackageReference>

<PackageReference Include="Microsoft.SourceLink.GitHub">
<TreatAsUsed>true</TreatAsUsed>
<PrivateAssets>all</PrivateAssets>
</PackageReference>

<PackageReference Include="MinVer">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand All @@ -45,6 +59,11 @@
<PackagePath>\</PackagePath>
<Visible>false</Visible>
</None>

<None Include="$(BaseDirectory)LICENSE.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

</Project>
3 changes: 2 additions & 1 deletion src/Mailtrap.Abstractions/Mailtrap.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
<RootNamespace>Mailtrap</RootNamespace>

<Title>Mailtrap Client Abstractions</Title>
<Description>Provides abstractions for the Mailtrap .NET SDK.</Description>
<PackageId>Mailtrap.Abstractions</PackageId>
<PackageTags>mailtrap; sdk; client; abstractions; email; smtp</PackageTags>
<PackageTags>mailtrap; sdk; client; email; abstractions</PackageTags>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/Mailtrap.Abstractions/README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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
Expand Down
Loading