Skip to content

PyPI Release

PyPI Release #33

Workflow file for this run

name: PyPI Release
on:
pull_request:
types:
- closed
paths:
- 'pyproject.toml'
branches:
- main
workflow_dispatch:
jobs:
build:
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install Poetry
run: |
pip install poetry
- name: Check changelog and create release notes
id: release_notes
run: |
VERSION=$(poetry version | awk '{print $2}')
echo "::set-output name=version::$VERSION"
if ! grep -q "Version $VERSION" CHANGES.rst; then
echo "No changelog entry found for version $VERSION"
exit 1
fi
NOTES=$(awk -v ver="$VERSION" '/Version/{if(p){exit}; if($2 == ver){p=1;next}} p' CHANGES.rst | sed '/^--*$/d')
NOTES="${NOTES//'%'/'%25'}"
NOTES="${NOTES//$'\n'/'%0A'}"
NOTES="${NOTES//$'\r'/'%0D'}"
echo "::set-output name=notes::$(printf '%s' "$NOTES")"
- name: Build and publish
run: |
poetry install --no-dev
poetry build
poetry config pypi-token.pypi ${{ secrets.WORDVIEW_PYPI_TOKEN }}
poetry publish
- name: Create GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.release_notes.outputs.version }}
release_name: Release ${{ steps.release_notes.outputs.version }}
body: ${{ steps.release_notes.outputs.notes }}