Settings #387
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 and publish release | |
on: | |
push: | |
branches: [ main, develop ] | |
pull_request: | |
branches: [ main, develop ] | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build and publish release | |
runs-on: ubuntu-latest | |
steps: | |
# https://github.com/marketplace/actions/setup-net-core-sdk | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.x | |
# https://github.com/marketplace/actions/checkout | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# https://github.com/marketplace/actions/nerdbank-gitversioning | |
- name: Run Nerdbank.GitVersioning | |
id: nbgv | |
uses: dotnet/nbgv@master | |
# https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test | |
- name: Run unit tests | |
run: dotnet test ./UtilitiesTests/UtilitiesTests.csproj | |
# https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-build | |
- name: Build project | |
run: >- | |
dotnet build ./Utilities/Utilities.csproj | |
--output ./Publish/ | |
--configuration ${{ endsWith(github.ref, 'refs/heads/main') && 'Release' || 'Debug' }} | |
-property:Version=${{ steps.nbgv.outputs.AssemblyVersion }} | |
-property:FileVersion=${{ steps.nbgv.outputs.AssemblyFileVersion }} | |
-property:AssemblyVersion=${{ steps.nbgv.outputs.AssemblyVersion }} | |
-property:InformationalVersion=${{ steps.nbgv.outputs.AssemblyInformationalVersion }} | |
-property:PackageVersion=${{ steps.nbgv.outputs.SemVer2 }} | |
# https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push | |
- name: Publish to NuGet.org | |
if: ${{ github.event_name != 'pull_request' }} | |
run: >- | |
dotnet nuget push ${{ github.workspace }}/Publish/*.nupkg | |
--source https://api.nuget.org/v3/index.json | |
--api-key ${{ secrets.NUGET_API_KEY }} | |
--skip-duplicate | |
# https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry | |
- name: Publish to GitHub NuGet Registry | |
if: ${{ github.event_name != 'pull_request' }} | |
run: >- | |
dotnet nuget push ${{ github.workspace }}/Publish/*.nupkg | |
--source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json | |
--api-key ${{ secrets.GITHUB_TOKEN }} | |
--skip-duplicate | |
- name: Zip output | |
if: ${{ github.event_name != 'pull_request' }} | |
run: 7z a -t7z ./Publish/Utilities.7z ./Publish/* | |
# https://github.com/marketplace/actions/gh-release | |
- name: Create GitHub release | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: softprops/action-gh-release@v2 | |
with: | |
generate_release_notes: true | |
tag_name: ${{ steps.nbgv.outputs.SemVer2 }} | |
prerelease: ${{ !endsWith(github.ref, 'refs/heads/main') }} | |
files: | | |
LICENSE | |
./Publish/Utilities.7z |