-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (45 loc) · 1.49 KB
/
publish.yml
File metadata and controls
55 lines (45 loc) · 1.49 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
name: Publish to NuGet
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., 1.0.1)'
required: true
type: string
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Set version
run: |
if [ "${{ github.event_name }}" == "release" ]; then
VERSION=${{ github.event.release.tag_name }}
else
VERSION=${{ github.event.inputs.version }}
fi
echo "VERSION=${VERSION#v}" >> $GITHUB_ENV
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Run tests
run: dotnet test --no-restore --verbosity normal
- name: Pack
run: dotnet pack src/CodeContext.CLI/CodeContext.CLI.csproj --configuration Release --no-build -p:Version=${{ env.VERSION }} -o ./artifacts
- name: Push to NuGet
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
if [ -z "$NUGET_API_KEY" ]; then
echo "Warning: NUGET_API_KEY not set. Skipping NuGet push."
echo "To enable automatic publishing, add NUGET_API_KEY to repository secrets."
exit 0
fi
dotnet nuget push ./artifacts/*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json --skip-duplicate