-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (112 loc) · 3.53 KB
/
Copy pathpublish.yml
File metadata and controls
130 lines (112 loc) · 3.53 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Publish NuGet Package
on:
workflow_dispatch:
inputs:
tag:
description: Existing Git tag to publish from
required: true
type: string
package:
description: NuGet package to publish
required: true
type: choice
options:
- TokenGuard.Core
- TokenGuard.Extensions.OpenAI
- TokenGuard.Extensions.Anthropic
permissions: {}
concurrency:
group: nuget-publish-${{ inputs.package }}-${{ inputs.tag }}
cancel-in-progress: false
jobs:
validate:
name: Validate and pack
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout tagged source
uses: actions/checkout@v4
with:
ref: refs/tags/${{ inputs.tag }}
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Select package project
id: package
shell: bash
env:
PACKAGE_ID: ${{ inputs.package }}
run: |
case "$PACKAGE_ID" in
TokenGuard.Core)
project="src/TokenGuard.Core/TokenGuard.Core.csproj"
;;
TokenGuard.Extensions.OpenAI)
project="src/TokenGuard.Extensions.OpenAI/TokenGuard.Extensions.OpenAI.csproj"
;;
TokenGuard.Extensions.Anthropic)
project="src/TokenGuard.Extensions.Anthropic/TokenGuard.Extensions.Anthropic.csproj"
;;
*)
echo "Unsupported package: $PACKAGE_ID" >&2
exit 1
;;
esac
echo "project=$project" >> "$GITHUB_OUTPUT"
- name: Restore solution
run: dotnet restore TokenGuard.sln --nologo
- name: Build solution
run: dotnet build TokenGuard.sln --configuration Release --no-restore --nologo
- name: Run test suites
run: dotnet test TokenGuard.sln --configuration Release --no-build --nologo
- name: Pack selected package
run: dotnet pack "${{ steps.package.outputs.project }}" --configuration Release --no-build --nologo --output artifacts/release
- name: Upload package artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: |
artifacts/release/*.nupkg
artifacts/release/*.snupkg
if-no-files-found: error
retention-days: 1
publish:
name: Publish to nuget.org
needs: validate
runs-on: ubuntu-latest
environment: release
permissions:
contents: read
id-token: write
steps:
- name: Download package artifacts
uses: actions/download-artifact@v4
with:
name: nuget-package
path: artifacts/release
- name: NuGet login
id: login
uses: NuGet/login@v1
with:
user: ${{ vars.NUGET_USER }}
- name: Publish package
shell: bash
env:
NUGET_API_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}
run: |
dotnet nuget push artifacts/release/*.nupkg \
--source https://api.nuget.org/v3/index.json \
--api-key "$NUGET_API_KEY" \
--skip-duplicate \
--no-symbols
- name: Publish symbols
shell: bash
env:
NUGET_API_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}
run: |
dotnet nuget push artifacts/release/*.snupkg \
--source https://api.nuget.org/v3/index.json \
--api-key "$NUGET_API_KEY" \
--skip-duplicate