diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90de12d..a74582f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,8 @@ name: Test on: push: + branches: + - master paths-ignore: - 'doc/**' pull_request: @@ -31,7 +33,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - fetch-depth: 1 + persist-credentials: false - name: Set up Python ${{ matrix.python-version }} uses: astral-sh/setup-uv@v6 @@ -55,7 +57,7 @@ jobs: build: name: build distribution - if: github.repository_owner == 'sphinx-doc' && github.ref == 'refs/heads/master' + if: ${{ github.repository_owner == 'sphinx-doc' && github.ref == 'refs/heads/master' }} needs: - tests runs-on: ubuntu-latest @@ -64,7 +66,8 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - fetch-depth: 1 + persist-credentials: false + fetch-depth: 0 - name: Set up Python uses: astral-sh/setup-uv@v6 @@ -78,9 +81,32 @@ jobs: name: distributions path: dist/ - pypi-publish: + publish-to-testpypi: + name: Upload release to TestPyPI + if: ${{ github.repository_owner == 'sphinx-doc' && github.ref == 'refs/heads/master' }} # only publish to TestPyPI on push to master + needs: + - build + runs-on: ubuntu-latest + environment: + name: testpypi + url: https://test.pypi.org/p/sphinx-intl + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: distributions + path: dist/ + - name: Publish package distributions to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + verbose: true + repository-url: https://test.pypi.org/legacy/ + + publish-to-pypi: name: Upload release to PyPI - if: github.repository_owner == 'sphinx-doc' && startsWith(github.ref, 'refs/tags/') + if: ${{ github.repository_owner == 'sphinx-doc' && startsWith(github.ref, 'refs/tags/') }} needs: - build runs-on: ubuntu-latest @@ -102,36 +128,35 @@ jobs: with: verbose: true - # for test - password: ${{ secrets.TESTPYPI_TOKEN }} - repository_url: https://test.pypi.org/legacy/ - - # for production - # password: ${{ secrets.PYPI_TOKEN }} - github-release: - name: GitHub release - if: github.repository_owner == 'sphinx-doc' + name: Sign the Python 🐍 distribution 📦 with Sigstore and upload them to GitHub Release + if: ${{ github.repository_owner == 'sphinx-doc' && startsWith(github.ref, 'refs/tags/') }} runs-on: ubuntu-latest needs: - - pypi-publish + - publish-to-pypi environment: release permissions: - contents: write # for softprops/action-gh-release to create GitHub release - + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Get release version - id: get_version - uses: actions/github-script@v7 + - name: Download all the dists + uses: actions/download-artifact@v4 with: - script: core.setOutput('version', context.ref.replace("refs/tags/", "")) - - - name: Create GitHub release - uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') + name: distributions + path: dist/ + - name: Sign the dists with Sigstore + uses: sigstore/gh-action-sigstore-python@v3.0.0 with: - name: "sphinx-intl ${{ steps.get_version.outputs.version }}" - body: "Changelog: https://sphinx-intl.readthedocs.io/en/master/changes.html" + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. + # `dist/` contains the built packages, and the + # sigstore-produced signatures and certificates. + run: >- + gh release upload + "$GITHUB_REF_NAME" dist/** + --repo "$GITHUB_REPOSITORY" diff --git a/CHANGES.rst b/CHANGES.rst index 9e87ded..b7eeef9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,6 +9,7 @@ Environments ------------ * add python-3.14 support by @rffontenelle in https://github.com/sphinx-doc/sphinx-intl/pull/115 +* Release to PyPI with digital attestations (PEP-740) by @shimizukawa in https://github.com/sphinx-doc/sphinx-intl/pull/125 Incompatibility --------------- diff --git a/pyproject.toml b/pyproject.toml index 584b98d..e86e3da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,7 +62,9 @@ build-backend = "setuptools.build_meta" include-package-data = true [tool.setuptools_scm] -# this empty section means: use_scm_version=True +# https://setuptools-scm.readthedocs.io/en/latest/extending/#available-implementations_1 +# because pypi does not support local version like .devN+ +local_scheme = "no-local-version" [tool.mypy] ignore_missing_imports = true