Skip to content

.NET Release

.NET Release #22

Workflow file for this run

# 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: .NET Release
on:
workflow_dispatch:
inputs:
pre_release:
required: true
type: boolean
description: Pre-Release - determines if the workflow should be run in pre release mode
version_mask:
required: true
type: string
description: Version mask - four digits separated by '.'. Each digit tells which number and by how much to bump in version
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: .NET Tool Restore
run: dotnet tool restore
- name: Set Input Parameters
run: |
VERSION_SUFFIX=$(if [ "${{ inputs.pre_release }}" == "true" ]; then echo "rc"; else echo ""; fi)
CONFIGURATION=$(if [ "${{ inputs.pre_release }}" == "true" ]; then echo "Debug"; else echo "Release"; fi)
echo "CONFIGURATION=$CONFIGURATION"
echo "CONFIGURATION=$CONFIGURATION" >> $GITHUB_ENV
echo "VERSION_SUFFIX=$VERSION_SUFFIX"
echo "VERSION_SUFFIX=$VERSION_SUFFIX" >> $GITHUB_ENV
- name: Version Bump
uses: ./.github/actions/bump-version
with:
version_mask: ${{ inputs.version_mask }}
version_file: "version.xml"
- name: Set Version Env Var
shell: pwsh
run: |
$lib_ver=(Select-Xml -Path ./version.xml -XPath '/Version' | Select-Object -ExpandProperty Node).InnerText
$full_ver=if ("${{ inputs.pre_release }}" -eq "true") {
"$lib_ver-${{ env.VERSION_SUFFIX }}"
} else {
"$lib_ver"
}
$tag="v$full_ver"
Add-Content -Path "$env:GITHUB_ENV" -Value "LIBRARY_VERSION=$lib_ver"
Add-Content -Path "$env:GITHUB_ENV" -Value "FULL_LIBRARY_VERSION=$full_ver"
Add-Content -Path "$env:GITHUB_ENV" -Value "LIBRARY_TAG=$tag"
- name: Build & Test
uses: ./.github/actions/build-n-test
with:
library_version: ${{ env.LIBRARY_VERSION }}
version_suffix: ${{ env.VERSION_SUFFIX }}
configuration: ${{ env.CONFIGURATION }}
gist_key: ${{ secrets.GH_GIST_API_KEY }}
- name: Publish NuGet Packages
run: |
mkdir ./package
cp ./src/TempMail.Client/bin/${{ env.CONFIGURATION }}/TempMail.Client.*.nupkg ./package
cp ./src/TempMail.Client.AspNetCore/bin/${{ env.CONFIGURATION }}/TempMail.Client.AspNetCore.*.nupkg ./package
dotnet nuget push ./package/TempMail.Client.*.nupkg -k ${{ secrets.NUGET_ORG_API_KEY }} -s https://api.nuget.org/v3/index.json
- name: GitHub Tag
uses: IIlyichev/github-tag-action@v6.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ env.LIBRARY_TAG }}
tag_prefix: ""
- name: GitHub Release
uses: softprops/action-gh-release@v2
with:
body: "## NuGet Packages: \n* [TempMail.Client](https://www.nuget.org/packages/TempMail.Client/${{ env.FULL_LIBRARY_VERSION }}) \n* [TempMail.Client.AspNetCore](https://www.nuget.org/packages/TempMail.Client.AspNetCore/${{ env.FULL_LIBRARY_VERSION }})"
prerelease: ${{ inputs.pre_release }}
tag_name: ${{ env.LIBRARY_TAG }}
name: ${{ env.LIBRARY_TAG }}
generate_release_notes: true
append_body: true
files: ./package/*