Skip to content

Using an older version of GitVersion specifications #45

Using an older version of GitVersion specifications

Using an older version of GitVersion specifications #45

Workflow file for this run

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.gitversion.outputs.AssemblySemVer }}
file-version: ${{ steps.gitversion.outputs.AssemblySemFileVer }}
informational-version: ${{ steps.gitversion.outputs.InformationalVersion }}
is-prerelease: ${{ contains(steps.gitversion.outputs.NuGetVersion, '-') }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v4.0.1
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v4.0.1
- name: Display GitVersion Results
run: |
echo "🔍 GitVersion Results:"
echo "Branch: ${{ github.ref }}"
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 }}'"
echo "PreReleaseTag: '${{ steps.gitversion.outputs.PreReleaseTag }}'"
echo "PreReleaseNumber: '${{ steps.gitversion.outputs.PreReleaseNumber }}'"
echo "CommitsSinceVersionSource: '${{ steps.gitversion.outputs.CommitsSinceVersionSource }}'"
echo "Is Pre-release: ${{ contains(steps.gitversion.outputs.NuGetVersion, '-') }}"
echo ""
echo "📋 Expected behavior:"
echo "- CD workflow should ALWAYS produce pre-release versions"
echo "- main branch should produce versions like: X.Y.Z-alpha.N"
echo "- develop branch should produce versions like: X.Y.Z-dev.N"
echo "- Only tagged releases from release workflow should produce stable versions"
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 (from GitVersion):"
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 }}"
echo "Is Pre-release: ${{ needs.calculate-version.outputs.is-prerelease }}"
- name: Restore dependencies
run: dotnet restore -p:TargetFramework=${{ matrix.dotnet-framework }}
- name: Build
run: |
echo "🏗️ Building with GitVersion integration..."
dotnet build --no-restore -c Release -f ${{ matrix.dotnet-framework }} \
-p:UseGitVersion=true \
--verbosity normal
shell: bash
- name: Test
run: dotnet test --no-build --verbosity normal -c Release -f ${{ matrix.dotnet-framework }}
publish:
needs: [calculate-version, build]
name: "Publish Pre-release Packages (CI/CD)"
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 Pre-release Packages"
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
uses: ./.github/workflows/clean-packages.yml
summary:
needs: [calculate-version, build, publish]
runs-on: ubuntu-latest
if: always()
steps:
- name: CD Workflow Summary
run: |
echo "## 🚀 CD Workflow Summary (GitVersion Direct)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Property | Value |" >> $GITHUB_STEP_SUMMARY
echo "|----------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| Branch | \`${{ github.ref_name }}\` |" >> $GITHUB_STEP_SUMMARY
echo "| Version (GitVersion) | \`${{ needs.calculate-version.outputs.version }}\` |" >> $GITHUB_STEP_SUMMARY
echo "| NuGet Version (GitVersion) | \`${{ needs.calculate-version.outputs.nuget-version }}\` |" >> $GITHUB_STEP_SUMMARY
echo "| Assembly Version (GitVersion) | \`${{ needs.calculate-version.outputs.assembly-version }}\` |" >> $GITHUB_STEP_SUMMARY
echo "| Pre-release | ${{ needs.calculate-version.outputs.is-prerelease == 'true' && '✅ Yes' || '❌ No' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Published to GitHub | ${{ needs.publish.result == 'success' && '✅ Yes' || '❌ No' }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.calculate-version.outputs.is-prerelease }}" == "true" ]; then
echo "🎯 **Pre-release Package**: This version is directly from GitVersion" >> $GITHUB_STEP_SUMMARY
echo "📦 **Usage**: Install with \`--prerelease\` flag: \`dotnet add package PackageName --version ${{ needs.calculate-version.outputs.nuget-version }} --prerelease\`" >> $GITHUB_STEP_SUMMARY
echo "✅ **GitVersion Direct**: No manual version construction - all versions from GitVersion" >> $GITHUB_STEP_SUMMARY
else
echo "⚠️ **Warning**: GitVersion produced a stable version!" >> $GITHUB_STEP_SUMMARY
echo "🏷️ **Current**: \`${{ needs.calculate-version.outputs.nuget-version }}\`" >> $GITHUB_STEP_SUMMARY
echo "🔧 **Action Required**: Check GitVersion configuration for branch labeling" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "📋 **Versioning Strategy**:" >> $GITHUB_STEP_SUMMARY
echo "- **CI/CD Workflow** (this): GitVersion calculates all versions directly" >> $GITHUB_STEP_SUMMARY
echo " - **main**: GitVersion → \`X.Y.Z-alpha.N\` versions" >> $GITHUB_STEP_SUMMARY
echo " - **develop**: GitVersion → \`X.Y.Z-dev.N\` versions" >> $GITHUB_STEP_SUMMARY
echo "- **Release Workflow**: GitVersion produces stable versions from tags (\`X.Y.Z\`)" >> $GITHUB_STEP_SUMMARY
echo "- **Build Process**: Uses \`-p:UseGitVersion=true\` to integrate directly" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "📦 **Published Packages**: Check the [GitHub Packages](https://github.com/${{ github.repository }}/pkgs) for the published packages." >> $GITHUB_STEP_SUMMARY