-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (103 loc) · 3.78 KB
/
release.yml
File metadata and controls
119 lines (103 loc) · 3.78 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Release and Publish
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 1.0.0)'
required: true
type: string
env:
DOTNET_VERSION: '8.0.x'
CONFIGURATION: Release
jobs:
build-and-publish:
name: Build and Publish NuGet Packages
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" == "release" ]; then
VERSION="${{ github.event.release.tag_name }}"
# Remove 'v' prefix if present
VERSION="${VERSION#v}"
else
VERSION="${{ github.event.inputs.version }}"
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Publishing version: $VERSION"
- name: Restore dependencies
run: dotnet restore
- name: Build solution
run: dotnet build --no-restore --configuration ${{ env.CONFIGURATION }}
- name: Run tests
run: dotnet test --no-build --configuration ${{ env.CONFIGURATION }} --verbosity normal
- name: Pack Domain package
run: |
dotnet pack Iso20022Library.Domain/Iso20022Library.Domain.csproj \
--no-build \
--configuration ${{ env.CONFIGURATION }} \
--output ./packages \
/p:Version=${{ steps.version.outputs.VERSION }} \
/p:PackageReleaseNotes="Release ${{ steps.version.outputs.VERSION }}"
- name: Pack Messages package
run: |
dotnet pack Iso20022Library.Messages/Iso20022Library.Messages.csproj \
--no-build \
--configuration ${{ env.CONFIGURATION }} \
--output ./packages \
/p:Version=${{ steps.version.outputs.VERSION }} \
/p:PackageReleaseNotes="Release ${{ steps.version.outputs.VERSION }}"
- name: Pack Infrastructure package
run: |
dotnet pack Iso20022Library.Infrastructure/Iso20022Library.Infrastructure.csproj \
--no-build \
--configuration ${{ env.CONFIGURATION }} \
--output ./packages \
/p:Version=${{ steps.version.outputs.VERSION }} \
/p:PackageReleaseNotes="Release ${{ steps.version.outputs.VERSION }}"
- name: Pack Application package
run: |
dotnet pack Iso20022Library.Application/Iso20022Library.Application.csproj \
--no-build \
--configuration ${{ env.CONFIGURATION }} \
--output ./packages \
/p:Version=${{ steps.version.outputs.VERSION }} \
/p:PackageReleaseNotes="Release ${{ steps.version.outputs.VERSION }}"
- name: Upload packages to GitHub
uses: actions/upload-artifact@v4
with:
name: nuget-packages-${{ steps.version.outputs.VERSION }}
path: ./packages/*.nupkg
retention-days: 90
- name: Publish to NuGet.org
if: github.event_name == 'release'
run: |
for package in ./packages/*.nupkg; do
echo "Publishing $package"
dotnet nuget push "$package" \
--api-key ${{ secrets.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
done
- name: Create GitHub release assets
if: github.event_name == 'workflow_dispatch'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.VERSION }}
name: Release ${{ steps.version.outputs.VERSION }}
files: ./packages/*.nupkg
generate_release_notes: true
draft: false
prerelease: false