Skip to content

Commit 8f1f2c4

Browse files
committed
Simplify and enhance NuGet publish workflow with flexible tag triggers, version logging, and updated action versions.
1 parent e6d6209 commit 8f1f2c4

1 file changed

Lines changed: 22 additions & 16 deletions

File tree

.github/workflows/nuget-publish.yml

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,49 @@
1-
name: Publish NuGet Package
1+
name: Publish to NuGet
22

33
on:
44
push:
55
tags:
6-
- '[0-9]+.[0-9]+.[0-9]+'
7-
- '[0-9]+.[0-9]+.[0-9]+-*'
6+
- '*'
7+
workflow_dispatch:
88

99
jobs:
1010
publish:
1111
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
1214

1315
steps:
1416
- name: Checkout code
1517
uses: actions/checkout@v4
1618

17-
- name: Extract version from tag
18-
id: get_version
19-
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
20-
21-
- name: Setup .NET 9.0
19+
- name: Setup .NET
2220
uses: actions/setup-dotnet@v4
2321
with:
2422
dotnet-version: '9.0.x'
2523

26-
- name: Restore dependencies
27-
run: dotnet restore ./src/NullOpsDevs.Bootstrap/NullOpsDevs.Bootstrap.csproj
24+
- name: Extract version from tag
25+
id: get_version
26+
run: |
27+
TAG_NAME=${GITHUB_REF#refs/tags/}
28+
echo "VERSION=$TAG_NAME" >> $GITHUB_OUTPUT
29+
echo "Building version: $TAG_NAME"
2830
29-
- name: Build
30-
run: dotnet build ./src/NullOpsDevs.Bootstrap/NullOpsDevs.Bootstrap.csproj --configuration Release --no-restore /p:Version=${{ steps.get_version.outputs.VERSION }}
31+
- name: Build library with version
32+
run: dotnet build -c Release /p:Version=${{ steps.get_version.outputs.VERSION }} ./src/NullOpsDevs.Bootstrap/NullOpsDevs.Bootstrap.csproj
3133

32-
- name: Pack
33-
run: dotnet pack ./src/NullOpsDevs.Bootstrap/NullOpsDevs.Bootstrap.csproj --configuration Release --no-build --output ./artifacts /p:Version=${{ steps.get_version.outputs.VERSION }}
34+
- name: Pack NuGet package
35+
run: dotnet pack -c Release --no-build /p:Version=${{ steps.get_version.outputs.VERSION }} ./src/NullOpsDevs.Bootstrap/NullOpsDevs.Bootstrap.csproj -o ./artifacts
3436

35-
- name: Push to NuGet
37+
- name: Publish to NuGet
3638
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
3739

3840
- name: Create GitHub Release
39-
uses: softprops/action-gh-release@v1
41+
uses: softprops/action-gh-release@v2
4042
with:
43+
name: Release ${{ steps.get_version.outputs.VERSION }}
44+
tag_name: ${{ steps.get_version.outputs.VERSION }}
45+
draft: false
46+
prerelease: false
4147
files: ./artifacts/*.nupkg
4248
generate_release_notes: true
4349
env:

0 commit comments

Comments
 (0)