Further attempts to fix the versioning issues #35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Messaging CI/CD | |
| permissions: | |
| contents: read | |
| packages: write | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| env: | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
| DOTNET_NOLOGO: true | |
| DOTNET_CLI_TELEMETRY_OPTOUT: true | |
| jobs: | |
| calculate-version: | |
| name: "Calculate Version" | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.gitversion.outputs.SemVer }} | |
| nuget-version: ${{ steps.gitversion.outputs.NuGetVersion }} | |
| assembly-version: ${{ steps.validate-version.outputs.ASSEMBLY_VERSION }} | |
| file-version: ${{ steps.validate-version.outputs.FILE_VERSION }} | |
| informational-version: ${{ steps.gitversion.outputs.InformationalVersion }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/setup@v4.0.1 | |
| with: | |
| versionSpec: '6.x' | |
| - name: Determine Version | |
| id: gitversion | |
| uses: gittools/actions/gitversion/execute@v4.0.1 | |
| - name: Validate and Normalize Version Properties | |
| id: validate-version | |
| run: | | |
| echo "🔍 Raw GitVersion outputs:" | |
| echo "SemVer: '${{ steps.gitversion.outputs.SemVer }}'" | |
| echo "NuGetVersion: '${{ steps.gitversion.outputs.NuGetVersion }}'" | |
| echo "AssemblySemVer: '${{ steps.gitversion.outputs.AssemblySemVer }}'" | |
| echo "AssemblySemFileVer: '${{ steps.gitversion.outputs.AssemblySemFileVer }}'" | |
| echo "InformationalVersion: '${{ steps.gitversion.outputs.InformationalVersion }}'" | |
| # Validate and set AssemblyVersion | |
| ASSEMBLY_VERSION="${{ steps.gitversion.outputs.AssemblySemVer }}" | |
| if [ -z "$ASSEMBLY_VERSION" ] || [ "$ASSEMBLY_VERSION" = " " ] || [ "$ASSEMBLY_VERSION" = "0.0.0" ]; then | |
| echo "⚠️ AssemblySemVer is empty or invalid, using fallback" | |
| ASSEMBLY_VERSION="1.0.0.0" | |
| fi | |
| # Validate and set FileVersion | |
| FILE_VERSION="${{ steps.gitversion.outputs.AssemblySemFileVer }}" | |
| if [ -z "$FILE_VERSION" ] || [ "$FILE_VERSION" = " " ] || [ "$FILE_VERSION" = "0.0.0" ]; then | |
| echo "⚠️ AssemblySemFileVer is empty or invalid, using AssemblyVersion" | |
| FILE_VERSION="$ASSEMBLY_VERSION" | |
| fi | |
| echo "✅ Validated versions:" | |
| echo "AssemblyVersion: '$ASSEMBLY_VERSION'" | |
| echo "FileVersion: '$FILE_VERSION'" | |
| echo "ASSEMBLY_VERSION=$ASSEMBLY_VERSION" >> $GITHUB_OUTPUT | |
| echo "FILE_VERSION=$FILE_VERSION" >> $GITHUB_OUTPUT | |
| - name: Display GitVersion outputs | |
| run: | | |
| echo "🔍 CD Version Calculation:" | |
| echo "Branch: ${{ github.ref }}" | |
| echo "Version: ${{ steps.gitversion.outputs.SemVer }}" | |
| echo "NuGet Version: ${{ steps.gitversion.outputs.NuGetVersion }}" | |
| echo "Assembly Version: ${{ steps.validate-version.outputs.ASSEMBLY_VERSION }}" | |
| echo "File Version: ${{ steps.validate-version.outputs.FILE_VERSION }}" | |
| echo "Informational Version: ${{ steps.gitversion.outputs.InformationalVersion }}" | |
| build: | |
| needs: calculate-version | |
| name: "Build and Test" | |
| strategy: | |
| matrix: | |
| include: | |
| - dotnet: '8.0.x' | |
| dotnet-framework: 'net8.0' | |
| os: ubuntu-latest | |
| - dotnet: '8.0.x' | |
| dotnet-framework: 'net8.0' | |
| os: windows-latest | |
| - dotnet: '9.0.x' | |
| dotnet-framework: 'net9.0' | |
| os: ubuntu-latest | |
| - dotnet: '9.0.x' | |
| dotnet-framework: 'net9.0' | |
| os: windows-latest | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET ${{ matrix.dotnet }} | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ matrix.dotnet }} | |
| - name: Display Build Version Info | |
| run: | | |
| echo "🔍 Build Version Information:" | |
| echo "SemVer: ${{ needs.calculate-version.outputs.version }}" | |
| echo "NuGet Version: ${{ needs.calculate-version.outputs.nuget-version }}" | |
| echo "Assembly Version: ${{ needs.calculate-version.outputs.assembly-version }}" | |
| echo "File Version: ${{ needs.calculate-version.outputs.file-version }}" | |
| echo "Informational Version: ${{ needs.calculate-version.outputs.informational-version }}" | |
| - name: Validate Build Version Properties | |
| run: | | |
| echo "🔧 Validating version properties before build..." | |
| VERSION="${{ needs.calculate-version.outputs.nuget-version }}" | |
| ASSEMBLY_VERSION="${{ needs.calculate-version.outputs.assembly-version }}" | |
| FILE_VERSION="${{ needs.calculate-version.outputs.file-version }}" | |
| INFORMATIONAL_VERSION="${{ needs.calculate-version.outputs.informational-version }}" | |
| if [ -z "$VERSION" ] || [ "$VERSION" = " " ]; then | |
| echo "❌ VERSION is empty" | |
| exit 1 | |
| fi | |
| if [ -z "$ASSEMBLY_VERSION" ] || [ "$ASSEMBLY_VERSION" = " " ]; then | |
| echo "❌ ASSEMBLY_VERSION is empty" | |
| exit 1 | |
| fi | |
| if [ -z "$FILE_VERSION" ] || [ "$FILE_VERSION" = " " ]; then | |
| echo "❌ FILE_VERSION is empty" | |
| exit 1 | |
| fi | |
| if [ -z "$INFORMATIONAL_VERSION" ] || [ "$INFORMATIONAL_VERSION" = " " ]; then | |
| echo "❌ INFORMATIONAL_VERSION is empty" | |
| exit 1 | |
| fi | |
| echo "✅ All version properties are valid" | |
| - name: Restore dependencies | |
| run: dotnet restore -p:TargetFramework=${{ matrix.dotnet-framework }} | |
| - name: Build | |
| run: | | |
| echo "🏗️ Building with explicit version properties..." | |
| dotnet build --no-restore -c Release -f ${{ matrix.dotnet-framework }} \ | |
| -p:Version="${{ needs.calculate-version.outputs.nuget-version }}" \ | |
| -p:PackageVersion="${{ needs.calculate-version.outputs.nuget-version }}" \ | |
| -p:AssemblyVersion="${{ needs.calculate-version.outputs.assembly-version }}" \ | |
| -p:FileVersion="${{ needs.calculate-version.outputs.file-version }}" \ | |
| -p:InformationalVersion="${{ needs.calculate-version.outputs.informational-version }}" \ | |
| -p:UseGitVersion=false \ | |
| --verbosity normal | |
| - name: Test (Ubuntu) | |
| if: startsWith(matrix.os, 'ubuntu') | |
| run: dotnet test --no-build --verbosity normal -c Release -f ${{ matrix.dotnet-framework }} | |
| - name: Test (Windows) | |
| if: startsWith(matrix.os, 'windows') | |
| run: dotnet test --no-build --verbosity normal -c Release -f ${{ matrix.dotnet-framework }} --filter "DB!=SQLServer" | |
| publish: | |
| needs: [calculate-version, build] | |
| name: "Publish Packages (Development)" | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' | |
| uses: ./.github/workflows/publish.yml | |
| with: | |
| publish-to-nuget: false | |
| build-configuration: 'Release' | |
| version: ${{ needs.calculate-version.outputs.version }} | |
| nuget-version: ${{ needs.calculate-version.outputs.nuget-version }} | |
| assembly-version: ${{ needs.calculate-version.outputs.assembly-version }} | |
| informational-version: ${{ needs.calculate-version.outputs.informational-version }} | |
| secrets: inherit | |
| clean: | |
| needs: publish | |
| name: "Clean Old Packages" | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' | |
| uses: ./.github/workflows/clean-packages.yml |