Skip to content

Publish to PyPI

Publish to PyPI #76

Workflow file for this run

name: Publish to PyPI
on:
push:
branches: [main]
workflow_dispatch:
inputs:
pypi:
type: boolean
description: Publish to PyPI
jobs:
pypi-upload:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python environment
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel build twine
pip install numpy
pip install -e '.[dev]' --extra-index-url https://download.pytorch.org/whl/cpu
- name: Get current package version
id: get_version
run: |
current_version=$(python -c "from boxmot import __version__; print(__version__)")
echo "version=$current_version" >> $GITHUB_OUTPUT
if: ${{ success() }}
- name: Increment package version
id: increment_version
run: |
current_version="${{ steps.get_version.outputs.version }}"
IFS='.' read -r -a version_parts <<< "$current_version"
((version_parts[2]++))
new_version="${version_parts[0]}.${version_parts[1]}.${version_parts[2]}"
echo $new_version
echo "new_version=$new_version" >> $GITHUB_OUTPUT
if: ${{ success() }}
- name: Update package version
run: |
new_version="${{ steps.increment_version.outputs.new_version }}"
sed -i "s/__version__ = .*/__version__ = '$new_version'/" boxmot/__init__.py
if: ${{ success() }}
- name: Commit and push updated version
run: |
current_version="${{ steps.get_version.outputs.version }}"
new_version="${{ steps.increment_version.outputs.new_version }}"
git config --local user.email [email protected]
git config --local user.name mikel-brostrom
git add boxmot/__init__.py
git commit -m "Update package version from $current_version to $new_version"
git push
if: ${{ success() }}
- name: Create source distribution
run: |
python setup.py sdist bdist_wheel
if: ${{ success() }}
- name: Twine check # Checks whether the long description will render correctly on PyPI
run: |
twine check dist/*
if: ${{ success() }}
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
#repository_url: https://test.pypi.org/legacy/
password: ${{ secrets.PYPI_TOKEN }}
user: __token__
verbose: true
if: ${{ success() }}
- name: Create code release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.increment_version.outputs.new_version }}
release_name: Release v${{ steps.increment_version.outputs.new_version }}
draft: false
prerelease: false
if: ${{ success() }}