Skip to content

Commit 36ec9a6

Browse files
committed
build: copier-auto-update
1 parent 9640fbe commit 36ec9a6

File tree

6 files changed

+99
-63
lines changed

6 files changed

+99
-63
lines changed

.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Answer file maintained by Copier for: https://github.com/KyleKing/mdformat-plugin-template
33
# DO NOT MODIFY THIS FILE. Edit by re-running copier and changing responses to the questions
44
# Check into version control.
5-
_commit: 2.1.2
5+
_commit: 2.2.0
66
_src_path: gh:KyleKing/mdformat-plugin-template
77
author_email: [email protected]
88
author_name: Kyle King

.github/workflows/tests.yml

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -26,67 +26,53 @@ jobs:
2626
os: [ubuntu-latest, windows-latest]
2727
steps:
2828
- uses: actions/checkout@v5
29-
- name: Set up Python ${{ matrix.python-version }}
30-
uses: actions/setup-python@v6
29+
- name: Install uv and Python
30+
uses: astral-sh/setup-uv@v7
3131
with:
3232
python-version: ${{ matrix.python-version }}
33-
- name: Installation (deps and package)
34-
# We install with flit --pth-file, so that coverage will be recorded for the module
35-
# Flit could be installed with pipx and use '--python=$(which python)', but
36-
# there were issues with the Windows Runner
37-
run: |
38-
pip install flit~=3.10.1
39-
flit install --deps=production --extras=test --pth-file
33+
- name: Install Package
34+
run: uv pip install --system ".[test]"
4035
- name: Run pytest
41-
run: |
42-
pytest --cov
43-
# # Not currently configured
44-
# - name: Report coverage
45-
# if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
46-
# uses: codecov/codecov-action@v4
47-
# with:
48-
# token: ${{ secrets.CODECOV_TOKEN }}
36+
run: pytest --cov
4937

5038
prek-hook:
5139
runs-on: ubuntu-latest
5240
steps:
5341
- uses: actions/checkout@v5
54-
- name: Set up Python
55-
uses: actions/setup-python@v6
42+
- name: Install uv and Python
43+
uses: astral-sh/setup-uv@v7
5644
with:
5745
python-version: 3.12
58-
- name: Installation (deps and package)
59-
run: |
60-
pip install flit~=3.10.1
61-
flit install --deps=production --pth-file
6246
- name: Install prek
6347
uses: j178/prek-action@v1
6448
with:
6549
install-only: true
50+
- name: Install Package
51+
run: uv pip install --system ".[test]"
6652
- name: run prek with plugin
67-
run: |
68-
prek run --config .prek-test.yaml --all-files --verbose --show-diff-on-failure
53+
run: prek run --config .pre-commit-test.yaml --all-files --verbose --show-diff-on-failure
6954

7055
publish:
7156
name: Publish to PyPi
7257
needs: [prek, tests, prek-hook]
7358
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
7459
runs-on: ubuntu-latest
75-
# Fix 403 error (https://github.com/softprops/action-gh-release/issues/400)
60+
environment:
61+
name: pypi
62+
url: https://pypi.org/p/mdformat-mkdocs
7663
permissions:
77-
contents: write
64+
contents: write # For GitHub release creation
65+
id-token: write # IMPORTANT: mandatory for PyPI trusted publishing
7866
steps:
79-
- name: Checkout source
80-
uses: actions/checkout@v5
81-
- name: install flit
82-
run: |
83-
pipx install flit~=3.10.1
84-
- name: Build and publish
85-
run: |
86-
flit publish
87-
env:
88-
FLIT_USERNAME: __token__
89-
FLIT_PASSWORD: ${{ secrets.PYPI_KEY }}
67+
- uses: actions/checkout@v5
68+
- name: Install uv and Python
69+
uses: astral-sh/setup-uv@v7
70+
with:
71+
python-version: 3.12
72+
- name: Build Package
73+
run: uv build
74+
- name: Publish to PyPI
75+
uses: pypa/gh-action-pypi-publish@release/v1
9076
- name: Generate GitHub Release Notes
9177
uses: softprops/action-gh-release@v2
9278
with:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ repos:
4141
- id: yamllint
4242
stages: ["pre-commit"]
4343
- repo: https://github.com/python-jsonschema/check-jsonschema
44-
rev: 0.30.0
44+
rev: 0.35.0
4545
hooks:
4646
- id: check-github-workflows
4747
args: ["--verbose"]

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Configuration can be passed via:
112112

