From 76a3018cb85be9d7260da72155cb90349740150d Mon Sep 17 00:00:00 2001 From: rameel Date: Tue, 17 Nov 2026 01:38:34 +0500 Subject: [PATCH 1/2] build: publish NuGet packages with trusted publishing --- .github/workflows/publish.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4af1ee9..b457fcb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,14 +6,16 @@ on: - "[0-9]+.[0-9]+.[0-9]+" - "[0-9]+.[0-9]+.[0-9]+-[a-z]+.[0-9]+" -permissions: - contents: write - jobs: publish: if: github.repository == 'rameel/ramstack.parsing' name: Publish packages runs-on: ubuntu-latest + environment: publish + + permissions: + contents: write + id-token: write steps: - name: Install .NET @@ -30,8 +32,14 @@ jobs: - name: Create NuGet Packages run: dotnet pack -c Release -o ./nuget --no-build + - name: NuGet login (OIDC) + id: login + uses: NuGet/login@v1 + with: + user: ${{ secrets.NUGET_USER }} + - name: Publish NuGet Packages - run: dotnet nuget push ./nuget/*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate -s https://api.nuget.org/v3/index.json + run: dotnet nuget push ./nuget/*.nupkg --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --skip-duplicate -s https://api.nuget.org/v3/index.json - name: Create GitHub Release uses: softprops/action-gh-release@v3 From 3265d6aaa8a961f56d2c804ad3743e78fca03b88 Mon Sep 17 00:00:00 2001 From: rameel Date: Tue, 17 Nov 2026 01:38:34 +0500 Subject: [PATCH 2/2] build: publish only tags that point to the head of main --- .github/workflows/publish.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b457fcb..c0cced8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -26,6 +26,9 @@ jobs: - name: Checkout uses: actions/checkout@v7 + - name: Verify tag commit is main HEAD + run: test "$GITHUB_SHA" = "$(git ls-remote origin refs/heads/main | cut -f1)" + - name: Build Solution run: dotnet build -c Release -p:SkipInternalsVisibleTo=true