1+ name : Publish V.Tag to NuGet.org
2+
3+ on :
4+ push :
5+ # publish only on tags like v1.2.3 (or v1.2)
6+ tags :
7+ - ' v*'
8+ workflow_dispatch :
9+
10+ jobs :
11+ publish :
12+ runs-on : ubuntu-latest
13+ steps :
14+ - name : Checkout
15+ uses : actions/checkout@v4
16+
17+ - name : Setup .NET
18+ uses : actions/setup-dotnet@v4
19+ with :
20+ dotnet-version : ' 10.0.x'
21+
22+ - name : Restore
23+ run : dotnet restore
24+
25+ - name : Build
26+ run : dotnet build --configuration Release --no-restore
27+
28+ - name : Test
29+ run : dotnet test --no-build --verbosity normal
30+ continue-on-error : false
31+
32+ - name : Determine package version
33+ id : version
34+ run : |
35+ # If this run was triggered by a tag, extract the tag name and strip a leading "v" if present.
36+ if [[ "$GITHUB_REF" == refs/tags/* ]]; then
37+ tag=${GITHUB_REF#refs/tags/}
38+ # strip leading v if present
39+ tag=${tag#v}
40+ echo "PACKAGE_VERSION=$tag" >> $GITHUB_ENV
41+ else
42+ # fallback CI version if not a tag
43+ echo "PACKAGE_VERSION=0.0.0-ci-${GITHUB_SHA::7}" >> $GITHUB_ENV
44+ fi
45+ echo "Determined PACKAGE_VERSION=$PACKAGE_VERSION"
46+
47+ - name : Pack
48+ run : |
49+ mkdir -p artifacts
50+ # pack all projects that should produce nuget packages, or specify a project file instead of '.'
51+ dotnet pack --configuration Release --no-build -o artifacts /p:PackageVersion=${PACKAGE_VERSION}
52+
53+ - name : Publish to nuget.org
54+ env :
55+ NUGET_API_KEY : ${{ secrets.SharpGLTF_PublishToNuget }}
56+ run : |
57+ # push all packages created in artifacts to nuget.org
58+ dotnet nuget push "artifacts/*.nupkg" \
59+ --api-key "$NUGET_API_KEY" \
60+ --source "https://api.nuget.org/v3/index.json" \
61+ --skip-duplicate
0 commit comments