From 601452cdd62d64009af4acf11b6232efcf2fee8a Mon Sep 17 00:00:00 2001 From: ax-meyer <32029723+ax-meyer@users.noreply.github.com> Date: Fri, 19 May 2023 15:22:20 +0200 Subject: [PATCH] Create dotnet-build-deploy.yml --- .github/workflows/dotnet-desktop.yml | 69 ++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/dotnet-desktop.yml diff --git a/.github/workflows/dotnet-desktop.yml b/.github/workflows/dotnet-desktop.yml new file mode 100644 index 0000000..2dd7bb7 --- /dev/null +++ b/.github/workflows/dotnet-desktop.yml @@ -0,0 +1,69 @@ +name: BuildTest + +on: [push, pull_request] + +jobs: + build_and_test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest, ubuntu-latest] + defaults: + run: + working-directory: ./Source + steps: + - uses: actions/checkout@v3 + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0.x + + - name: Dotnet clean + run: dotnet clean + + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal + + + publish_nuget: + needs: [build_and_test] + if: startsWith(github.ref, 'refs/tags/v') # make sure deploy only runs on tags with version number + runs-on: windows-latest + defaults: + run: + working-directory: ./Source + + steps: + - uses: actions/checkout@v3 + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0.x + + - name: Dotnet clean + run: dotnet clean + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --configuration Release + + - name: Pack nuget + run: | + $env:RELEASE_VERSION=($env:GITHUB_REF).split("tags/v")[-1] + echo $env:RELEASE_VERSION + echo $env:GITHUB_SHA + mkdir nupkg + dotnet pack -p:PackageVersion=$env:RELEASE_VERSION -o $PWD\nupkg -p:RepositoryCommit=$env:GITHUB_SHA --configuration Release -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg + + - name: Publish nuget + run: | + cd nupkg + dotnet nuget push "**/*.nupkg" --api-key ${{secrets.NUGET_DEPLOY_KEY}} --source "https://api.nuget.org/v3/index.json" --skip-duplicate