-
Notifications
You must be signed in to change notification settings - Fork 1
60 lines (50 loc) · 1.88 KB
/
ci_main.yml
File metadata and controls
60 lines (50 loc) · 1.88 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
name: CI
on:
push:
branches: [ main ]
paths:
- "**/*.csproj"
- "Directory.Build.props"
- ".github/workflows/ci.yml"
jobs:
pack-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
VERSION_SUFFIX: ""
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.304'
- name: Prepare NuGet.config (GitHub Packages + nuget.org)
run: |
cat > ./nuget.config <<'EOF'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="github" value="https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<github>
<add key="Username" value="${{ github.actor }}" />
<add key="ClearTextPassword" value="${{ secrets.GITHUB_TOKEN }}" />
</github>
</packageSourceCredentials>
</configuration>
EOF
dotnet nuget list source --configfile ./nuget.config
- name: Set VERSION suffix for CI
run: echo "VERSION_SUFFIX=-ci-$(date +'%Y%m%d%H%M%S').${{ github.run_number }}" >> $GITHUB_ENV
- name: Restore
run: dotnet restore --configfile ./nuget.config
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Pack
run: dotnet pack --no-build --configuration Release -o ./artifacts /p:VersionSuffix="${{ env.VERSION_SUFFIX }}"
- name: Push to GitHub Packages
run: dotnet nuget push "./artifacts/*.nupkg" --skip-duplicate --source "github" --api-key "${{ secrets.GITHUB_TOKEN }}" --configfile ./nuget.config