From e6797aa9160ae431d2519623f34e73f45ac8370d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Ulsberg?= Date: Thu, 1 Oct 2020 23:21:07 +0200 Subject: [PATCH] Add jobs for package publishing - Add NuGet push to production job `nuget-push-prod`. - Add NuGet push to development job `nuget-push-dev`. - Add job `release-artifacts` to upload `.nuget` to the GitHub Release corresponding to the current tag (if any). --- .github/workflows/dotnet.yml | 67 +++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 1bf1d78..9370559 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -3,6 +3,7 @@ name: dotnet on: push: branches: [master] + tags: ["*"] pull_request: branches: [master] @@ -18,12 +19,12 @@ jobs: with: fetch-depth: 0 - - uses: gittools/actions/gitversion/setup@v0.9.3 + - uses: gittools/actions/gitversion/setup@v0.9.4 with: versionSpec: "5.x" - id: gitversion - uses: gittools/actions/gitversion/execute@v0.9.3 + uses: gittools/actions/gitversion/execute@v0.9.4 - uses: actions/setup-dotnet@v1 with: @@ -55,8 +56,7 @@ jobs: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} run: bash <(curl -s https://codecov.io/bash) - - name: NuGet Pack - run: | + - run: | dotnet pack \ --include-source \ --configuration Release \ @@ -64,9 +64,66 @@ jobs: --no-restore \ -p:PackageVersion="${{ steps.gitversion.outputs.fullSemVer }}" \ src/json-ld.net/json-ld.net.csproj \ - --output nugets/ + --output ${{ github.workspace }}/nugets/ - uses: actions/upload-artifact@v2 with: name: nugets path: nugets + + nuget-push-dev: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') != true + needs: build + + steps: + - uses: actions/download-artifact@v2 + with: + name: nugets + + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: 2.1.401 + source-url: https://nuget.pkg.github.com/linked-data-dotnet/json-ld.net/index.json + env: + NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} + + - run: dotnet nuget push nugets/*.nupkg --source https://nuget.pkg.github.com/linked-data-dotnet/json-ld.net/index.json --skip-duplicate + + nuget-push-prod: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + needs: build + + steps: + - uses: actions/download-artifact@v2 + with: + name: nugets + + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: 2.1.401 + source-url: https://api.nuget.org/v3/index.json + env: + NUGET_AUTH_TOKEN: ${{ secrets.NUGET_API_KEY }} + + - run: dotnet nuget push nugets/*.nupkg --skip-duplicate + + release-artifacts: + runs-on: ubuntu-latest + needs: build + if: startsWith(github.ref, 'refs/tags/') + + steps: + - uses: actions/download-artifact@v1 + with: + name: nugets + + - name: Upload to stable release + uses: svenstaro/upload-release-action@v1-release + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: nugets + asset_name: json-ld.net + tag: ${{ github.ref }} + overwrite: true