Bump peaceiris/actions-gh-pages from 3 to 4 (#107) #92
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 distributions | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
pull_request: | |
branches: | |
- main | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
publish: | |
type: choice | |
description: 'Publish to TestPyPI?' | |
options: | |
- false | |
- true | |
jobs: | |
build-and-publish: | |
name: Build and publish Python distro to (Test)PyPI | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install build, check-manifest, and twine | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
python -m pip install build check-manifest twine | |
python -m pip list | |
- name: Check MANIFEST | |
run: | | |
check-manifest | |
- name: Build a sdist and a wheel | |
run: | | |
python -m build . | |
- name: Verify the distribution | |
run: twine check dist/* | |
- name: List contents of sdist | |
run: python -m tarfile --list dist/packtivity-*.tar.gz | |
- name: List contents of wheel | |
run: python -m zipfile --list dist/packtivity-*.whl | |
- name: Publish distribution 📦 to Test PyPI | |
# Publish to TestPyPI on tag events of if manually triggered | |
# Compare to 'true' string as booleans get turned into strings in the console | |
if: >- | |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && github.repository == 'yadage/packtivity') | |
|| (github.event_name == 'workflow_dispatch' && github.event.inputs.publish == 'true' && github.repository == 'yadage/packtivity') | |
uses: pypa/[email protected] | |
with: | |
password: ${{ secrets.test_pypi_password }} | |
repository_url: https://test.pypi.org/legacy/ | |
print_hash: true | |
- name: Publish distribution 📦 to PyPI | |
# publish to PyPI on releases | |
if: github.event_name == 'release' && github.event.action == 'published' && github.repository == 'yadage/packtivity' | |
uses: pypa/[email protected] | |
with: | |
password: ${{ secrets.pypi_password }} | |
print_hash: true |