|
7 | 7 | description: "Publish to NuGet.org (PowerShell Gallery uses same feed)" |
8 | 8 | required: false |
9 | 9 | default: "true" |
10 | | - publishToGitHub: |
11 | | - description: "Publish to GitHub Packages" |
12 | | - required: false |
13 | | - default: "true" |
14 | 10 | versionOverride: |
15 | 11 | description: "Override module version (optional)" |
16 | 12 | required: false |
|
27 | 23 | required: false |
28 | 24 | NUGETAPIKEY: |
29 | 25 | required: false |
30 | | - PACKAGES_TOKEN: |
31 | | - required: false |
32 | 26 | workflow_run: |
33 | 27 | workflows: ["Tests"] |
34 | 28 | types: |
|
38 | 32 |
|
39 | 33 | permissions: |
40 | 34 | contents: write |
41 | | - packages: write |
42 | 35 |
|
43 | 36 | jobs: |
44 | 37 | validate-and-publish: |
|
47 | 40 | env: |
48 | 41 | PSGALLERYAPIKEY: ${{ secrets.PSGALLERYAPIKEY }} |
49 | 42 | NUGETAPIKEY: ${{ secrets.NUGETAPIKEY }} |
50 | | - PACKAGES_TOKEN: ${{ github.token }} |
51 | 43 | PUBLISH_TO_NUGET_INPUT: ${{ github.event.inputs.publishToNuGet }} |
52 | | - PUBLISH_TO_GITHUB_INPUT: ${{ github.event.inputs.publishToGitHub }} |
53 | 44 | CREATE_RELEASE_INPUT: ${{ github.event.inputs.createRelease }} |
54 | 45 | steps: |
55 | 46 | - name: Harden the runner (Audit all outbound calls) |
@@ -333,22 +324,3 @@ jobs: |
333 | 324 | Write-Host "Publishing $packagePath to NuGet.org" |
334 | 325 | dotnet nuget push $packagePath --api-key $apiKey --source https://api.nuget.org/v3/index.json --skip-duplicate |
335 | 326 | shell: pwsh |
336 | | - |
337 | | - - name: Publish to GitHub Packages |
338 | | - if: ${{ env.PACKAGES_TOKEN != '' && (github.event_name != 'workflow_dispatch' || env.PUBLISH_TO_GITHUB_INPUT != 'false') }} |
339 | | - run: | |
340 | | - $packagePath = '${{ steps.package.outputs.packagePath }}' |
341 | | - if (-not (Test-Path $packagePath)) { |
342 | | - throw "Package not found at $packagePath" |
343 | | - } |
344 | | -
|
345 | | - $token = $env:PACKAGES_TOKEN |
346 | | - if ([string]::IsNullOrWhiteSpace($token)) { |
347 | | - Write-Host 'No GitHub Packages token provided. Skipping publish.' |
348 | | - return |
349 | | - } |
350 | | -
|
351 | | - $source = "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" |
352 | | - Write-Host "Publishing $packagePath to GitHub Packages feed $source" |
353 | | - dotnet nuget push $packagePath --api-key $token --source $source --skip-duplicate |
354 | | - shell: pwsh |
0 commit comments