From 5ecd069b844c5a0c58701584fab7bc5b1c021847 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 18 Sep 2024 12:15:06 +1000 Subject: [PATCH] publishing to GitHub packages only after packaging job completes. Done as a workflow_run trigger so that we can run in the right GITHUB_TOKEN context --- .github/workflows/dotnet-publish-ci.yml | 10 +--------- .../workflows/dotnet-publish-gh-packages.yml | 19 +++++++++++++++++++ .github/workflows/dotnet-publish-main.yml | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/dotnet-publish-gh-packages.yml diff --git a/.github/workflows/dotnet-publish-ci.yml b/.github/workflows/dotnet-publish-ci.yml index 6ccf9c81..3b98650f 100644 --- a/.github/workflows/dotnet-publish-ci.yml +++ b/.github/workflows/dotnet-publish-ci.yml @@ -1,7 +1,7 @@ # This workflow will build a .NET project # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net -name: .NET Publish (GitHub Packages) +name: .NET Publish (CI) on: pull_request: @@ -16,11 +16,6 @@ env: jobs: publish-github-packages: runs-on: ubuntu-latest - permissions: - contents: read - packages: write - attestations: write - id-token: write steps: - uses: actions/checkout@v4 - name: Setup .NET @@ -46,6 +41,3 @@ jobs: with: name: nuget-packages path: ./nuget - - - name: Publish to GitHub packages - run: dotnet nuget push ./nuget/*.nupkg --source "https://nuget.pkg.github.com/tonybaloney/index.json" --api-key ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/dotnet-publish-gh-packages.yml b/.github/workflows/dotnet-publish-gh-packages.yml new file mode 100644 index 00000000..a4e4af3a --- /dev/null +++ b/.github/workflows/dotnet-publish-gh-packages.yml @@ -0,0 +1,19 @@ +name: "Publish NuGet packages to GitHub Packages" +on: + workflow_run: + workflows: [".NET Publish (CI)"] + types: + - completed +jobs: + report: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + attestations: write + id-token: write + steps: + - uses: actions/download-artifact@v4 + with: + name: nuget-packages + run-id: ${{ github.event.workflow_run.id }} diff --git a/.github/workflows/dotnet-publish-main.yml b/.github/workflows/dotnet-publish-main.yml index 364b21e4..4142a6cf 100644 --- a/.github/workflows/dotnet-publish-main.yml +++ b/.github/workflows/dotnet-publish-main.yml @@ -1,7 +1,7 @@ # This workflow will build a .NET project # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net -name: .NET Publish (NuGet) +name: .NET Publish (main) on: push: