-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (71 loc) · 2.04 KB
/
release.yml
File metadata and controls
85 lines (71 loc) · 2.04 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Release
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g. 1.0.0)'
required: true
type: string
permissions:
contents: read
jobs:
pack-and-publish:
name: Pack & Publish to NuGet
runs-on: ubuntu-latest
env:
CI: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDKs
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', 'Directory.Packages.props') }}
restore-keys: |
nuget-${{ runner.os }}-
- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ inputs.version }}"
else
# Strip 'v' prefix from tag: v1.2.3 -> 1.2.3
VERSION="${GITHUB_REF_NAME#v}"
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Publishing version: $VERSION"
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --no-restore -c Release
- name: Test
run: dotnet test --no-build -c Release
- name: Pack
run: >-
dotnet pack --no-build -c Release
-p:VersionPrefix=${{ steps.version.outputs.version }}
--output ./packages
- name: Upload NuGet packages
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: |
./packages/*.nupkg
./packages/*.snupkg
retention-days: 90
- name: Publish to NuGet.org
run: >-
dotnet nuget push ./packages/*.nupkg
--api-key ${{ secrets.NUGET_API_KEY }}
--source https://api.nuget.org/v3/index.json
--skip-duplicate