Complete PyPI automation - build, publish, and workflow generation
Automates complete PyPI publishing workflow with build, validation, and GitHub Actions setup.
/plugin marketplace add Data-Wise/craft/plugin install data-wise-craft@Data-Wise/craftdist/Complete PyPI publishing automation with GitHub Actions workflows.
| Command | Purpose |
|---|---|
publish | Build and publish to PyPI (default) |
workflow | Generate GitHub Actions release workflow |
validate | Check package structure and metadata |
setup | Full setup wizard (workflow + trusted publishing) |
check | Pre-flight checks before publishing |
# Validate package before publishing
/craft:dist:pypi validate
# Full automated setup (recommended for new projects)
/craft:dist:pypi setup
# Generate release workflow
/craft:dist:pypi workflow
# Pre-flight checks
/craft:dist:pypi check
Build and publish package to PyPI.
/craft:dist:pypi publish # Publish current version
/craft:dist:pypi publish --version 1.2.3 # Publish specific version
pyproject.toml with valid metadata# Build package
uv build
# Publish to TestPyPI first
uv publish --repository testpypi
# Publish to PyPI
uv publish
Generate GitHub Actions workflow for automated PyPI releases.
/craft:dist:pypi workflow # Generate workflow
/craft:dist:pypi workflow --test # Include TestPyPI step
.github/workflows/pypi-release.yml
name: PyPI Release
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Version to publish (must match pyproject.toml)'
required: true
type: string
jobs:
publish:
name: Build and Publish to PyPI
runs-on: ubuntu-latest
environment: pypi # Must match PyPI trusted publisher config
permissions:
id-token: write # For trusted publishing
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Set up Python
run: uv python install 3.12
- name: Install dependencies
run: uv sync
- name: Build package
run: uv build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
skip-existing: true prevents accidental overwritesValidate package structure and metadata before publishing.
/craft:dist:pypi validate
| Check | Description |
|---|---|
pyproject.toml | Valid TOML, required fields present |
version | Matches expected format (PEP 440) |
readme | README file exists and is referenced |
license | License file or classifier present |
classifiers | Valid PyPI classifiers |
dependencies | All dependencies are valid |
build | Package builds successfully |
╭─────────────────────────────────────────────────────────────╮
│ PyPI Package Validation │
├─────────────────────────────────────────────────────────────┤
│ ✓ pyproject.toml valid │
│ ✓ Version: 0.6.1 (PEP 440 compliant) │
│ ✓ README.md found and referenced │
│ ✓ License: MIT │
│ ✓ 4 classifiers valid │
│ ✓ 4 dependencies valid │
│ ✓ Build successful │
├─────────────────────────────────────────────────────────────┤
│ ✅ Ready to publish │
╰─────────────────────────────────────────────────────────────╯
Full setup wizard for new PyPI publishing.
/craft:dist:pypi setup
Validate Package
Generate Workflow
.github/workflows/pypi-release.ymlGuide Trusted Publishing Setup
Create First Release (optional)
After running setup, configure PyPI:
pypi-release.ymlpypiPre-flight checks before publishing.
/craft:dist:pypi check
| Check | Description |
|---|---|
| Version Sync | pyproject.toml == init.py == git tag |
| Clean Repo | No uncommitted changes |
| Tests Pass | pytest returns 0 |
| Build Works | uv build succeeds |
| Not Published | Version not already on PyPI |
╭─────────────────────────────────────────────────────────────╮
│ PyPI Pre-Flight Checks │
├─────────────────────────────────────────────────────────────┤
│ ✓ Version sync: 0.6.1 (pyproject.toml, __init__.py, tag) │
│ ✓ Repository clean │
│ ✓ Tests passing (135 passed) │
│ ✓ Build successful │
│ ✓ Version 0.6.1 not on PyPI │
├─────────────────────────────────────────────────────────────┤
│ ✅ Ready to publish │
│ │
│ Next: Create GitHub release to trigger workflow │
│ gh release create v0.6.1 --title "v0.6.1" --generate-notes│
╰─────────────────────────────────────────────────────────────╯
/craft:dist:pypi workflow WhenYou want to automate PyPI publishing via GitHub Actions. This is the recommended approach for consistent, secure releases.
/craft:dist:pypi validate WhenBefore any release, to catch issues early. Run this as part of your pre-release checklist.
/craft:dist:pypi check WhenYou're about to create a release and want to ensure everything is in order.
/craft:dist:pypi setup WhenSetting up a new project for PyPI publishing for the first time.
/craft:dist:homebrew - Homebrew formula automation/craft:dist:curl-install - curl installer generation/craft:check --for release - Release readiness check/craft:git:tag - Create release tags/craft:dist:pypi is Invokedpublish)publish: Build and guide through publishingworkflow: Generate GitHub Actions workflowvalidate: Run all validation checkssetup: Full wizard flowcheck: Pre-flight checksEnsure these match before publishing:
pyproject.toml → version = "X.Y.Z"src/package/__init__.py → __version__ = "X.Y.Z"vX.Y.Z