Skip to content

Commit cb0fb90

Browse files
committed
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).
1 parent 0d70909 commit cb0fb90

File tree

1 file changed

+62
-5
lines changed

1 file changed

+62
-5
lines changed

Diff for: .github/workflows/dotnet.yml

+62-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: dotnet
33
on:
44
push:
55
branches: [master]
6+
tags: ["*"]
67
pull_request:
78
branches: [master]
89

@@ -18,12 +19,12 @@ jobs:
1819
with:
1920
fetch-depth: 0
2021

21-
- uses: gittools/actions/gitversion/[email protected].3
22+
- uses: gittools/actions/gitversion/[email protected].4
2223
with:
2324
versionSpec: "5.x"
2425

2526
- id: gitversion
26-
uses: gittools/actions/gitversion/[email protected].3
27+
uses: gittools/actions/gitversion/[email protected].4
2728

2829
- uses: actions/setup-dotnet@v1
2930
with:
@@ -55,18 +56,74 @@ jobs:
5556
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
5657
run: bash <(curl -s https://codecov.io/bash)
5758

58-
- name: NuGet Pack
59-
run: |
59+
- run: |
6060
dotnet pack \
6161
--include-source \
6262
--configuration Release \
6363
--no-build \
6464
--no-restore \
6565
-p:PackageVersion="${{ steps.gitversion.outputs.fullSemVer }}" \
6666
src/json-ld.net/json-ld.net.csproj \
67-
--output nugets/
67+
--output ${{ github.workspace }}/nugets/
6868
6969
- uses: actions/upload-artifact@v2
7070
with:
7171
name: nugets
7272
path: nugets
73+
74+
nuget-push-dev:
75+
runs-on: ubuntu-latest
76+
if: startsWith(github.ref, 'refs/tags/') != true
77+
needs: build
78+
79+
steps:
80+
- uses: actions/download-artifact@v2
81+
with:
82+
name: nugets
83+
84+
- uses: actions/setup-dotnet@v1
85+
with:
86+
dotnet-version: 3.1
87+
source-url: https://nuget.pkg.github.com/linked-data-dotnet/index.json
88+
env:
89+
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
91+
- run: dotnet nuget push "*.nupkg" --skip-duplicate --api-key ${{ secrets.GITHUB_TOKEN }}
92+
93+
nuget-push-prod:
94+
runs-on: ubuntu-latest
95+
if: startsWith(github.ref, 'refs/tags/')
96+
needs: build
97+
98+
steps:
99+
- uses: actions/download-artifact@v2
100+
with:
101+
name: nugets
102+
103+
- uses: actions/setup-dotnet@v1
104+
with:
105+
dotnet-version: 2.1.401
106+
source-url: https://api.nuget.org/v3/index.json
107+
env:
108+
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_API_KEY }}
109+
110+
- run: dotnet nuget push nugets/*.nupkg --skip-duplicate
111+
112+
release-artifacts:
113+
runs-on: ubuntu-latest
114+
needs: build
115+
if: startsWith(github.ref, 'refs/tags/')
116+
117+
steps:
118+
- uses: actions/download-artifact@v1
119+
with:
120+
name: nugets
121+
122+
- name: Upload to stable release
123+
uses: svenstaro/upload-release-action@v1-release
124+
with:
125+
repo_token: ${{ secrets.GITHUB_TOKEN }}
126+
file: nugets
127+
asset_name: json-ld.net
128+
tag: ${{ github.ref }}
129+
overwrite: true

0 commit comments

Comments
 (0)