Skip to content

chore: [pre-commit.ci] pre-commit autoupdate #220

chore: [pre-commit.ci] pre-commit autoupdate

chore: [pre-commit.ci] pre-commit autoupdate #220

name: publish distributions
on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types: [published]
workflow_dispatch:
jobs:
build-and-publish:
name: Build and publish Python distro to (Test)PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install python-build, check-manifest, and twine
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install build check-manifest twine
- name: Check MANIFEST
run: |
check-manifest
- name: Build a wheel and a sdist
run: |
python -m build --outdir dist/ .
- name: Verify history available for dev versions
run: |
wheel_name=$(find dist/ -iname "*.whl" -printf "%f\n")
if [[ "${wheel_name}" == *"heputils-0.1.dev"* ]]; then
echo "python-build incorrectly named built distribution: ${wheel_name}"
echo "python-build is lacking the history and tags required to determine version number"
echo "intentionally erroring with 'return 1' now"
return 1
fi
echo "python-build named built distribution: ${wheel_name}"
- name: Verify the distribution
run: twine check dist/*
- name: List contents of sdist
run: tar --list --file dist/heputils-*.tar.gz
- name: Publish distribution 📦 to Test PyPI
# every PR will trigger a push event on main, so check the push event is actually coming from main
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'matthewfeickert/heputils'
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: github.event_name == 'release' && github.event.action == 'published' && github.repository == 'matthewfeickert/heputils'
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
password: ${{ secrets.pypi_password }}