A shareable semantic-release configuration and composite GitHub Action for Python packages that use Poetry.
-
Follow Conventional Commits (for instance, using commitizen).
-
Create an API token for PyPI (or another package index of your choice, like Test PyPI).
-
If you are using GitHub Actions:
- Add your PyPI API token as a secret named
PYPI_TOKEN
. - Add a release job to your workflow like this:
jobs: test: ... release: name: Release runs-on: ubuntu-latest needs: test if: github.repository_owner == 'your-github-name' && github.event_name == 'push' && github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: python-version: 3.8 - name: Install poetry run: pip install poetry==1.1.6 - uses: bjoluc/semantic-release-config-poetry@v1 with: pypi_token: ${{ secrets.PYPI_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
- Add your PyPI API token as a secret named
-
If you are not using GitHub Actions, configure a release job in your CI like this:
- Install Python, Poetry, and Node.js
- Run
npm install semantic-release @bjoluc/semantic-release-config-poetry
- Run
npx semantic-release --extends @bjoluc/semantic-release-config-poetry
The shareable semantic-release configuration exposed by this package requires the following environment variables:
Environment variable name | GitHub Action input name | Description | GitHub Action input default value |
---|---|---|---|
PYPI_REPOSITORY |
repository |
The repository to upload your Python package to (e.g., https://upload.pypi.org/legacy/ for PyPI, or https://test.pypi.org/legacy/ for Test PyPI) |
https://upload.pypi.org/legacy/ |
PYPI_TOKEN |
pypi_token |
An API token for the specified PyPI repository | - |
GITHUB_TOKEN |
github_token |
A GitHub API token (to publish GitHub releases and comment on resolved issues) | - |