From 0db7a6043cd5489c715d9ee6a7c4d2af27e5287d Mon Sep 17 00:00:00 2001 From: Divyanshu Jethi <67845323+divyanshujethi@users.noreply.github.com> Date: Sun, 6 Dec 2026 18:15:05 +0530 Subject: [PATCH] fix(ci): restore pypi environment, add skip-existing and explicit token/OIDC split --- .github/workflows/publish-pypi.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 2881307..36dde5c 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -60,6 +60,9 @@ jobs: needs: - build runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/dbshield-defense permissions: contents: read id-token: write @@ -71,10 +74,22 @@ jobs: name: python-package-distributions path: dist/ - - name: Publish distribution 📦 to PyPI + - name: Publish distribution 📦 to PyPI (API Token) + if: env.HAS_PYPI_TOKEN == 'true' + env: + HAS_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN != '' }} uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.12.4 with: password: ${{ secrets.PYPI_API_TOKEN }} + skip-existing: true + + - name: Publish distribution 📦 to PyPI (OIDC Trusted Publishing) + if: env.HAS_PYPI_TOKEN != 'true' + env: + HAS_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN != '' }} + uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.12.4 + with: + skip-existing: true create-release: name: Create GitHub Release with SBOM Artifacts