Skip to content

Commit

Permalink
Publish NuGet packages to multiple sources (#93)
Browse files Browse the repository at this point in the history
* Publish packages to multiple sources
  • Loading branch information
piotrzajac authored Dec 12, 2023
1 parent 2026aa6 commit f88ec44
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ jobs:
publish:
needs: [build-test-pack]
if: ${{ inputs.environment != null }}
permissions: {}
permissions:
packages: write
uses: ./.github/workflows/publish.yml
with:
environment: ${{ inputs.environment }}
secrets:
nuget-api-key: ${{ secrets.NUGET_API_KEY }}
secrets: inherit

tag:
needs: [publish, init]
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ on:
type: string
required: true
default: prod
secrets:
nuget-api-key:
description: Value of NuGet API key used to upload packages
required: true

env:
DOTNET_NOLOGO: true
Expand All @@ -25,13 +21,19 @@ jobs:
run:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions: {}
permissions:
packages: write
environment:
name: ${{ inputs.environment }}
strategy:
matrix:
packageSource:
- { url: 'https://api.nuget.org/v3/index.json', apiKeySecretName: 'NUGET_API_KEY' }
- { url: 'https://nuget.pkg.github.com/ObjectivityLtd/index.json', apiKeySecretName: 'GITHUB_TOKEN' }
steps:
- name: 🔽 download packages
uses: actions/download-artifact@v3
with:
name: packages
- name: 📤 push
run: dotnet nuget push **/*.nupkg --api-key ${{ secrets.nuget-api-key }} --source "nuget.org" --skip-duplicate
run: dotnet nuget push **/*.nupkg --api-key ${{ secrets[matrix.packageSource.apiKeySecretName] }} --source "${{ matrix.packageSource.url }}" --skip-duplicate

0 comments on commit f88ec44

Please sign in to comment.