From 203d323c320e1e5ca14a66cc03af1650088a5a82 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Thu, 15 Jan 2026 20:34:10 +0100 Subject: [PATCH] Enhance CI workflow with versioning and packaging Added steps to setup GitVersion, create NuGet package, and publish it along with a GitHub release. --- .github/workflows/push_main.yml | 68 +++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/push_main.yml diff --git a/.github/workflows/push_main.yml b/.github/workflows/push_main.yml new file mode 100644 index 0000000..88c4dec --- /dev/null +++ b/.github/workflows/push_main.yml @@ -0,0 +1,68 @@ +name: Build NuGet package on main branch pull request + +on: + pull_request: + branches: + - "main" + paths: + - "TimetableDesigner.Backend.Events**" + +jobs: + build: + name: Build and pack + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6.0.2 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 10.0.x + - name: Build + run: dotnet build + - name: Setup GitVersion + uses: gittools/actions/gitversion/setup@v0.9.7 + with: + versionSpec: 5.x + - name: Determine version + uses: gittools/actions/gitversion/execute@v0.9.7 + id: gitversion + with: + useConfigFile: true + configFilePath: ./.github/config/gitversion.yml + - name: Create NuGet package + run: dotnet pack -c Release -p:Version=${{steps.gitversion.outputs.SemVer}} -p:PackageVersion=${{steps.gitversion.outputs.SemVer}} --output ${{ github.workspace}}/nuget + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: nuget + path: ${{ github.workspace}}/nuget/*.nupkg + outputs: + version: ${{ steps.gitversion.outputs.SemVer }} + publish: + name: Publish + runs-on: ubuntu-latest + needs: build + steps: + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: nuget + path: ${{ github.workspace}}/nuget + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 10.0.x + - name: Publish + run: dotnet nuget push ${{ github.workspace}}/nuget/*.nupkg --source "github" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate + - name: Create Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{needs.build.outputs.version}} + release_name: ${{needs.build.outputs.version}} + draft: false + prerelease: false + +