Bumped MimeKit #1270
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: [push, pull_request, workflow_dispatch] | |
jobs: | |
ci: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ windows-latest, ubuntu-latest ] | |
build-configuration: [ Debug, Release ] | |
outputs: | |
latest-version: ${{ steps.semantic_version.outputs.version_num }} | |
environment: ci | |
env: | |
SOLUTION_PATH: MailKit.sln | |
BUILD_PLATFORM: Any CPU | |
BUILD_CONFIGURATION: ${{ matrix.build-configuration }} | |
GENERATE_CODE_COVERAGE: ${{ matrix.os == 'windows-latest' && matrix.build-configuration == 'Debug' }} | |
MONO_RUNTIME: ${{ matrix.os != 'windows-latest' }} | |
PUBLISH: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.os == 'windows-latest' && matrix.build-configuration == 'Release' }} | |
steps: | |
- name: Setup/Install the .NET 8 SDK | |
id: install-netsdk | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- if: runner.os == 'Windows' | |
name: Setup MSBuild | |
id: setup_msbuild | |
uses: microsoft/setup-msbuild@v2 | |
- name: Checkout repository | |
id: checkout_repo | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
submodules: recursive | |
fetch-depth: 0 | |
- name: Get semantic version from csproj | |
id: semantic_version | |
shell: pwsh | |
run: | | |
$xml = [xml](gc MailKit/MailKit.csproj) | |
$SEMANTIC_VERSION_NUMBER = $xml.Project.PropertyGroup.VersionPrefix | |
$VERSION_NUM = $SEMANTIC_VERSION_NUMBER[0].Trim() | |
Write-Host "version_num=${VERSION_NUM}" | |
[IO.File]::AppendAllText($env:GITHUB_OUTPUT, "version_num=${VERSION_NUM}$([Environment]::NewLine)") | |
- if: ${{ env.PUBLISH == 'true' }} | |
name: Get latest tag | |
id: get_latest_tag | |
shell: pwsh | |
run: | | |
$LATEST_TAG = git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags "https://github.com/$env:GIT_URL.git" '*.*.*' | tail --lines=1 | cut --delimiter='/' --fields=3 | |
Write-Host "tag=$LATEST_TAG" | |
[IO.File]::AppendAllText($env:GITHUB_OUTPUT, "tag=${LATEST_TAG}$([Environment]::NewLine)") | |
env: | |
GIT_URL: ${{ github.repository }} | |
- if: ${{ env.PUBLISH == 'true' && steps.semantic_version.outputs.version_num != steps.get_latest_tag.outputs.tag }} | |
name: Add new tag to repo | |
id: add_new_tag_to_repo | |
continue-on-error: true | |
shell: pwsh | |
run: | | |
git config --global user.name $env:GIT_USER_NAME | |
git config --global user.email $env:GIT_USER_EMAIL | |
git tag -a -m "Tagged for $env:NEW_VERSION_NUM" $env:NEW_VERSION_NUM | |
git push --follow-tags | |
env: | |
GIT_USER_NAME: ${{ github.event.head_commit.author.username }} | |
GIT_USER_EMAIL: ${{ github.event.head_commit.author.email }} | |
NEW_VERSION_NUM: ${{ steps.semantic_version.outputs.version_num }} | |
- name: Run .NET restore | |
shell: pwsh | |
run: | | |
dotnet restore $env:SOLUTION_PATH | |
- name: Run .NET tool restore | |
shell: pwsh | |
run: | | |
dotnet tool restore | |
- name: Build solution | |
id: build_solution | |
continue-on-error: true | |
shell: pwsh | |
run: | | |
dotnet msbuild $env:SOLUTION_PATH -property:Platform=$env:BUILD_PLATFORM -property:Configuration=$env:BUILD_CONFIGURATION -property:MonoRuntime=$env:MONO_RUNTIME | |
- name: Run unit tests | |
id: run_unit_tests | |
continue-on-error: true | |
shell: pwsh | |
run: | | |
& ./scripts/test.ps1 -Configuration:$env:BUILD_CONFIGURATION -GenerateCodeCoverage:$env:GENERATE_CODE_COVERAGE | |
- name: Upload unit test results | |
id: upload_test_results | |
continue-on-error: true | |
uses: actions/upload-artifact@v4 | |
with: | |
name: MailKit.${{ steps.semantic_version.outputs.version_num }}.${{ github.run_number }}-${{ matrix.os }}-${{ matrix.build-configuration }}-TestResults.xml | |
path: TestResult.xml | |
- if: ${{ env.GENERATE_CODE_COVERAGE == 'true' }} | |
name: Upload code coverage data to coveralls.io | |
id: upload_to_coveralls | |
shell: pwsh | |
run: | | |
& ./scripts/coveralls.ps1 | |
env: | |
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} | |
GIT_COMMIT_SHA: ${{ github.sha }} | |
GIT_REF: ${{ github.ref }} | |
GIT_ACTOR: ${{ github.event.head_commit.author.username }} | |
GIT_ACTOR_EMAIL: ${{ github.event.head_commit.author.email }} | |
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | |
COVERALLS_JOB_ID: ${{ steps.semantic_version.outputs.version_num }}.${{ github.run_number }} | |
- if: ${{ env.PUBLISH == 'true' }} | |
name: Create NuGet package | |
id: create_nuget_package | |
shell: pwsh | |
run: | | |
nuget pack nuget/MailKit.nuspec -Version "$env:LATEST_VERSION.$env:GITHUB_RUN_NUMBER" | |
env: | |
LATEST_VERSION: ${{ steps.semantic_version.outputs.version_num }} | |
- if: ${{ env.PUBLISH == 'true' }} | |
name: Push NuGet package to MyGet | |
id: push_nuget_package | |
shell: pwsh | |
run: | | |
nuget push $env:NUGET_PKG_PATH -ApiKey $env:MYGET_API_KEY -Source https://www.myget.org/F/mimekit/api/v3/index.json | |
env: | |
NUGET_PKG_PATH: MailKit.${{ steps.semantic_version.outputs.version_num }}.${{ github.run_number }}.nupkg | |
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }} | |
- if: ${{ env.PUBLISH == 'true' }} | |
name: Upload NuGet package as artifact | |
id: upload_nuget_package | |
uses: actions/upload-artifact@v4 | |
with: | |
name: MailKit.${{ steps.semantic_version.outputs.version_num }}.${{ github.run_number }}.nupkg | |
path: MailKit.${{ steps.semantic_version.outputs.version_num }}.${{ github.run_number }}.nupkg | |
# Built with ❤ by [Pipeline Foundation](https://pipeline.foundation) |