Skip to content

Commit 32ef660

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 32ef660

File tree

1 file changed

+60
-5
lines changed

1 file changed

+60
-5
lines changed

.github/workflows/dotnet.yml

+60-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,72 @@ 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+
89+
- run: dotnet nuget push "*.nupkg" --skip-duplicate --api-key ${{ secrets.GITHUB_TOKEN }}
90+
91+
nuget-push-prod:
92+
runs-on: ubuntu-latest
93+
if: startsWith(github.ref, 'refs/tags/')
94+
needs: build
95+
96+
steps:
97+
- uses: actions/download-artifact@v2
98+
with:
99+
name: nugets
100+
101+
- uses: actions/setup-dotnet@v1
102+
with:
103+
dotnet-version: 2.1.401
104+
source-url: https://api.nuget.org/v3/index.json
105+
env:
106+
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_API_KEY }}
107+
108+
- run: dotnet nuget push nugets/*.nupkg --skip-duplicate
109+
110+
release-artifacts:
111+
runs-on: ubuntu-latest
112+
needs: build
113+
if: startsWith(github.ref, 'refs/tags/')
114+
115+
steps:
116+
- uses: actions/download-artifact@v1
117+
with:
118+
name: nugets
119+
120+
- name: Upload to stable release
121+
uses: svenstaro/upload-release-action@v1-release
122+
with:
123+
repo_token: ${{ secrets.GITHUB_TOKEN }}
124+
file: nugets
125+
asset_name: json-ld.net
126+
tag: ${{ github.ref }}
127+
overwrite: true

0 commit comments

Comments
 (0)