-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (71 loc) · 2.42 KB
/
publish.yml
File metadata and controls
86 lines (71 loc) · 2.42 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
86
name: Publish to NuGet
on:
push:
tags:
- 'v*.*.*' # e.g., v1.2.0
workflow_dispatch:
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build solution
run: dotnet build --no-restore --configuration Release
- name: Run unit tests
run: dotnet test ./tests --no-build --configuration Release --verbosity normal
publish:
needs: build-and-test
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set-version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build solution
run: dotnet build --no-restore --configuration Release
- name: Extract version from tag
id: set-version
run: |
VERSION="${GITHUB_REF#refs/tags/v}"
echo "Using version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Pack NuGet packages
run: |
VERSION=${{ steps.set-version.outputs.version }}
dotnet pack src/${{ github.event.repository.name }}.csproj \
--configuration Release \
--no-build \
-p:PackageVersion=$VERSION \
-p:IncludeSymbols=true \
-p:SymbolPackageFormat=snupkg
- name: Show packed files
run: ls -lh src/bin/Release
- name: Push NuGet packages
run: |
for pkg in $(find src/bin/Release -name "*.nupkg" ! -name "*.symbols.nupkg" ! -name "*.snupkg"); do
echo "Pushing main package: $pkg"
dotnet nuget push "$pkg" \
--api-key "${{ secrets.NUGET_API_KEY }}" \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
done
for symbols in $(find src/bin/Release -name "*.snupkg"); do
echo "Pushing symbol package: $symbols"
dotnet nuget push "$symbols" \
--api-key "${{ secrets.NUGET_API_KEY }}" \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
done