diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4af1ee9..c0cced8 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 @@ -24,14 +26,23 @@ 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 - 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