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.
This commit is contained in:
parent
c870bdb2ac
commit
001a471549
4 changed files with 171 additions and 18 deletions
36
Makefile
36
Makefile
|
|
@ -5,7 +5,7 @@ PYTEST = $(VENV_DIR)/bin/pytest
|
|||
RUFF = $(VENV_DIR)/bin/ruff
|
||||
|
||||
.DEFAULT_GOAL := all
|
||||
.PHONY: all bootstrap venv install test lint format clean help
|
||||
.PHONY: all bootstrap venv install test lint format clean help build dist-check publish-test publish
|
||||
|
||||
all: bootstrap test lint
|
||||
|
||||
|
|
@ -16,6 +16,16 @@ help:
|
|||
@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)
|
||||
|
|
@ -40,3 +50,27 @@ clean:
|
|||
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/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue