Skip to content

Commit

Permalink
Merge pull request #378 from Lombiq/issue/OCC-245
Browse files Browse the repository at this point in the history
OCC-245: Add the option to publish without Microsoft.SourceLink.GitHub
  • Loading branch information
sarahelsaig authored Jul 27, 2024
2 parents 4d374c4 + ae3ff79 commit 3a7674d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
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

0 comments on commit 3a7674d

Please sign in to comment.