Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCC-245: Add the option to publish without Microsoft.SourceLink.GitHub #378

Merged
merged 11 commits into from
Jul 27, 2024
2 changes: 1 addition & 1 deletion .github/actions/publish-nuget/Add-SourceLinkPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ foreach ($projectFile in $projectFiles)
# Central Package Management (https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management).
# Unfortunately, this makes NuGet publishing a lot slower than using dotnet restore, and it's also more verbose
# (without the ability to configure that verbosity).
dotnet add $projectFile.FullName package 'Microsoft.SourceLink.GitHub' --source 'https://api.nuget.org/v3/index.json'
dotnet add $projectFile.FullName package 'Microsoft.SourceLink.GitHub'

# The NuGetBuild property mustn't remain in the project file.
$projectXml = [xml](Get-Content $projectFile)
Expand Down
14 changes: 13 additions & 1 deletion .github/actions/publish-nuget/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ inputs:
https://github.com/actions/upload-artifact#retention-period for more details. Note that this only affects the
retention of the workflow run's artifact, not the artifacts attached to the release created on GitHub; those will
remain indefinitely.
add-source-link-package:
required: false
default: 'true'
description: If set to "true", the Microsoft.SourceLink.GitHub NuGet package is added to the projects.

runs:
using: composite
Expand Down Expand Up @@ -114,7 +118,15 @@ runs:
# This also implicitly restores NuGet dependencies.
- name: Add Source Link package
shell: pwsh
run: Add-SourceLinkPackage
run: |
if ('${{ inputs.add-source-link-package }}' -eq 'true')
{
Add-SourceLinkPackage
}
else
{
dotnet restore -p:NuGetBuild=true
}

- name: Update package manifest version
shell: pwsh
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ on:
https://github.com/actions/upload-artifact#retention-period for more details. Note that this only affects the
retention of the workflow run's artifact, not the artifacts attached to the release created on GitHub; those
will remain indefinitely.
add-source-link-package:
type: string
default: 'true'
description: If set to "true", the Microsoft.SourceLink.GitHub NuGet package is added to the projects.

jobs:
publish-nuget:
Expand All @@ -83,6 +87,7 @@ jobs:
dotnet-pack-include-symbols: ${{ inputs.dotnet-pack-include-symbols }}
publish-version: ${{ inputs.publish-version }}
nuget-artifact-retention-days: ${{ inputs.nuget-artifact-retention-days }}
add-source-link-package: ${{ inputs.add-source-link-package }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
API_KEY: ${{ secrets.API_KEY }}
Expand Down
Loading