Skip to content

Commit b871611

Browse files
docs: finish Package Maintenance section
1 parent 0156286 commit b871611

File tree

20 files changed

+140
-54
lines changed

20 files changed

+140
-54
lines changed

afterpython/doc/myst.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ project:
4141
- title: Package Maintenance
4242
children:
4343
- file: package_maintenance/package_management.md
44-
- file: package_maintenance/release_management.md
44+
- file: package_maintenance/commit_workflow.md
45+
- file: package_maintenance/package_releases.md
4546
- file: package_maintenance/ci_cd.md
4647
- title: References
4748
children:
48-
- file: references/cli_commands.md
4949
- file: references/environment_variables.md
5050
- file: references/roadmap.md
5151
- file: CONTRIBUTING.md
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[pre-commit]: https://pre-commit.com/
2+
[commitizen]: https://commitizen-tools.github.io/commitizen/
3+
[Conventional Commits]: https://www.conventionalcommits.org
4+
5+
6+
# Commit Workflow
7+
8+
## Pre-Commit Hooks
9+
Pre-commit hooks are scripts that automatically run before a commit is finalized, serving as a quality checkpoint for code changes. `afterpython` uses [pre-commit] to manage these hooks.
10+
11+
After running `ap init`, if you agreed to create a `.pre-commit-config.yaml` file, it will be located in the `afterpython/` folder with some default hooks. Since this configuration file is not at the project root, you need to run `ap pre-commit` (or `ap pc` for short) instead of the `pre-commit` command—it automatically uses the configuration in `afterpython/`.
12+
13+
### Commands
14+
- `ap pre-commit` (or `ap pc`) — equivalent to `pre-commit --config afterpython/.pre-commit-config.yaml`
15+
16+
17+
---
18+
## Commitizen
19+
If you agreed to create a `cz.toml` file during `ap init`, `afterpython` will use [commitizen] to help you write clear, structured commit messages following the [Conventional Commits] specification.
20+
21+
Since the `cz.toml` configuration file is located in `afterpython/` (not the project root), use `ap cz` instead of the standard `cz` command.
22+
23+
### Writing Commit Messages
24+
**Recommended:** Use `ap commit` to create commits. This command:
25+
1. Runs pre-commit hooks on changed files to catch issues early
26+
2. Guides you through an interactive prompt to write a properly formatted commit message
27+
3. Provides flags to skip checks when needed
28+
29+
**Alternative:** Use `git commit` directly if you're comfortable writing [Conventional Commits] format messages (e.g., `feat: add new feature`, `fix: resolve bug`). Your message must match the format enforced in `cz.toml` and pass pre-commit hook checks.
30+
31+
32+
**Bypassing checks:** To commit without running any checks:
33+
- `git commit --no-verify` — skip pre-commit hooks
34+
- `git push --no-verify` — skip pre-push hooks
35+
36+
### Commands
37+
- `ap cz` (or `ap commitizen`) — equivalent to `cz --config afterpython/cz.toml`
38+
- `ap commit` — wrapper around `cz commit` with additional features:
39+
- `ap commit --no-cz` — skip commitizen checks in pre-commit hooks
40+
- `ap commit --no-pc` — skip pre-commit checks before writing the commit message
41+
- `git commit --no-verify` — skip all pre-commit hooks
42+
- `git push --no-verify` — skip all pre-push hooks
43+
44+
45+
:::{tip} Commitizen Customization
46+
<!-- :class: dropdown -->
47+
Customize the commit message format by editing `cz.toml`.
48+
49+
See [Commitizen Customization](https://commitizen-tools.github.io/commitizen/customization/) for details.
50+
:::

afterpython/doc/package_maintenance/package_management.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[pdm]: https://github.com/pdm-project/pdm
44
[ruff]: https://github.com/astral-sh/ruff
55
[pixi]: https://github.com/prefix-dev/pixi
6+
[npm-check-updates]: https://www.npmjs.com/package/npm-check-updates
67

78
# Package Management
89

@@ -32,7 +33,7 @@ As a package maintainer, you face a dilemma: your dependencies (e.g. `pandas`) r
3233

3334
This is why minimum version updates are usually done manually—it's up to the package maintainer to decide when to require newer dependency versions.
3435

35-
`pcu` (similar to `ncu` in Node.js) helps automate this process:
36+
`pcu` (similar to `ncu` ([npm-check-updates]) in Node.js) helps automate this process:
3637
- `pcu` shows the latest available versions of your dependencies
3738
- `pcu -u` updates the minimum versions in your `pyproject.toml`
3839
- `pcu -u --all` also updates the versions in your `.pre-commit-config.yaml`
@@ -47,5 +48,12 @@ Only update minimum versions when you have a good reason—such as needing bug f
4748

4849

4950
---
50-
## pixi 🚧
51-
[pixi] manages both your package dependencies and your environment. For example, if your project installs `pyspark` and you need to lock Java to version 17, `pixi` handles that for you.
51+
## `pixi`
52+
[pixi] is a system-level package and environment manager that handles both Python and non-Python dependencies. For example, if your project uses `pyspark` and you need to lock Java to version 17, `pixi` can handle that for you.
53+
54+
`afterpython` itself uses `pixi` to create a reproducible development environment.
55+
For instance, `afterpython` uses `gh` (the GitHub CLI), which is a non-Python dependency. Using `pixi` ensures all contributors use the exact same version of `gh` and other system tools. If you're already using `pixi` for your project, `afterpython` provides a set of commands that keep both `uv` and `pixi` synchronized:
56+
- `ap add <lib>` — Adds a package to both `uv` and `pixi`. Supports `--optional` and `--group` flags.
57+
- `ap remove <lib>` — Removes a package from both `uv` and `pixi`. Supports `--optional` and `--group` flags.
58+
- `ap lock` — Runs both `uv lock` and `pixi lock`
59+
- `ap install` — Runs `uv sync --all-extras --all-groups` and `pixi install`
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
[commitizen]: https://commitizen-tools.github.io/commitizen/
2+
[SemVer]: https://semver.org
3+
[Python Versioning]: https://packaging.python.org/en/latest/discussions/versioning/
4+
[PyPI]: https://pypi.org/
5+
6+
7+
# Package Releases
8+
9+
## Version Bumping
10+
`ap bump` automatically increments your project version using [commitizen]'s `cz bump` under the hood.
11+
12+
### Commands
13+
- `ap bump` — automatically bump version based on conventional commits
14+
- `ap bump --pre` — bump to a pre-release version (e.g., `0.1.0.dev3``0.1.0.rc0`)
15+
- `ap bump --release` — bump to a release version (e.g., `0.1.0.rc0``0.1.0`)
16+
- **NOTE**: This command will **automatically trigger** the [release](./package_releases.md#releasing-your-package) workflow, you don't need to run `ap release` manually.
17+
18+
:::{seealso} Versioning
19+
:class: dropdown
20+
See [SemVer] and [Python Versioning] to learn more about versioning in Python packages.
21+
:::
22+
23+
---
24+
## PyPI and GitHub Releases
25+
If you agreed to create `cz.toml` during `ap init`, `afterpython` automatically creates a GitHub Actions workflow (`.github/workflows/release.yml`) that publishes your package to [PyPI] and creates GitHub releases.
26+
27+
### PyPI Setup
28+
To enable trusted publishing on PyPI:
29+
30+
1. Go to [PyPI] and navigate to your project
31+
2. Click **Manage****Publishing** (left sidebar)
32+
3. Under the **GitHub** tab, fill in:
33+
- **Owner:** Your GitHub username or organization name
34+
- **Repository:** Your repository name
35+
- **Workflow name:** `release.yml`
36+
37+
:::{note} Using an API Token
38+
:class: dropdown
39+
To use an API token instead (e.g., `UV_PUBLISH_TOKEN`), you'll need to modify the `release.yml` workflow file.
40+
:::
41+
42+
### Releasing Your Package
43+
`ap release` manually pushes the git tag created by `ap bump` to GitHub, which triggers the `release.yml` workflow. This command is unnecessary if you've already successfully run `ap bump --release`.
44+
45+
**Commands:**
46+
- `ap release` — release the current version to PyPI and GitHub
47+
- `ap release --force` — force release even for development versions
48+
49+
50+
---
51+
## Semantic Release 🚧
52+
53+
54+
---
55+
## Changlog 🚧

afterpython/doc/package_maintenance/release_management.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

afterpython/doc/references/cli_commands.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/afterpython/cli/commands/check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
)
1414
@click.pass_context
1515
def check(ctx):
16-
"""Simple wrapper for ruff check for convenience, always use the afterpython/ruff.toml if it exists"""
16+
"""Run ruff linter (uses afterpython/ruff.toml if available)"""
1717
from afterpython.utils import handle_passthrough_help
1818

1919
# Show both our options and ruff's help and exit

src/afterpython/cli/commands/clean.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
@click.option(
2727
"--all",
2828
is_flag=True,
29-
help='--all passed to "myst clean", also clean afterpython build directories (_build/ and _website/build/)',
29+
help="Also clean AfterPython build directories (_build/ and _website/build/)",
3030
)
3131
def clean(ctx, all: bool):
32-
"""Clean the build directory"""
32+
"""Clean build artifacts from content types and website"""
3333
from afterpython.utils import handle_passthrough_help
3434

3535
# Show both our options and myst's help and exit

src/afterpython/cli/commands/commit.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
)
1414
@click.pass_context
1515
@click.option(
16-
"--no-cz", "--no-commitizen", is_flag=True, help="Skip running 'cz commit'"
16+
"--no-cz",
17+
"--no-commitizen",
18+
is_flag=True,
19+
help="Skip 'commitizen' and 'commitizen-branch' pre-commit hooks",
1720
)
1821
@click.option(
1922
"--no-pc",
@@ -22,7 +25,7 @@
2225
help="Skip running pre-commit checks before commit",
2326
)
2427
def commit(ctx, no_cz: bool, no_pc: bool):
25-
"""Run 'cz commit'"""
28+
"""Create a conventional commit with interactive prompts"""
2629
from afterpython.utils import handle_passthrough_help
2730

2831
# Show both our options and commitizen's help and exit

src/afterpython/cli/commands/commitizen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
)
1414
@click.pass_context
1515
def commitizen(ctx):
16-
"""Run commitizen"""
16+
"""Run commitizen CLI (uses afterpython/cz.toml)"""
1717
from afterpython.utils import handle_passthrough_help
1818

1919
# Show both our options and commitizen's help and exit

0 commit comments

Comments
 (0)