113113
## Development Notes
114114

115-
- This project uses `flit` as the build backend
115+
- This project uses `uv-build` as the build backend
116116
- Uses `tox` for test automation with multiple Python versions (3.10, 3.12)
117117
- Pre-commit is configured but the project now uses `prek` (faster alternative)
118118
- Python 3.10+ is required (see `requires-python` in `pyproject.toml`)

CONTRIBUTING.md

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A collection of useful resources to reference when developing new features:
99

1010
## Local Development
1111

12-
This package utilizes [flit](https://flit.readthedocs.io) as the build engine, and [tox](https://tox.readthedocs.io) for test automation.
12+
This package utilizes [uv](https://docs.astral.sh/uv) as the build engine, and [tox](https://tox.readthedocs.io) for test automation.
1313

1414
To install these development dependencies:
1515

@@ -35,7 +35,7 @@ The easiest way to write tests, is to edit `tests/fixtures.md`
3535
To run the code formatting and style checks:
3636

3737
```bash
38-
tox -e py312-pre-commit
38+
tox -e py312-prek
3939
```
4040

4141
or directly with [prek](https://github.com/j178/prek) (or pre-commit)
@@ -79,21 +79,59 @@ Or with pipx:
7979
pipx install . --include-deps --force --editable
8080
```
8181

82-
## Publish to PyPi
82+
## Publish to PyPI
8383

84-
First, update the version in `mdformat_mkdocs/__init__.py`
84+
This project uses [PyPI Trusted Publishers](https://docs.pypi.org/trusted-publishers) for secure, token-free publishing from GitHub Actions, with [uv](https://docs.astral.sh/uv) for building packages.
8585

86-
Then, either use the Github Action by committing the new version in `__init__.py` and pushing an associated tag in format: `v#.#.#` (e.g. `v1.3.2` for `__version__ = '1.3.2'`)
86+
### Initial Setup (One-time)
8787

88-
Or run flit locally:
88+
Before publishing for the first time, you need to configure Trusted Publishing on PyPI:
8989

90-
```bash
91-
# envchain --set FLIT FLIT_PASSWORD
92-
export FLIT_USERNAME=__token__
93-
export eval $(envchain FLIT env | grep FLIT_PASSWORD=)
90+
1. Go to your project's page on PyPI: `https://pypi.org/manage/project/mdformat_mkdocs/settings/publishing/`
91+
- If the project doesn't exist yet, go to [PyPI's publishing page](https://pypi.org/manage/account/publishing) to add a "pending" publisher
92+
1. Add a new Trusted Publisher with these settings:
93+
- **PyPI Project Name**: `mdformat_mkdocs`
94+
- **Owner**: `kyleking`
95+
- **Repository name**: `mdformat-mkdocs`
96+
- **Workflow name**: `tests.yml` (`.github/workflows/tests.yml`)
97+
- **Environment name**: `pypi`
98+
1. Configure the GitHub Environment:
99+
- Go to your repository's `Settings``Environments`
100+
- Create an environment named `pypi`
101+
- (Recommended) Enable "Required reviewers" for production safety
102+
103+
### Publishing a Release
104+
105+
#### Option 1: Using commitizen (Recommended)
106+
107+
Use commitizen to automatically bump versions and create a commit with tag:
108+
109+
```sh
110+
# Dry run to preview the version bump
111+
tox -e py312-cz -- --dry-run
112+
113+
# Automatically bump version based on conventional commits
114+
tox -e py312-cz
94115

95-
flit publish
116+
# Or manually specify the increment type
117+
tox -e py312-cz -- --increment PATCH # or MINOR or MAJOR
118+
119+
# Push the commit and tag
120+
git push origin main --tags
121+
```
122+
123+
Commitizen will automatically update versions in `pyproject.toml` and `mdformat_mkdocs/__init__.py`.
124+
125+
#### Option 2: Manual Version Bump
126+
127+
Update the versions in both `pyproject.toml` under `[project].version` and `mdformat_mkdocs/__init__.py` for `__version__`. Commit the change and push a tag in the form `vX.Y.Z` (for example, `v1.3.2` when the project version is `1.3.2`):
128+
129+
```sh
130+
TAG=1.3.2
131+
git add pyproject.toml mdformat_mkdocs/__init__.py
132+
git commit -m "release: v$TAG"
133+
git tag v$TAG
134+
git push origin main --tags
96135
```
97136

98-
> [!NOTE]
99-
> The Github Action requires generating an API key on PyPi and adding it to the repository `Settings/Secrets`, under the name `PYPI_KEY`
137+
The GitHub Action will automatically build and publish to PyPI using Trusted Publishers (no API tokens needed!).

pyproject.toml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
2-
build-backend = "flit_core.buildapi"
3-
requires = ["flit_core >=3.9.0,<4"]
2+
build-backend = "uv_build"
3+
requires = ["uv_build>=0.9.10"]
44

55
[project]
66
authors = [
@@ -18,11 +18,13 @@ dependencies = [
1818
"mdit-py-plugins >= 0.4.1",
1919
"more-itertools >= 10.5.0",
2020
]
21-
dynamic = ["description", "version"]
2221
keywords = ["markdown", "markdown-it", "mdformat", "mdformat_plugin_template"]
22+
license = "MIT"
23+
license-files = ["LICENSE"]
2324
name = "mdformat_mkdocs"
2425
readme = "README.md"
2526
requires-python = ">=3.10.0"
27+
version = "4.5.0"
2628

2729
[project.entry-points."mdformat.parser_extension"]
2830
mkdocs = "mdformat_mkdocs"
@@ -45,9 +47,9 @@ recommended = [
4547
]
4648
test = [
4749
"beartype >= 0.21.0",
48-
"pytest >= 8.3.4",
50+
"pytest >= 9.0.1",
4951
"pytest-beartype >= 0.2.0",
50-
"pytest-cov >= 6.2.1",
52+
"pytest-cov >= 7.0.0",
5153
"syrupy >= 4.9.1",
5254
]
5355

@@ -56,9 +58,10 @@ test = [
5658
"Changelog" = "https://github.com/kyleking/mdformat-mkdocs/releases"
5759
homepage = "https://github.com/kyleking/mdformat-mkdocs"
5860

59-
[tool.flit.sdist]
60-
exclude = [".github/", "tests/"]
61-
include = []
61+
[tool.commitizen]
62+
tag_format = "v${version}"
63+
version = "4.5.0"
64+
version_files = ["mdformat_mkdocs/__init__.py", "pyproject.toml:^version"]
6265

6366
[tool.mypy]
6467
check_untyped_defs = true
@@ -166,7 +169,7 @@ inline_arrays = false
166169
[tool.tox]
167170
# Docs: https://tox.wiki/en/4.23.2/config.html#core
168171
basepython = ["python3.10", "python3.12"]
169-
env_list = ["py310-hook", "py310-test", "py312-prek", "py312-ruff", "py312-test", "py312-type"]
172+
env_list = ["py310-hook", "py310-test", "py312-cz", "py312-prek", "py312-ruff", "py312-test", "py312-type"]
170173
isolated_build = true
171174
requires = ["tox>=4.32.0"]
172175
skip_missing_interpreters = false
@@ -179,6 +182,12 @@ deps = "prek>=0.2.17"
179182
commands = [["pytest", "--cov=mdformat_mkdocs"]]
180183
extras = ["test"]
181184

185+
[tool.tox.env."py312-cz"]
186+
commands = [["cz", "bump", {default = [], extend = true, replace = "posargs"}]]
187+
deps = "commitizen>=4.10.0"
188+
description = "Bump version using commitizen. Optionally specify: '-- --increment MAJOR|MINOR|PATCH' or '-- --dry-run'"
189+
skip_install = true
190+
182191
[tool.tox.env."py312-prek"]
183192
commands = [["prek", "run", "--all-files", {default = [], extend = true, replace = "posargs"}]]
184193
deps = "prek>=0.2.17"
@@ -207,3 +216,6 @@ deps = ["mypy>=1.18.2"]
207216
[tool.tox.env_run_base]
208217
# Validates that commands are set
209218
commands = [["error-commands-are-not-set"]]
219+
220+
[tool.uv.build-backend]
221+
module-root = ""

0 commit comments

Comments
 (0)