Skip to content

Commit

Permalink
simultaneous pypi + release publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
mikel.brostrom committed May 25, 2023
1 parent 0760a12 commit 6fffa56
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish to PyPI

on:
push:
branches: [main, create-pip-package]
branches: [main]
workflow_dispatch:
inputs:
pypi:
Expand All @@ -16,25 +16,70 @@ jobs:
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: 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: Get current package version
id: get_version
run: |
current_version=$(python -c "from your_package import __version__; print(__version__)")
echo "::set-output name=version::$current_version"
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 "::set-output name=new_version::$new_version"
if: ${{ success() }}

- name: Commit and push updated version
run: |
git add boxmot/__init__.py
git commit -m "Update package version"
git push
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() }}

- 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


0 comments on commit 6fffa56

Please sign in to comment.