-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (43 loc) · 1.61 KB
/
publish.yml
File metadata and controls
55 lines (43 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: .NET Build and Publish Nuget Package
on:
push:
branches:
- "**"
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
pull_request:
branches:
- "**"
env:
VERSION: 1.0.0
defaults:
run:
working-directory: .
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set Version Variable
if: ${{ github.ref_type == 'tag' }}
env:
TAG: ${{ github.ref_name }}
run: echo "VERSION=${TAG#v}" >> $GITHUB_ENV
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore /p:Version=$VERSION
- name: Pack NuGet Packages
run: dotnet pack --configuration Release --output nupkgs --no-restore --no-build /p:PackageVersion=$VERSION
- name: Add GitHub NuGet Source
run: dotnet nuget add source --username ${{ github.repository_owner }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
- name: Upload NuGet Package
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')
run: dotnet nuget push nupkgs/*.nupkg --skip-duplicate -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
- name: Upload NuGet Package to GitHub
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')
run: dotnet nuget push nupkgs/*.nupkg --skip-duplicate -k ${{ secrets.PAT_GITHUB }} -s "github"