erldistpy/Makefile
russell@unturf.com 001a471549
packaging: ship to PyPI via tag + GitLab CI (mirrors ago's pattern)
pyproject.toml gains the metadata PyPI expects:
  - Real author name + email
  - Keywords (erlang, elixir, distribution, gen_server, ...)
  - Classifiers (status, license, Python versions, topic)
  - Project URLs (Homepage / Repository / Bug Tracker)
  - readme content-type = text/markdown so PyPI renders our README
  - build + twine added to the [dev] extra

.gitlab-ci.yml mirrors ago's two-stage pattern:
  - test stage on every push (venv + pip install -e .[dev] + pytest)
  - pypi-twine stage only on tags: python -m build, twine check,
    twine upload. Credentials come from GitLab CI variables
    TWINE_USERNAME (typically __token__) and TWINE_PASSWORD.

Makefile gains build / dist-check / publish-test / publish targets so
the release flow is also runnable locally if a dry run is needed.

Release flow:
  1. Bump version in pyproject.toml
  2. Commit + push
  3. git tag -a vX.Y.Z -m 'release vX.Y.Z' && git push --tags
  4. CI's pypi-twine stage picks up the tag and uploads

README.md adds an Install section + Quick start (plain dist + TLS dist)
so PyPI's project page shows usable copy on first visit. dist/ artifacts
build cleanly and both pass twine check.
2026-06-16 13:45:08 -04:00

76 lines
2.3 KiB
Makefile

VENV_DIR = $(shell pwd)/.venv
PYTHON = $(VENV_DIR)/bin/python
PIP = $(VENV_DIR)/bin/pip
PYTEST = $(VENV_DIR)/bin/pytest
RUFF = $(VENV_DIR)/bin/ruff
.DEFAULT_GOAL := all
.PHONY: all bootstrap venv install test lint format clean help build dist-check publish-test publish
all: bootstrap test lint
help:
@echo "erldistpy targets"
@echo " make bootstrap - create venv, install editable + dev deps"
@echo " make test - run pytest"
@echo " make lint - ruff check"
@echo " make format - ruff format"
@echo " make clean - drop venv + caches"
@echo ""
@echo "Packaging (PyPI):"
@echo " make build - build sdist + wheel into dist/"
@echo " make dist-check - validate built artifacts (twine check)"
@echo " make publish-test- upload to test.pypi.org (needs TWINE_PASSWORD)"
@echo " make publish - upload to pypi.org (needs TWINE_PASSWORD)"
@echo ""
@echo "Release flow: bump version in pyproject.toml, commit, then"
@echo " git tag -a vX.Y.Z -m 'release vX.Y.Z' && git push --tags"
@echo " CI's pypi-twine stage handles the upload from there."
venv:
test -d $(VENV_DIR) || python3 -m venv $(VENV_DIR)
$(PIP) install --upgrade pip wheel setuptools
bootstrap: venv
$(PIP) install -e ".[dev]"
install: bootstrap
test:
$(PYTEST) -v
lint:
$(RUFF) check erldistpy tests
format:
$(RUFF) format erldistpy tests
clean:
rm -rf $(VENV_DIR)
rm -rf .pytest_cache .ruff_cache
rm -rf build dist *.egg-info
find . -type d -name __pycache__ -exec rm -rf {} +
# -- Packaging --------------------------------------------------------------
# Build sdist + wheel; emits dist/erldistpy-<version>.tar.gz +
# dist/erldistpy-<version>-py3-none-any.whl.
build: bootstrap
rm -rf dist build
$(PIP) install --upgrade build
$(PYTHON) -m build
# Validate built artifacts before upload — twine checks long-description
# rendering and required metadata.
dist-check: build
$(PIP) install --upgrade twine
$(VENV_DIR)/bin/twine check dist/*
# Upload to TestPyPI for a dry run before tagging a real release.
# TWINE_USERNAME=__token__ and TWINE_PASSWORD=<test.pypi token> required.
publish-test: dist-check
$(VENV_DIR)/bin/twine upload --repository testpypi dist/*
# Upload to PyPI — this is what CI runs on tag. Run locally only if you
# explicitly know you want to bypass CI.
publish: dist-check
$(VENV_DIR)/bin/twine upload dist/*