From f88ec443cef64e490569b34affd86b01e6155273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Zaj=C4=85c?= Date: Tue, 12 Dec 2023 17:17:14 +0100 Subject: [PATCH] Publish NuGet packages to multiple sources (#93) * Publish packages to multiple sources --- .github/workflows/cicd.yml | 6 +++--- .github/workflows/publish.yml | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 9bb49adf..8a40ae1e 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -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] diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c17277a8..0c6008fe 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 @@ -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