Skip to content

#0 FEAT Fix README.md #12

#0 FEAT Fix README.md

#0 FEAT Fix README.md #12

Workflow file for this run

name: Build & Publish NuGet
permissions:
contents: write
on:
push:
branches:
- release
workflow_dispatch:
jobs:
build-pack-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
token: ${{ secrets.GITHUB_TOKEN }} # allows pushing tags
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '9.0.x'
# Read base version from central config file and build full version
- name: Determine version
id: version
run: |
BASE_VERSION=$(cat VERSION.txt)
echo "Base version: $BASE_VERSION"
FULL_VERSION="$BASE_VERSION.${GITHUB_RUN_NUMBER}"
echo "Full version: $FULL_VERSION"
echo "BASE_VERSION=$BASE_VERSION" >> $GITHUB_OUTPUT
echo "FULL_VERSION=$FULL_VERSION" >> $GITHUB_OUTPUT
# Find solution file dynamically (first .sln we encounter)
- name: Locate solution file
id: solution
run: |
SOLUTION=$(find . -maxdepth 5 -name "*.sln" | head -n 1)
if [ -z "$SOLUTION" ]; then
echo "❌ No solution file (*.sln) found in the repo."
exit 1
fi
echo "Found solution: $SOLUTION"
echo "SOLUTION_PATH=$SOLUTION" >> $GITHUB_OUTPUT
# Restore using the solution
- name: Restore
run: dotnet restore "${{ steps.solution.outputs.SOLUTION_PATH }}"
# Pack all packable projects into ./artifacts with unified version
- name: Pack all NuGet projects
run: dotnet pack "./FluentAAS/FluentAAS.sln" -c Release -o ./artifacts /p:PackageVersion=${{ steps.version.outputs.FULL_VERSION }}
# Publish NuGet packages to nuget.org
- name: Publish to NuGet
run: dotnet nuget push "artifacts/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source "https://api.nuget.org/v3/index.json" --skip-duplicate
# Create a new Git tag for this version
- name: Create and push Git tag
run: |
TAG="v${{ steps.version.outputs.FULL_VERSION }}"
echo "Creating git tag: $TAG"
git tag $TAG
git push origin $TAG
# Check if there are any tags yet (first release => no tags)
- name: Check for existing tags
id: check_tags
run: |
if git tag --list | grep . > /dev/null; then
echo "has_tags=true" >> $GITHUB_OUTPUT
else
echo "has_tags=false" >> $GITHUB_OUTPUT
fi
# Build changelog / release notes automatically (only if we have tags)
- name: Build Changelog
if: steps.check_tags.outputs.has_tags == 'true'
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v6
with:
fetchReleaseInformation: true
failOnError: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Upload artifacts to the workflow run
- name: Upload NuGet Artifacts
uses: actions/upload-artifact@v5
with:
name: nuget-packages-${{ steps.version.outputs.FULL_VERSION }}
path: ./artifacts/*.nupkg
# Create GitHub Release with generated changelog and attach .nupkg files
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.FULL_VERSION }}
name: FluentAAS v${{ steps.version.outputs.FULL_VERSION }}
body: ${{ steps.build_changelog.outputs.changelog || 'Initial release of FluentAAS.' }}
files: ./artifacts/*.nupkg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}