Skip to main content

CLI tool to publish Python packages and documentation with external configuration

Project description

cal-publish-python

CLI tool to publish Python packages and documentation with external configuration.

Overview

cal-publish-python is designed to keep sensitive configuration (tokens, registry URLs, SSH keys) outside of build jobs. The project being published defines the "what" (name, version), while the publishing configuration defines the "where" (registry, documentation platform).

Installation

pip install cal-publish-python

Or with uv:

uv pip install cal-publish-python

Usage

Publishing to PyPI

cal-publish-python pypi --output-dir output/

Or specify a wheel directly:

cal-publish-python pypi --wheel output/my-package-1.0.0-py3-none-any.whl

Publishing Documentation

GitLab Pages Mode

cal-publish-python docs --project my-project --doc-version 1.0.0 --html html/

With options:

cal-publish-python docs -p my-project -V 1.0.0 -H html/ --set-latest --force

SSH Mode

Configure SSH mode in your config file, then:

cal-publish-python docs -p my-project -V 1.0.0 --output-dir output/

Configuration

Config File

Create a JSON configuration file:

{
    "pypi": {
        "token": "pypi-xxxxxxxxxxxx",
        "repository_url": "https://upload.pypi.org/legacy/"
    },
    "docs": {
        "mode": "gitlab-pages",
        "gitlab_pages": {
            "token": "glpat-xxxxxxxxxxxx",
            "url": "https://gitlab.com",
            "group": "docs"
        },
        "ssh": {
            "host": "docs.example.com",
            "base_path": "/var/www/docs",
            "ssh_key": "~/.ssh/id_rsa",
            "user": "deploy",
            "port": 22
        }
    }
}

Set the config file path via environment variable:

export CAL_PUBLISH_CONFIG=/path/to/config.json

Or pass it directly:

cal-publish-python -c config.json pypi --output-dir output/

Environment Variables

All configuration values can be overridden by environment variables:

Variable Description
CAL_PUBLISH_CONFIG Path to JSON config file
CAL_PUBLISH_PYPI_TOKEN PyPI API token
CAL_PUBLISH_PYPI_REPOSITORY_URL PyPI repository URL
CAL_PUBLISH_DOCS_MODE Documentation mode (gitlab-pages or ssh)
CAL_PUBLISH_GITLAB_TOKEN GitLab personal access token
CAL_PUBLISH_GITLAB_URL GitLab instance URL
CAL_PUBLISH_GITLAB_GROUP GitLab group for docs
CAL_PUBLISH_SSH_HOST SSH host
CAL_PUBLISH_SSH_BASE_PATH Base path on remote server
CAL_PUBLISH_SSH_KEY Path to SSH private key
CAL_PUBLISH_SSH_USER SSH user
CAL_PUBLISH_SSH_PORT SSH port

Integration with Makefile

Add a publish target to your project's Makefile:

.PHONY: publish
publish: build
	cal-publish-python pypi --output-dir output/
	cal-publish-python docs -p $(PROJECT_NAME) -V $(VERSION_STR) --output-dir output/ --set-latest

Development

# Clone the repository
git clone <repo-url>
cd cal-publish-python

# Set up development environment
make dev

# Run checks
make check

# Build
make build

Licence

MIT License — Copyright (c) 2026 Cyber Assessment Labs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cal_publish_python-0.3.1-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

Details for the file cal_publish_python-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for cal_publish_python-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fe3daae368beb3d1083013e41efc7216937d2bae899e48a3bd5248c9a8cbf0d7
MD5 185f64cb5c90d9ba29bd83f5f0e3b75c
BLAKE2b-256 d0a9a6a3932e5a1c1fad6642bd1969fe3c68bc22c6d722798939a25814a634f3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page