Skip to content

Commit

Permalink
Merge pull request #26 from Ellerbach/fix/fix-release-pipeline
Browse files Browse the repository at this point in the history
Fix release pipeline
  • Loading branch information
mtirionMSFT authored Apr 5, 2023
2 parents 7cbb9de + a434b88 commit 27285a8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 36 deletions.
46 changes: 12 additions & 34 deletions .github/workflows/release-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ jobs:
with:
dotnet-version: 6.x

# Build the tools & create the zip-file
# Build the tools & create the zip-file and nuget packages
# Chocolatey tools are in .\tools. NuGet packages in .\artifacts
- name: Build & Package
run: pwsh .\build.ps1

Expand All @@ -49,7 +50,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Create GitHub release with created zip-file and CHANGELOG
# 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
Expand All @@ -60,40 +61,17 @@ jobs:
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 }}

# package for publishing to nuget
# For NuGet we can only publish per tool, not as a complete package.
- name: Package for .NET tools
run: dotnet pack ./src/DocFxCompanionTools.sln -c Release -p:PackAsTool=true -o ./artifacts

- name : Publish DocLinkChecker to NuGet
uses: nuget-publish.yml@v1
with:
nuget_api_key: ${{ secrets.NUGET_TOOLS }}
nuget_source: https://api.nuget.org/v3/index.json
nuget_package: ./artifacts/DocLinkChecker.${{ steps.gitversion.outputs.MajorMinorPatch }}.nupkg

- name : Publish DocLanguageTranslator to NuGet
uses: nuget-publish.yml@v1
with:
nuget_api_key: ${{ secrets.NUGET_TOOLS }}
nuget_source: https://api.nuget.org/v3/index.json
nuget_package: ./artifacts/DocLanguageTranslator.${{ steps.gitversion.outputs.MajorMinorPatch }}.nupkg

- name : Publish DocFxTocGenerator to NuGet
uses: nuget-publish.yml@v1
with:
nuget_api_key: ${{ secrets.NUGET_TOOLS }}
nuget_source: https://api.nuget.org/v3/index.json
nuget_package: ./artifacts/DocFxTocGenerator.${{ steps.gitversion.outputs.MajorMinorPatch }}.nupkg

- name : Publish DocFxOpenApi to NuGet
uses: nuget-publish.yml@v1
with:
nuget_api_key: ${{ secrets.NUGET_TOOLS }}
nuget_source: https://api.nuget.org/v3/index.json
nuget_package: ./artifacts/DocFxOpenApi.${{ steps.gitversion.outputs.MajorMinorPatch }}.nupkg
# 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
}
4 changes: 3 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ if (Test-Path -Path $solution.assetZipPath) {
# Build all dotnet solution into $solution.targetFolder as single exe's
foreach ($sln in (Get-ChildItem -Recurse src\*.sln)) {
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
}

# Package NuGet packages
dotnet pack ./src/DocFxCompanionTools.sln -c Release -p:PackAsTool=true -o ./artifacts

# remove possible generated XML documentation files
Remove-Item "$($solution.targetFolder)\*.xml"
# Copy license to the folder to package
Expand Down
6 changes: 5 additions & 1 deletion tools/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ function RemovePath {
function GetCurrentVersionFromGitTag {
param($gitCommand)
$stdout = & $gitCommand describe --abbrev=0 --tags
return $stdout ? $stdout.Trim() : ''
if ($stdout) {
return $stdout;
} else {
return '';
}
}

function GetVersionFromReleaseNote {
Expand Down

0 comments on commit 27285a8

Please sign in to comment.