-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (92 loc) · 2.9 KB
/
publish.yml
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Publish
on:
workflow_dispatch: # Allow running the workflow manually from the GitHub UI
push:
branches:
- 'main'
pull_request:
branches:
- '*'
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: [ '9.0.x' ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for version calculation
- name: Setup .NET ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Display dotnet version
run: dotnet --info
- name: Restore dependencies
run: dotnet restore
- name: Build solution
run: dotnet build -c Release --no-restore /p:ContinuousIntegrationBuild=true
- name: Run tests
run: dotnet test -c Release --no-build --verbosity normal
# Package will be created for both target frameworks
- name: Create NuGet package
run: dotnet pack -c Release --no-build --include-symbols -p:SymbolPackageFormat=snupkg
- name: Upload NuGet Package Artifact
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: |
src/MailFusion/bin/Release/*.nupkg
src/MailFusion/bin/Release/*.snupkg
validate:
if: github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Download NuGet Package Artifact
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: artifacts
- name: Install Meziantou NuGet Package Validation Tool
run: dotnet tool install --global Meziantou.Framework.NuGetPackageValidation.Tool
- name: Validate NuGet Package
run: |
for package in artifacts/*.nupkg; do
echo "Validating package: $package"
meziantou.validate-nuget-package "$package"
done
publish:
if: github.ref == 'refs/heads/main'
needs: validate
runs-on: ubuntu-latest
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Download NuGet Package Artifact
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: artifacts
- name: Publish to NuGet
run: |
for package in artifacts/*.nupkg; do
dotnet nuget push "$package" \
--api-key ${{ secrets.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
done
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}