Skip to content

Publish Python Package #18

Publish Python Package

Publish Python Package #18

Workflow file for this run

name: Publish Python Package
on:
release:
types: [ created ]
jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Extract release version
id: get_version
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Update version in pyproject.toml
working-directory: src/python
run: |
sed -i '' 's/^version = .*/version = "${{ env.version }}"/' pyproject.toml
- name: Commit updated pyproject.toml
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add pyproject.toml
git commit -m "Bump version to ${{ env.version }}"
git push
working-directory: src/python
- name: Install dependencies
working-directory: src/python
run: |
python -m pip install --upgrade pip
pip install build
- name: Build a binary wheel dist
working-directory: src/python
run: |
rm -rf dist
python -m build
- name: Quick test of the built dist
run: |
pip install "src/python/dist/$(ls src/python/dist/ | head -1)"
python -c "import pose_format"
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: src/python/dist/
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}