Skip to content

Commit 699e3c8

Browse files
committed
Replace auto-publish workflow with manual dispatch
- Removed dotnetcore.yml (auto-triggered on nuget branch and tags) - Added publish.yml with workflow_dispatch (manual only) - Publish workflow: runs tests → packs all packages → publishes to NuGet with --skip-duplicate → creates git tag automatically - Version is read from Directory.Build.props VersionPrefix or overridden via workflow input - Option to skip tests if CI already passed - All secrets passed via env vars (not inline expressions) - CI workflow (ci.yml) unchanged: still runs on push/PR to master The nuget branch is no longer needed for publishing.
1 parent 4821613 commit 699e3c8

File tree

2 files changed

+118
-85
lines changed

2 files changed

+118
-85
lines changed

.github/workflows/dotnetcore.yml

Lines changed: 0 additions & 85 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Publish NuGet Packages
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to publish (e.g. 12.0.0). Leave empty to use VersionPrefix from Directory.Build.props.'
8+
required: false
9+
type: string
10+
skip-tests:
11+
description: 'Skip test execution (use only if tests already passed on CI)'
12+
required: false
13+
type: boolean
14+
default: false
15+
16+
jobs:
17+
test:
18+
if: ${{ !inputs.skip-tests }}
19+
runs-on: ubuntu-latest
20+
21+
services:
22+
redis:
23+
image: redis:latest
24+
options: >-
25+
--health-cmd "redis-cli ping"
26+
--health-interval 10s
27+
--health-timeout 5s
28+
--health-retries 5
29+
ports:
30+
- 6379:6379
31+
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v4
35+
36+
- name: Setup dotnet
37+
uses: actions/setup-dotnet@v4
38+
with:
39+
dotnet-version: |
40+
8.0.x
41+
9.0.x
42+
10.0.x
43+
44+
- name: Run .NET 10 Tests
45+
run: dotnet test -f net10.0 --verbosity normal
46+
env:
47+
REDIS_HOST: localhost
48+
49+
- name: Run .NET 9 Tests
50+
run: dotnet test -f net9.0 --verbosity normal
51+
env:
52+
REDIS_HOST: localhost
53+
54+
publish:
55+
needs: [test]
56+
if: ${{ always() && (needs.test.result == 'success' || inputs.skip-tests) }}
57+
runs-on: ubuntu-latest
58+
59+
steps:
60+
- name: Checkout repository
61+
uses: actions/checkout@v4
62+
63+
- name: Setup dotnet
64+
uses: actions/setup-dotnet@v4
65+
with:
66+
dotnet-version: |
67+
8.0.x
68+
9.0.x
69+
10.0.x
70+
71+
- name: Determine version
72+
id: version
73+
run: |
74+
if [ -n "$INPUT_VERSION" ]; then
75+
echo "version=$INPUT_VERSION" >> "$GITHUB_OUTPUT"
76+
else
77+
VERSION=$(grep -oP '(?<=<VersionPrefix>)[^<]+' Directory.Build.props)
78+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
79+
fi
80+
env:
81+
INPUT_VERSION: ${{ inputs.version }}
82+
83+
- name: Pack all NuGet packages
84+
run: dotnet pack -c Release -o ./packages /p:Version="$PKG_VERSION"
85+
env:
86+
PKG_VERSION: ${{ steps.version.outputs.version }}
87+
88+
- name: Publish to NuGet
89+
run: |
90+
for f in ./packages/*.nupkg; do
91+
echo "Publishing $(basename "$f")"
92+
dotnet nuget push "$f" --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate
93+
done
94+
env:
95+
NUGET_API_KEY: ${{ secrets.NuGetApiKey }}
96+
97+
- name: Create Git tag
98+
run: |
99+
git config user.name "github-actions"
100+
git config user.email "github-actions@github.com"
101+
git tag -a "v$TAG_VERSION" -m "v$TAG_VERSION"
102+
git push origin "v$TAG_VERSION"
103+
env:
104+
TAG_VERSION: ${{ steps.version.outputs.version }}
105+
106+
- name: Summary
107+
run: |
108+
echo "## Published v$PKG_VERSION" >> "$GITHUB_STEP_SUMMARY"
109+
echo "" >> "$GITHUB_STEP_SUMMARY"
110+
echo "### Packages" >> "$GITHUB_STEP_SUMMARY"
111+
for f in ./packages/*.nupkg; do
112+
echo "- $(basename "$f")" >> "$GITHUB_STEP_SUMMARY"
113+
done
114+
echo "" >> "$GITHUB_STEP_SUMMARY"
115+
echo "### Tag" >> "$GITHUB_STEP_SUMMARY"
116+
echo "Created tag v$PKG_VERSION" >> "$GITHUB_STEP_SUMMARY"
117+
env:
118+
PKG_VERSION: ${{ steps.version.outputs.version }}

0 commit comments

Comments
 (0)