diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27ad8bcf4..7faef4e63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -272,6 +272,8 @@ jobs: if: github.event_name == 'workflow_dispatch' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/v2') runs-on: ubuntu-latest needs: [ validate-nuget, run-test, validate-template, validate-docs ] + permissions: + id-token: write steps: - uses: actions/download-artifact@v5 with: @@ -284,5 +286,11 @@ jobs: - name: 🛠️ Upload library to GitHub Package Repository run: dotnet nuget push ${{ env.NUGET_DIRECTORY }}/*.nupkg -k ${{ secrets.GITHUB_TOKEN }} -s https://nuget.pkg.github.com/bunit-dev/index.json --skip-duplicate --no-symbols + - name: 🛠️ NuGet login + uses: NuGet/login@v1 + id: nuget-login + with: + user: ${{ secrets.NUGET_USER }} + - name: 🛠️ Upload library to NuGet.org repository - run: dotnet nuget push ${{ env.NUGET_DIRECTORY }}/*.nupkg -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols + run: dotnet nuget push ${{ env.NUGET_DIRECTORY }}/*.nupkg -k ${{ steps.nuget-login.outputs.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9b0196f97..9e28b01c6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,6 +26,8 @@ jobs: if: github.ref == 'refs/heads/stable' || github.event.pull_request.merged == true && contains(github.head_ref, 'release/v') == true runs-on: ubuntu-latest + permissions: + id-token: write steps: - name: 🛒 Checkout repository @@ -101,9 +103,15 @@ jobs: dotnet pack src/bunit.web.query/ -c Release --property:PackageOutputPath=${GITHUB_WORKSPACE}/packages -p:ContinuousIntegrationBuild=true -p:publicrelease=true dotnet pack src/bunit.generators/ -c Release --property:PackageOutputPath=${GITHUB_WORKSPACE}/packages -p:ContinuousIntegrationBuild=true -p:publicrelease=true + - name: 🛠️ NuGet login + uses: NuGet/login@v1 + id: nuget-login + with: + user: ${{ secrets.NUGET_USER }} + - name: 🛠️ Upload library to NuGet.org repository run: | - dotnet nuget push ${GITHUB_WORKSPACE}/packages/*.nupkg -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols + dotnet nuget push ${GITHUB_WORKSPACE}/packages/*.nupkg -k ${{ steps.nuget-login.outputs.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols - name: ⏩ Push stable branch run: git push origin stable