From f6648470a69b214a1cc199ddf5e4769328e434ac Mon Sep 17 00:00:00 2001 From: Martin Tirion Date: Tue, 29 Oct 2024 10:11:57 +0100 Subject: [PATCH 1/5] Modified release pipeline for testing --- .github/workflows/release-and-publish.yml | 48 ++++++----------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml index f4d0925..1edced8 100644 --- a/.github/workflows/release-and-publish.yml +++ b/.github/workflows/release-and-publish.yml @@ -11,27 +11,28 @@ jobs: steps: # Checkout sources. Depth=0 is for using GitVersion - - name: Checkout - uses: actions/checkout@v4 + steps: + - uses: actions/checkout@v2 with: fetch-depth: 0 - + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.x + # Install and Setup GitVersion - name: Install GitVersion uses: gittools/actions/gitversion/setup@v3.0.0 with: - versionSpec: '6.x' - - name: Use GitVersion + versionSpec: '5.x' + # Step id is used as reference for the output values + - name: Use GitVersion to determine the version id: gitversion uses: gittools/actions/gitversion/execute@v3.0.0 - - # Setup .NET 8 - - name: Setup .NET - uses: actions/setup-dotnet@v4 with: - dotnet-version: 8.x - + useConfigFile: true + # Build the tools & create the zip-file and nuget packages # Chocolatey tools are in .\tools. NuGet packages in .\artifacts - name: Build & Package @@ -50,28 +51,3 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Create GitHub release with created zip-file and CHANGELOG for Chocolatey and releases - # NOTE: this is where we prepend "v" before the version in the tag/release - - name: Create release - uses: ncipollo/release-action@v1 - with: - artifacts: "./tools.zip" - body: ${{steps.github_release.outputs.changelog}} - tag: "v${{ steps.gitversion.outputs.MajorMinorPatch }}" - token: ${{ secrets.GITHUB_TOKEN }} - - # package and publish Chocolatey package for this version - # We publish the nuspec file which references the tools.zip in releases. - - name: Publish to Chocolatey - env: - CHOCO_TOKEN: ${{ secrets.CHOCO_TOKEN }} - run: pwsh .\pack.ps1 -publish -version ${{ steps.gitversion.outputs.MajorMinorPatch }} - - # Publish all NuGet packages to NuGet.org - # Use --skip-duplicate to prevent errors if a package with the same version already exists. - # If you retry a failed workflow, already published packages will be skipped without error. - - name: Publish separate tools to NuGet - run: | - foreach($file in (Get-ChildItem "./artifacts" -Recurse -Include *.nupkg)) { - dotnet nuget push $file --api-key "${{ secrets.NUGET_TOOLS }}" --source https://api.nuget.org/v3/index.json --skip-duplicate - } \ No newline at end of file From 5e6d0ae5d0efa39d2072567e6de4ee0040a4a9f2 Mon Sep 17 00:00:00 2001 From: Martin Tirion Date: Tue, 29 Oct 2024 10:13:17 +0100 Subject: [PATCH 2/5] Fixed error --- .github/workflows/release-and-publish.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml index 1edced8..4294f77 100644 --- a/.github/workflows/release-and-publish.yml +++ b/.github/workflows/release-and-publish.yml @@ -11,7 +11,6 @@ jobs: steps: # Checkout sources. Depth=0 is for using GitVersion - steps: - uses: actions/checkout@v2 with: fetch-depth: 0 From e3a3495c0031ee53d75cdace88f3c07d76ec8caa Mon Sep 17 00:00:00 2001 From: Martin Tirion Date: Tue, 29 Oct 2024 10:16:43 +0100 Subject: [PATCH 3/5] Fix2 --- .github/workflows/release-and-publish.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml index 4294f77..b0580c0 100644 --- a/.github/workflows/release-and-publish.yml +++ b/.github/workflows/release-and-publish.yml @@ -11,9 +11,11 @@ jobs: steps: # Checkout sources. Depth=0 is for using GitVersion - - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v2 with: fetch-depth: 0 + - name: Setup .NET uses: actions/setup-dotnet@v4 with: @@ -49,4 +51,3 @@ jobs: toTag: ${{ steps.gitversion.outputs.Sha }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - From 23c493f9721f3f25beafb450c8637abaacf47960 Mon Sep 17 00:00:00 2001 From: Martin Tirion Date: Tue, 29 Oct 2024 10:18:50 +0100 Subject: [PATCH 4/5] fix3 --- .github/workflows/release-and-publish.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml index b0580c0..eddd4e0 100644 --- a/.github/workflows/release-and-publish.yml +++ b/.github/workflows/release-and-publish.yml @@ -8,9 +8,9 @@ on: jobs: build: runs-on: windows-latest - steps: - # Checkout sources. Depth=0 is for using GitVersion + steps: + # Checkout sources. Depth=0 is for using GitVersion - name: Checkout uses: actions/checkout@v2 with: @@ -21,7 +21,7 @@ jobs: with: dotnet-version: 8.x - # Install and Setup GitVersion + # Install and Setup GitVersion - name: Install GitVersion uses: gittools/actions/gitversion/setup@v3.0.0 with: From 2821a9f8267c41781cf7cc9576a6f45a8601ee94 Mon Sep 17 00:00:00 2001 From: Martin Tirion Date: Tue, 29 Oct 2024 11:07:16 +0100 Subject: [PATCH 5/5] Fixed pipelines. Improved build skipping double compile. Improved publish - only projects, not solutions --- .github/workflows/build.yml | 3 ++- .github/workflows/release-and-publish.yml | 27 +++++++++++++++++++++++ build.ps1 | 4 ++-- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6766f41..a3be585 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,10 +21,11 @@ jobs: dotnet-version: 8.x # Loop through all the solutions in src and restore, build & test + # Skip DocFxCompanionTools.sln, as it is a combination of all solutions. - name: Restore, build & test shell: pwsh run: | - foreach ($sln in (Get-ChildItem -Recurse src\*.sln)) { + foreach ($sln in (Get-ChildItem -Recurse src\*.sln -Exclude DocFxCompanionTools.sln)) { Write-Host "Start building $($sln.FullName)" & dotnet restore $sln.FullName diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml index eddd4e0..62d2353 100644 --- a/.github/workflows/release-and-publish.yml +++ b/.github/workflows/release-and-publish.yml @@ -51,3 +51,30 @@ jobs: toTag: ${{ steps.gitversion.outputs.Sha }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # Create GitHub release with created zip-file and CHANGELOG for Chocolatey and releases + # NOTE: this is where we prepend "v" before the version in the tag/release + - name: Create release + uses: ncipollo/release-action@v1 + with: + artifacts: "./tools.zip" + body: ${{steps.github_release.outputs.changelog}} + tag: "v${{ steps.gitversion.outputs.MajorMinorPatch }}" + token: ${{ secrets.GITHUB_TOKEN }} + + # package and publish Chocolatey package for this version + # We publish the nuspec file which references the tools.zip in releases. + - name: Publish to Chocolatey + env: + CHOCO_TOKEN: ${{ secrets.CHOCO_TOKEN }} + run: pwsh .\pack.ps1 -publish -version ${{ steps.gitversion.outputs.MajorMinorPatch }} + + # Publish all NuGet packages to NuGet.org + # Use --skip-duplicate to prevent errors if a package with the same version already exists. + # If you retry a failed workflow, already published packages will be skipped without error. + - name: Publish separate tools to NuGet + run: | + foreach($file in (Get-ChildItem "./artifacts" -Recurse -Include *.nupkg)) { + dotnet nuget push $file --api-key "${{ secrets.NUGET_TOOLS }}" --source https://api.nuget.org/v3/index.json --skip-duplicate + } + diff --git a/build.ps1 b/build.ps1 index 839f0d7..f567e3f 100644 --- a/build.ps1 +++ b/build.ps1 @@ -14,8 +14,8 @@ if (Test-Path -Path $solution.assetZipPath) { Remove-Item $solution.assetZipPath } -# Build all dotnet solution into $solution.targetFolder as single exe's -foreach ($sln in (Get-ChildItem -Recurse src\*.sln)) { +# Build all dotnet projects into $solution.targetFolder as single exe's. Skip Test projects. +foreach ($sln in (Get-ChildItem -Recurse src\*\*.csproj -Exclude *.Test.*)) { Write-Host "Start building $($sln.FullName)" & dotnet publish $sln.FullName -c Release -r win-x64 /p:PublishSingleFile=true /p:CopyOutputSymbolsToPublishDirectory=false --self-contained false -o $solution.targetFolder }