google / google/flatbuffers

Publish Python package with official action

Open
#8,732 2 comments 1 reaction 0 assignees View on GitHub
CI python
Dominant language
C++
Stars
26.5k
Forks
3.7k
PR merge metrics
No merged PRs in 30d

Description

See [the Python packaging documentation](https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#configuring-trusted-publishing), [the PyPI documentation](https://docs.pypi.org/trusted-publishers/), and [the official pypi-publish GitHub action documentation](https://github.com/pypa/gh-action-pypi-publish?tab=readme-ov-file#trusted-publishing) on trusted publishing.

Actions (click to expand)

- Configure (or use an existing) GitHub environment and add to PyPI
- In the `Publish PyPi` job of the [`Release`](https://github.com/google/flatbuffers/blob/master/.github/workflows/release.yml) CI workflow:
- add aforementioned environment (eg name `pypi`), and permissions:
```diff
+ environment:
+ name: pypi
+ url: https://pypi.org/p/flatbuffers
+ permissions:
+ id-token: write
+ contents: read
```
- in the `Upload to PyPi` step, switch to using the action:
```diff
- run: python3 -m twine upload dist/*
+ uses: pypa/gh-action-pypi-publish@release/v1`
```
- in the `Install Dependencies` step, remove `twine`:
```diff
- python3 -m pip install setuptools wheel twine
+ python3 -m pip install setuptools wheel
```
- You will be able to remove the `TWINE_TOKEN` project secret

Related: #8731

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.