Releasing¶
Releases are published to PyPI from GitLab CI by trusted publishing: no password or token is stored anywhere.
One-time setup¶
On pypi.org, Your account → Publishing → Add a new pending publisher → GitLab (after the first release: the project's Settings → Publishing):
| Field | Value |
|---|---|
| PyPI project name | rainbow-fmt |
| Namespace | thebjorn |
| Project name | rainbow-fmt |
| Top-level pipeline file path | .gitlab-ci.yml |
| Environment name | pypi |
Making a release¶
The version lives in three files that must agree: pyproject.toml,
src/rainbow_fmt/__init__.py and dkbuild.yml (package.version, which
also lists __init__.py under package.versioned so that
dktools finds it in the src
layout). Between releases they hold the last released version; there is
no .dev suffix.
- Rename the
Unreleasedsection ofCHANGELOG.mdto the new version and date; merge tomainand wait for a green pipeline. - On
main, rundk upversion -tfor a patch release,dk upversion -i -tfor a minor one ordk upversion -m -tfor a major one (dk upversion -s 1.2.3 -tsets an exact version). It bumps the three files, commits them (tagged-upversion), tagsv+ version and pushes the commit and the tag. Without-tit only edits the files. - The tag's pipeline runs lint, tests, benchmark and build; then the
publishjob checks that the wheel israinbow_fmt-<version>-…, runstwine check, exchanges the job's OIDC token for a short-lived PyPI token (ci/mint_pypi_token.py) and uploads the sdist and the wheel.
PyPI never accepts the same version twice: a broken release is fixed with a
new version (and the old one can be yanked on PyPI). A tag whose
version does not match the wheel (the files were not bumped) fails at the
first line of the publish job and publishes nothing.
The editable install's metadata is read at install time: after a bump,
python -m pip install -e '.[dev]' again, or tests/test_package.py
(which compares the two) fails.
The documentation site¶
rainbow-fmt.dev is docs/ built by
MkDocs with the Material theme (mkdocs.yml;
mkdocs-material is a dev dependency) and hosted on
Cloudflare Pages. mkdocs
serve previews it locally. The docs job builds it with --strict on
every pipeline, so a link or anchor that goes nowhere fails the pipeline
(tests/test_docs_site.py does the same locally); the deploy-docs job
uploads the result with wrangler pages deploy on every push to main
that passed lint, tests, benchmark and build. Links from the docs to files
outside docs/ (STYLEGUIDE.md, LICENSE, the VS Code extension) are
GitLab URLs, since the site serves only docs/.
One-time setup¶
- Create the Pages project, named
rainbow-fmt. From a checkout aftermkdocs build --strict:npx wrangler login, thennpx wrangler pages deploy site --project-name rainbow-fmt --branch main, which creates the project on its first run. Or in the Cloudflare dashboard, Workers & Pages → Create application → Get started → Drag and drop your files, and drop thesite/folder. A direct-upload project cannot be switched to Git integration later; it does not need to be, since CI uploads. - In the project, Custom domains → Set up a custom domain →
rainbow-fmt.dev. The zone is in the same account, so Cloudflare adds the CNAME record and the certificate itself. Addwww.rainbow-fmt.devthe same way if wanted. - My Profile → API Tokens → Create Token, a custom token with the permission Account → Cloudflare Pages → Edit. The account ID is on the Workers & Pages overview page.
- GitLab, Settings → CI/CD → Variables:
CLOUDFLARE_API_TOKEN(masked, protected) andCLOUDFLARE_ACCOUNT_ID.