Skip to content

Commit

Permalink
Add jobs for package publishing
Browse files Browse the repository at this point in the history
- 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).
  • Loading branch information
asbjornu committed Oct 1, 2020
1 parent 0d70909 commit e6797aa
Showing 1 changed file with 62 additions and 5 deletions.
67 changes: 62 additions & 5 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: dotnet
on:
push:
branches: [master]
tags: ["*"]
pull_request:
branches: [master]

Expand All @@ -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:
Expand Down Expand Up @@ -55,18 +56,74 @@ 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 \
--no-build \
--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

0 comments on commit e6797aa

Please sign in to comment.