-
Notifications
You must be signed in to change notification settings - Fork 2
69 lines (58 loc) · 2.24 KB
/
Copy pathpublish.yml
File metadata and controls
69 lines (58 loc) · 2.24 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
name: Publish to NuGet
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Package version (leave empty to use csproj version)"
required: false
type: string
jobs:
publish:
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write # Required for OIDC token exchange with NuGet
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
10.0.x
- name: Determine version
id: version
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
# Strip leading 'v' from tag (v1.0.2 → 1.0.2)
VERSION="${{ github.event.release.tag_name }}"
VERSION="${VERSION#v}"
elif [[ -n "${{ inputs.version }}" ]]; then
VERSION="${{ inputs.version }}"
else
# Read from csproj
VERSION=$(grep -oP '<Version>\K[^<]+' src/ElBruno.HuggingFace.Downloader/ElBruno.HuggingFace.Downloader.csproj)
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "📦 Publishing version: $VERSION"
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build -c Release --no-restore -p:Version=${{ steps.version.outputs.version }}
- name: Test
run: dotnet test -c Release --no-build --verbosity normal
- name: Pack
run: |
dotnet pack src/ElBruno.HuggingFace.Downloader/ElBruno.HuggingFace.Downloader.csproj -c Release --no-build -p:Version=${{ steps.version.outputs.version }} -o artifacts
dotnet pack src/ElBruno.HuggingFace.Downloader.Cli/ElBruno.HuggingFace.Downloader.Cli.csproj -c Release --no-build -p:Version=${{ steps.version.outputs.version }} -o artifacts
- name: NuGet login (OIDC → temp API key)
uses: NuGet/login@v1
id: login
with:
user: ${{ secrets.NUGET_USER }}
- name: Push to NuGet.org
run: dotnet nuget push artifacts/*.nupkg --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate