Skip to content

v1.5.0

v1.5.0 #6

Workflow file for this run

name: Publish to PyPI
on:
release:
types: [published]
workflow_dispatch:
inputs:
test-pypi:
description: 'Publish to TestPyPI instead of PyPI'
required: false
default: false
type: boolean
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Clean before build
run: |
rm -rf dist/ build/ *.egg-info/
find . -type d -name __pycache__ -exec rm -rf {} + || true
- name: Build package
run: python -m build
- name: Check package
run: twine check dist/*
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
publish:
needs: build
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.test-pypi == 'true' && 'testpypi' || 'pypi' }}
url: ${{ github.event.inputs.test-pypi == 'true' && 'https://test.pypi.org/p/docpull' || 'https://pypi.org/p/docpull' }}
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish to TestPyPI
if: github.event.inputs.test-pypi == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
- name: Publish to PyPI
if: github.event.inputs.test-pypi != 'true'
uses: pypa/gh-action-pypi-publish@release/v1