Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bjoluc/semantic-release-config-poetry

A shareable semantic-release configuration and composite GitHub action for Python packages that use Poetry
https://github.com/bjoluc/semantic-release-config-poetry

github github-action python python-poetry semantic-release semantic-release-config

Last synced: 14 days ago
JSON representation

A shareable semantic-release configuration and composite GitHub action for Python packages that use Poetry

Awesome Lists containing this project

README

        

# @bjoluc/semantic-release-config-poetry

[![npm](https://img.shields.io/npm/v/@bjoluc/semantic-release-config-poetry/latest)](https://www.npmjs.com/package/@bjoluc/semantic-release-config-npm)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bjoluc/semantic-release-config-poetry/build.yml)](https://github.com/bjoluc/semantic-release-config-poetry/actions)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

A shareable semantic-release configuration and composite GitHub Action for Python packages that use Poetry.

## How to use this

- Follow [Conventional Commits](https://www.conventionalcommits.org) (for instance, using [commitizen](https://pypi.org/project/commitizen/)).

- Create an [API token](https://pypi.org/help/#apitoken) for PyPI (or another package index of your choice, like [Test PyPI](https://test.pypi.org/)).

- 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:

```yml
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@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install poetry
run: pip install poetry==1.2.1
- uses: bjoluc/semantic-release-config-poetry@v2
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
```

- If you are not using GitHub Actions, configure a release job in your CI like this:
- Install Python, Poetry, and a Node.js LTS version
- Run `npm install --no-save @bjoluc/semantic-release-config-poetry`
- Run `npx semantic-release --extends @bjoluc/semantic-release-config-poetry`

## Configuration

The shareable semantic-release configuration exposed by this package requires the following environment variables.
When using the GitHub action, each environment variable can be set via its corresponding lower-case input variable (e.g., `pypi_token` for `PYPI_TOKEN`).

| Environment variable | Description |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `PYPI_TOKEN` | An API token for the PyPI repository specified by `PYPI_REPOSITORY` |
| `GITHUB_TOKEN` | A GitHub API token to publish GitHub releases and comment on resolved issues. The `github_token` Action input is optional and defaults to the value of the `GITHUB_TOKEN` secret. |

Furthermore, the following optional environment variables can be set:

| Environment variable | Description | Default value |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
| `PYPI_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/` |
| `RELEASE_BRANCH` | The name of the Git branch to be released | `main` |
| `CHANGELOG_FILE` | The path of the changelog file | `CHANGELOG.md` |