Publish to PyPI #279
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish to PyPI | |
on: | |
workflow_run: | |
workflows: | |
- Tests | |
types: | |
- completed | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
autotag: | |
name: Create tag if the commit has new version implemented | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
outputs: | |
tagcreated: ${{ steps.autotag.outputs.tagcreated }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Autotag | |
id: autotag | |
uses: butlerlogic/[email protected] | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
with: | |
strategy: regex | |
root: "oml/__init__.py" | |
regex_pattern: > | |
^__version__ = ['"]([^'"]*)['"] | |
tag_prefix: "release." | |
build_and_publish_to_pypi: | |
name: Build and publish Python distribution to PyPI | |
needs: autotag | |
if: ${{ needs.autotag.outputs.tagcreated == 'yes' }} | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.8.0" | |
- name: Build a binary wheel | |
run: | | |
make build_wheel | |
- name: Publish distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} |