Skip to content

Commit 3a89cc8

Browse files
author
cleilson pereira
committed
feat: Enhance CI/CD pipeline with automatic version tagging and improved NuGet packaging using GitVersion; update changelog
1 parent dc9f474 commit 3a89cc8

2 files changed

Lines changed: 96 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 92 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ jobs:
8888
package:
8989
name: Create NuGet Package
9090
runs-on: ubuntu-latest
91-
needs: [build-and-test, code-quality]
91+
needs: [build-and-test, code-quality, tag-version]
9292
if: github.ref == 'refs/heads/master'
9393

9494
steps:
@@ -102,27 +102,33 @@ jobs:
102102
with:
103103
dotnet-version: '8.0.x'
104104

105+
- name: Install GitVersion
106+
uses: gittools/actions/gitversion/setup@v0.10.2
107+
with:
108+
versionSpec: '5.x'
109+
110+
- name: Determine version
111+
id: gitversion
112+
uses: gittools/actions/gitversion/execute@v0.10.2
113+
with:
114+
useConfigFile: true
115+
105116
- name: Restore dependencies
106117
run: dotnet restore
107118

108-
- name: Create version number
109-
id: version
110-
run: |
111-
VERSION="1.0.0-alpha.$(date +%Y%m%d%H%M%S)"
112-
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
113-
echo "Creating version: $VERSION"
114-
115119
- name: Pack NuGet packages
116120
run: |
117-
dotnet pack Iso20022Library.Domain/Iso20022Library.Domain.csproj --no-restore --configuration Release --output ./packages /p:Version=${{ steps.version.outputs.VERSION }}
118-
dotnet pack Iso20022Library.Messages/Iso20022Library.Messages.csproj --no-restore --configuration Release --output ./packages /p:Version=${{ steps.version.outputs.VERSION }}
119-
dotnet pack Iso20022Library.Infrastructure/Iso20022Library.Infrastructure.csproj --no-restore --configuration Release --output ./packages /p:Version=${{ steps.version.outputs.VERSION }}
120-
dotnet pack Iso20022Library.Application/Iso20022Library.Application.csproj --no-restore --configuration Release --output ./packages /p:Version=${{ steps.version.outputs.VERSION }}
121+
VERSION="${{ steps.gitversion.outputs.nuGetVersionV2 }}"
122+
echo "Creating NuGet packages with version: $VERSION"
123+
dotnet pack Iso20022Library.Domain/Iso20022Library.Domain.csproj --no-restore --configuration Release --output ./packages /p:Version=$VERSION
124+
dotnet pack Iso20022Library.Messages/Iso20022Library.Messages.csproj --no-restore --configuration Release --output ./packages /p:Version=$VERSION
125+
dotnet pack Iso20022Library.Infrastructure/Iso20022Library.Infrastructure.csproj --no-restore --configuration Release --output ./packages /p:Version=$VERSION
126+
dotnet pack Iso20022Library.Application/Iso20022Library.Application.csproj --no-restore --configuration Release --output ./packages /p:Version=$VERSION
121127
122128
- name: Upload NuGet packages
123129
uses: actions/upload-artifact@v4
124130
with:
125-
name: nuget-packages
131+
name: nuget-packages-v${{ steps.gitversion.outputs.majorMinorPatch }}
126132
path: ./packages/*.nupkg
127133
retention-days: 90
128134

@@ -158,3 +164,76 @@ jobs:
158164
- name: Run vulnerability scan
159165
run: dotnet list package --vulnerable --include-transitive
160166
continue-on-error: true
167+
168+
tag-version:
169+
name: Create Version Tag
170+
runs-on: ubuntu-latest
171+
needs: [build-and-test, code-quality]
172+
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
173+
174+
steps:
175+
- name: Checkout code
176+
uses: actions/checkout@v4
177+
with:
178+
fetch-depth: 0
179+
token: ${{ secrets.GITHUB_TOKEN }}
180+
181+
- name: Setup .NET
182+
uses: actions/setup-dotnet@v4
183+
with:
184+
dotnet-version: '8.0.x'
185+
186+
- name: Install GitVersion
187+
uses: gittools/actions/gitversion/setup@v0.10.2
188+
with:
189+
versionSpec: '5.x'
190+
191+
- name: Determine version
192+
id: gitversion
193+
uses: gittools/actions/gitversion/execute@v0.10.2
194+
with:
195+
useConfigFile: true
196+
197+
- name: Create version tag
198+
run: |
199+
VERSION="${{ steps.gitversion.outputs.majorMinorPatch }}"
200+
TAG_NAME="v$VERSION"
201+
202+
# Check if tag already exists
203+
if git tag -l "$TAG_NAME" | grep -q "$TAG_NAME"; then
204+
echo "Tag $TAG_NAME already exists, skipping..."
205+
else
206+
echo "Creating tag: $TAG_NAME"
207+
git config --local user.email "action@github.com"
208+
git config --local user.name "GitHub Action"
209+
git tag -a "$TAG_NAME" -m "Release version $VERSION"
210+
git push origin "$TAG_NAME"
211+
echo "Created and pushed tag: $TAG_NAME"
212+
fi
213+
214+
- name: Create GitHub Release
215+
uses: softprops/action-gh-release@v1
216+
with:
217+
tag_name: v${{ steps.gitversion.outputs.majorMinorPatch }}
218+
name: Release ${{ steps.gitversion.outputs.majorMinorPatch }}
219+
body: |
220+
## 🚀 Release ${{ steps.gitversion.outputs.majorMinorPatch }}
221+
222+
**Build:** ${{ github.sha }}
223+
**Branch:** ${{ github.ref_name }}
224+
225+
### 📦 NuGet Packages
226+
- Iso20022Library.Domain
227+
- Iso20022Library.Messages
228+
- Iso20022Library.Infrastructure
229+
- Iso20022Library.Application
230+
231+
### 🧪 Tests
232+
All ${{ github.event.head_commit.message }} tests passed successfully.
233+
234+
---
235+
*Auto-generated release from CI/CD pipeline*
236+
draft: false
237+
prerelease: false
238+
generate_release_notes: true
239+
token: ${{ secrets.GITHUB_TOKEN }}

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
## [Unreleased]
44
### Fixed
55
- **Cross-platform test compatibility**: Enhanced test infrastructure to resolve XSD file paths dynamically using cross-platform compatible `GetXsdPath` helper method, eliminating hardcoded Windows-specific paths that were causing failures in GitHub Actions Linux environment.
6+
- **Security scan configuration**: Fixed security scan tool compatibility by adding .NET 6.0 runtime support and correcting command-line arguments.
7+
### Added
8+
- **Automatic version tagging**: Added GitVersion-based automatic tagging system in CI/CD pipeline that creates semantic version tags and GitHub releases automatically on pushes to master branch.
9+
- **Enhanced NuGet packaging**: Improved NuGet package creation with GitVersion integration for consistent semantic versioning across all packages.
610
### Changed
711
- **Updated GitHub Actions workflows** to use `master` branch instead of `main` branch for consistency with repository setup
812
### Added

0 commit comments

Comments
 (0)