Skip to content

Commit 1cd2a8b

Browse files
authored
Merge pull request #18 from atakanatali/feature/deployment-workflow
ci: Advanced NuGet publishing workflow
2 parents bd54e9a + c5b8c80 commit 1cd2a8b

File tree

1 file changed

+88
-19
lines changed

1 file changed

+88
-19
lines changed

.github/workflows/publish.yml

Lines changed: 88 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,114 @@
1-
name: Publish NuGet
1+
name: Publish to NuGet
22

33
on:
44
workflow_dispatch:
55
inputs:
6-
version_suffix:
7-
description: 'Optional version suffix (e.g. preview.1)'
6+
version:
7+
description: 'Package version (e.g., 1.0.0)'
8+
required: true
9+
type: string
10+
prerelease:
11+
description: 'Is this a prerelease? (adds -preview suffix)'
812
required: false
9-
default: ''
13+
type: boolean
14+
default: false
15+
16+
env:
17+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
18+
DOTNET_CLI_TELEMETRY_OPTOUT: true
1019

1120
jobs:
1221
publish:
22+
name: Build & Publish
23+
if: github.repository_owner == 'atakanatali'
1324
runs-on: ubuntu-latest
25+
environment: nuget-prod
1426

1527
steps:
1628
- name: Checkout
1729
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
1832

19-
- name: Setup .NET
33+
- name: 🔧 Setup .NET
2034
uses: actions/setup-dotnet@v4
2135
with:
2236
dotnet-version: 9.0.x
2337

38+
- name: Set Version
39+
id: version
40+
run: |
41+
VERSION="${{ github.event.inputs.version }}"
42+
if [ "${{ github.event.inputs.prerelease }}" == "true" ]; then
43+
VERSION="${VERSION}-preview"
44+
fi
45+
echo "PACKAGE_VERSION=${VERSION}" >> $GITHUB_OUTPUT
46+
echo "Package version: ${VERSION}"
47+
2448
- name: Restore
2549
run: dotnet restore
2650

27-
- name: Build
28-
run: dotnet build --configuration Release --no-restore
51+
- name: 🔨 Build
52+
run: |
53+
dotnet build -c Release --no-restore \
54+
/p:Version=${{ steps.version.outputs.PACKAGE_VERSION }} \
55+
/p:PackageVersion=${{ steps.version.outputs.PACKAGE_VERSION }}
56+
57+
- name: Test
58+
run: dotnet test -c Release --no-build --verbosity normal
2959

3060
- name: Pack
3161
run: |
32-
VERSION_SUFFIX_ARG=""
33-
if [ -n "${{ github.event.inputs.version_suffix }}" ]; then
34-
VERSION_SUFFIX_ARG="--version-suffix ${{ github.event.inputs.version_suffix }}"
35-
fi
36-
dotnet pack src/Notify.Abstractions/Notify.Abstractions.csproj --configuration Release --no-build --output artifacts $VERSION_SUFFIX_ARG
37-
dotnet pack src/Notify.Broker.Abstractions/Notify.Broker.Abstractions.csproj --configuration Release --no-build --output artifacts $VERSION_SUFFIX_ARG
38-
dotnet pack src/Notify.Broker.RabbitMQ/Notify.Broker.RabbitMQ.csproj --configuration Release --no-build --output artifacts $VERSION_SUFFIX_ARG
39-
dotnet pack src/Notify.Core/Notify.Core.csproj --configuration Release --no-build --output artifacts $VERSION_SUFFIX_ARG
40-
dotnet pack src/Notify.Hosting/Notify.Hosting.csproj --configuration Release --no-build --output artifacts $VERSION_SUFFIX_ARG
62+
dotnet pack -c Release --no-build \
63+
/p:Version=${{ steps.version.outputs.PACKAGE_VERSION }} \
64+
/p:PackageVersion=${{ steps.version.outputs.PACKAGE_VERSION }} \
65+
-o ./nupkgs
66+
67+
- name: 📋 List Packages
68+
run: ls -la ./nupkgs
69+
70+
- name: Push to NuGet
71+
run: |
72+
for package in ./nupkgs/*.nupkg; do
73+
echo "Publishing: $package"
74+
dotnet nuget push "$package" \
75+
--api-key "${{ secrets.NUGET_API_KEY }}" \
76+
--source https://api.nuget.org/v3/index.json \
77+
--skip-duplicate
78+
done
4179
42-
- name: Publish
80+
- name: Create Git Tag
81+
run: |
82+
git config user.name "github-actions[bot]"
83+
git config user.email "github-actions[bot]@users.noreply.github.com"
84+
git tag -a "v${{ steps.version.outputs.PACKAGE_VERSION }}" -m "Release v${{ steps.version.outputs.PACKAGE_VERSION }}"
85+
git push origin "v${{ steps.version.outputs.PACKAGE_VERSION }}"
86+
87+
- name: Create Release
88+
uses: softprops/action-gh-release@v1
89+
with:
90+
tag_name: v${{ steps.version.outputs.PACKAGE_VERSION }}
91+
name: Notify v${{ steps.version.outputs.PACKAGE_VERSION }}
92+
body: |
93+
## Notify v${{ steps.version.outputs.PACKAGE_VERSION }}
94+
95+
### Packages Published
96+
- `Notify.Abstractions` - Shared contracts and interfaces
97+
- `Notify.Core` - Producer-side publishing, serialization, and compression
98+
- `Notify.Hosting` - Worker-side consumption and provider dispatching
99+
- `Notify.Broker.Abstractions` - Broker-agnostic abstractions
100+
- `Notify.Broker.RabbitMQ` - RabbitMQ broker implementation
101+
102+
### Installation
103+
```bash
104+
dotnet add package Notify.Core --version ${{ steps.version.outputs.PACKAGE_VERSION }}
105+
```
106+
107+
See [CHANGELOG.md](https://github.com/atakanatali/notify/blob/main/CHANGELOG.md) for details.
108+
draft: false
109+
prerelease: ${{ github.event.inputs.prerelease }}
110+
files: |
111+
./nupkgs/*.nupkg
112+
./nupkgs/*.snupkg
43113
env:
44-
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
45-
run: dotnet nuget push "artifacts/*.nupkg" --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate
114+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)