[Release] v5.5.0 #99
Workflow file for this run
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: Release | |
| run-name: '[Release] ${{ github.event.release.tag_name }}' | |
| on: | |
| release: | |
| types: [published] | |
| permissions: | |
| contents: write | |
| env: | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
| DOTNET_NOLOGO: true | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: | | |
| 8.0.x | |
| 9.0.x | |
| 10.0.x | |
| - name: Extract version from release tag | |
| id: get_version | |
| run: | | |
| # Remove 'v' prefix from tag name if present (e.g., v2.5.0 -> 2.5.0) | |
| VERSION=${GITHUB_REF_NAME#v} | |
| # Validate that VERSION is not empty | |
| if [ -z "$VERSION" ]; then | |
| echo "Error: VERSION is empty! GITHUB_REF_NAME was: $GITHUB_REF_NAME" | |
| echo "Please create the release with a proper tag like 'v5.1.0'" | |
| exit 1 | |
| fi | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Extracted version: $VERSION" | |
| - name: Update version in Directory.Build.props | |
| run: | | |
| # Update the version in Directory.Build.props | |
| sed -i "s|<Version>.*</Version>|<Version>${{ steps.get_version.outputs.VERSION }}</Version>|g" Directory.Build.props | |
| echo "Updated Directory.Build.props with version ${{ steps.get_version.outputs.VERSION }}" | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --configuration Release --no-restore | |
| - name: Run Unit Tests | |
| run: dotnet test --configuration Release --no-build --verbosity normal | |
| - name: Pack NuGet packages | |
| run: dotnet pack --configuration Release --no-build --include-symbols -p:SymbolPackageFormat=snupkg --output ./artifacts | |
| - name: List generated packages | |
| run: ls -la ./artifacts/ | |
| - name: Publish to NuGet | |
| shell: pwsh | |
| run: | | |
| foreach ($file in Get-ChildItem "./artifacts" -Recurse -Include *.nupkg,*.snupkg) { | |
| Write-Host "Processing package: $($file.Name)" | |
| # Determine which API key to use based on package name | |
| $apiKey = $null | |
| if ($file.Name -like "Facet.Mapping.Expressions.*") { | |
| Write-Host "Publishing Facet.Mapping.Expressions package..." | |
| $apiKey = "${{ secrets.NUGET_API_KEY_EXPRESSIONS }}" | |
| } elseif ($file.Name -like "Facet.Mapping.*") { | |
| Write-Host "Publishing Facet.Mapping package..." | |
| $apiKey = "${{ secrets.NUGET_MAP_API_KEY }}" | |
| } elseif ($file.Name -like "Facet.Extensions.EFCore.Mapping.*") { | |
| Write-Host "Publishing Facet.Extensions.EFCore.Mapping package..." | |
| $apiKey = "${{ secrets.NUGET_API_KEY_EXTENSIONS_EF_MAPPING }}" | |
| } elseif ($file.Name -like "Facet.Extensions.EFCore.*") { | |
| Write-Host "Publishing Facet.Extensions.EFCore package..." | |
| $apiKey = "${{ secrets.NUGET_API_KEY_EXTENSIONS_EF }}" | |
| } elseif ($file.Name -like "Facet.Extensions.*") { | |
| Write-Host "Publishing Facet.Extensions package..." | |
| $apiKey = "${{ secrets.NUGET_API_KEY_EXTENSIONS }}" | |
| } elseif ($file.Name -like "Facet.Dashboard.*") { | |
| Write-Host "Publishing Facet.Dashboard package..." | |
| $apiKey = "${{ secrets.NUGET_API_KEY_DASHBOARD }}" | |
| } elseif ($file.Name -like "Facet.Attributes.*") { | |
| Write-Host "Publishing Facet.Attributes package..." | |
| $apiKey = "${{ secrets.NUGET_ATTRIBUTES_API_KEY }}" | |
| } elseif ($file.Name -like "Facet.*") { | |
| Write-Host "Publishing Facet package..." | |
| $apiKey = "${{ secrets.NUGET_API_KEY }}" | |
| } else { | |
| Write-Host "Skipping unknown package: $($file.Name)" | |
| continue | |
| } | |
| dotnet nuget push $file ` | |
| --api-key $apiKey ` | |
| --source https://api.nuget.org/v3/index.json ` | |
| --skip-duplicate | |
| } | |
| - name: Commit version update | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| # Check if we're on a detached HEAD and create/switch to master branch | |
| if git symbolic-ref HEAD >/dev/null 2>&1; then | |
| echo "On branch, proceeding with commit" | |
| else | |
| echo "Detached HEAD detected, switching to master branch" | |
| git checkout -B master | |
| fi | |
| # Only commit if there are changes | |
| if git diff --quiet Directory.Build.props; then | |
| echo "No changes to commit" | |
| else | |
| git add Directory.Build.props | |
| git commit -m "Bump version to ${{ steps.get_version.outputs.VERSION }}" | |
| git push origin master | |
| fi |