From f3b14848d6c9d1b9d5a3f0b021436c0b24953305 Mon Sep 17 00:00:00 2001 From: akdalin-hee <124877763+akdalin-hee@users.noreply.github.com> Date: Wed, 9 Jul 2025 08:36:18 +0100 Subject: [PATCH 1/2] Create publish_package.yml --- .github/workflows/publish_package.yml | 64 +++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/publish_package.yml diff --git a/.github/workflows/publish_package.yml b/.github/workflows/publish_package.yml new file mode 100644 index 0000000000..21cb5e0524 --- /dev/null +++ b/.github/workflows/publish_package.yml @@ -0,0 +1,64 @@ +name: Publish NuGet Package + +on: + pull_request: + types: [closed] + +jobs: + nuget_publish: + name: Build, Pack, and Publish NuGet Package + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + env: + BUILD_CONFIG: "Release" + PROJECT_PATH: "DotnetViewComponents/DotnetViewComponents.csproj" + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + strategy: + matrix: + dotnet-version: ["6.0.x", "8.0.x"] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup .NET SDK + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 6.0.x + + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v1.1.1 + with: + versionSpec: '6.0.x' + + - name: Determine Version + id: gitversion + uses: gittools/actions/gitversion/execute@v1.1.1 + + - name: Display GitVersion outputs + run: echo "Calculated Version:${{ steps.gitversion.outputs.semVer }}" + + - name: Setup .NET SDK for Building + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + - name: Restore NuGet packages + run: dotnet restore $PROJECT_PATH + + - name: Build project + run: dotnet build $PROJECT_PATH --configuration $BUILD_CONFIG --no-restore + + - name: Pack NuGet package + run: dotnet pack $PROJECT_PATH --configuration $BUILD_CONFIG --no-build -o out /p:PackageVersion=${{ steps.gitversion.outputs.semVer }} + + - name: Add GitHub NuGet source + run: dotnet nuget add source --username ${{ github.actor }} --password $GITHUB_TOKEN --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" + + - name: Publish NuGet package to GitHub Packages + run: dotnet nuget push out/*.nupkg --api-key $GITHUB_TOKEN --source "github" --skip-duplicate From c6da6983cfb199808aa36956aa8e06b9b104e92e Mon Sep 17 00:00:00 2001 From: akdalin-hee <124877763+akdalin-hee@users.noreply.github.com> Date: Wed, 9 Jul 2025 14:27:52 +0100 Subject: [PATCH 2/2] Update gittools setup --- .github/workflows/publish_package.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_package.yml b/.github/workflows/publish_package.yml index 21cb5e0524..cb842004cd 100644 --- a/.github/workflows/publish_package.yml +++ b/.github/workflows/publish_package.yml @@ -41,7 +41,15 @@ jobs: uses: gittools/actions/gitversion/execute@v1.1.1 - name: Display GitVersion outputs - run: echo "Calculated Version:${{ steps.gitversion.outputs.semVer }}" + run: | + echo "Major: ${{ steps.gitversion.outputs.major }}" + echo "Minor: ${{ steps.gitversion.outputs.minor }}" + echo "Patch: ${{ steps.gitversion.outputs.patch }}" + + - name: Save version + run: | + VERSION="${{ steps.gitversion.outputs.major }}.${{ steps.gitversion.outputs.minor }}.${{ steps.gitversion.outputs.patch }}" + echo "VERSION=$VERSION" >> $GITHUB_ENV - name: Setup .NET SDK for Building uses: actions/setup-dotnet@v4 @@ -55,7 +63,7 @@ jobs: run: dotnet build $PROJECT_PATH --configuration $BUILD_CONFIG --no-restore - name: Pack NuGet package - run: dotnet pack $PROJECT_PATH --configuration $BUILD_CONFIG --no-build -o out /p:PackageVersion=${{ steps.gitversion.outputs.semVer }} + run: dotnet pack $PROJECT_PATH --configuration $BUILD_CONFIG --no-build -o out /p:PackageVersion=$VERSION - name: Add GitHub NuGet source run: dotnet nuget add source --username ${{ github.actor }} --password $GITHUB_TOKEN --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"