-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (89 loc) · 2.85 KB
/
Copy pathdotnet.yml
File metadata and controls
107 lines (89 loc) · 2.85 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Build, Test, and Publish
on:
workflow_dispatch:
push:
tags:
- "v*"
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
runs-on: ubuntu-latest
env:
USE_TESTCONTAINERS: true
strategy:
matrix:
dotnet: [ '6.0.x', '8.0.x', '9.0.x', '10.0.x' ]
steps:
- uses: actions/checkout@v4
- name: Debug - List directory structure
run: |
echo "Root directory contents:"
ls -la
echo ""
echo "StateCheckpoint.NET directory contents:"
ls -la ./StateCheckpoint.NET || echo "Checkpoint.NET folder does not exist"
echo ""
echo "Looking for .sln files:"
find . -name "*.sln" -type f
shell: bash
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet }}
- name: Restore dependencies
run: dotnet restore StateCheckpoint.NET/StateCheckpoint.NET/StateCheckpoint.NET.csproj
- name: Build
run: dotnet build StateCheckpoint.NET/StateCheckpoint.NET/StateCheckpoint.NET.csproj --no-restore --configuration Release
- name: Run tests
run: dotnet test StateCheckpoint.NET/StateCheckpoint.NET/StateCheckpoint.NET.csproj --no-build --configuration Release --verbosity normal
publish:
name: Publish to NuGet
runs-on: ubuntu-latest
needs: test
if: startsWith(github.ref, 'refs/tags/v')
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Display tag version
run: echo "Tag version = ${GITHUB_REF#refs/tags/v}"
- name: Pack NuGet package
run: |
dotnet pack StateCheckpoint.NET/StateCheckpoint.NET/StateCheckpoint.NET.csproj \
--configuration Release \
--output ./nupkgs \
-p:PackageVersion="${GITHUB_REF#refs/tags/v}" \
-p:IncludeSymbols=false \
-p:IncludeSource=false
- name: List nupkg files
run: ls -la ./nupkgs
- name: Get OIDC token
id: oidc
uses: actions/github-script@v7
with:
script: |
const token = await core.getIDToken('api://NuGet');
core.setOutput('token', token);
- name: Push to NuGet.org
env:
NUGET_AUTH_TOKEN: ${{ steps.oidc.outputs.token }}
run: |
for pkg in ./nupkgs/*.nupkg; do
if [ -f "$pkg" ]; then
echo "Pushing $pkg"
dotnet nuget push "$pkg" \
--source "https://api.nuget.org/v3/index.json" \
--api-key "$NUGET_AUTH_TOKEN" \
--skip-duplicate
else
echo "No .nupkg files found"
exit 1
fi
done