Skip to content

Merge pull request #66 from dodge-research-group/dev #67

Merge pull request #66 from dodge-research-group/dev

Merge pull request #66 from dodge-research-group/dev #67

name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
# Modified from https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/# ,
# based on suggestions from https://pyopensci.discourse.group/t/trouble-github-action-for-publishing-to-pypi/355?u=jsdodge
# and https://github.com/dodge-research-group/thztools/pull/23
on:
release:
types: [published]
push:
branches:
- main
jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install hatch
run: pip install hatch
- name: Build a binary wheel and a source tarball
run: hatch build
- name: Publish distribution 📦 to Test PyPI
if: github.event_name == 'push'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI }}
repository-url: https://test.pypi.org/legacy/
skip_existing: true
- name: Publish distribution 📦 to PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI }}