From 30c8b491c15aacd74f331f68eaa9ebb25dd9dbca Mon Sep 17 00:00:00 2001 From: Jon Nuttall Date: Sat, 30 Dec 2023 21:53:51 +0000 Subject: [PATCH] Create dotnet.yml --- .github/workflows/dotnet.yml | 61 ++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/dotnet.yml diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 0000000..a33a20e --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,61 @@ +name: Build + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + - name: Checkout + uses: actions/checkout@v1 + - name: Setup .NET Core 6.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '6.0.x' + - name: Build + run: dotnet build --configuration Release + - name: Test + run: dotnet test --no-build --configuration Release + pack: + runs-on: ubuntu-latest + needs: build + if: github.event_name == 'push' + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Setup .NET Core 6.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '6.0.x' + - name: Determine version + run: echo "::set-env name=VERSION::$(git describe --tags --dirty)" + - name: Pack + run: dotnet pack --output ./artifacts --configuration Release -p:Version=$VERSION + - uses: actions/upload-artifact@v1 + with: + name: artifacts + path: ./artifacts + publish: + runs-on: ubuntu-latest + needs: pack + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + steps: + - name: Setup .NET Core 6.0 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '6.0.x' + - uses: actions/download-artifact@v1 + with: + name: artifacts + path: ./artifacts + - name: Publish packages + run: dotnet nuget push ./artifacts/**.nupkg --source nuget.org --api-key ${{secrets.NUGET_TOKEN}}