├── .github
└── workflows
│ └── mirror.yml
├── .pre-commit-hooks.yaml
├── README.rst
├── mirror.py
└── pyproject.toml
/.github/workflows/mirror.yml:
--------------------------------------------------------------------------------
1 | name: Mirror
2 |
3 | on:
4 | schedule:
5 | - cron: '43 5 * * *'
6 | repository_dispatch:
7 | types: [pypi_release]
8 | workflow_dispatch:
9 |
10 | jobs:
11 | build:
12 | name: Mirror
13 | runs-on: ubuntu-24.04
14 | steps:
15 | - uses: actions/checkout@v4
16 |
17 | - name: Install uv
18 | uses: astral-sh/setup-uv@v5
19 | with:
20 | enable-cache: true
21 |
22 | - name: Configure Git
23 | run: |
24 | git config --global user.name 'Github Actions'
25 | git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
26 |
27 | - run: uv run mirror.py
28 |
29 | - run: |
30 | git remote set-url origin https://x-access-token:$GH_TOKEN@github.com/$GITHUB_REPOSITORY
31 | git push origin HEAD:refs/heads/main --tags
32 | env:
33 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 |
--------------------------------------------------------------------------------
/.pre-commit-hooks.yaml:
--------------------------------------------------------------------------------
1 | - id: djade
2 | name: Djade
3 | description: "Djade: a Django template formatter"
4 | entry: djade
5 | language: python
6 | minimum_pre_commit_version: 2.9.2
7 | files: '(^|/)templates/'
8 | types_or: [text]
9 | exclude_types: [python]
10 |
--------------------------------------------------------------------------------
/README.rst:
--------------------------------------------------------------------------------
1 | djade-pre-commit
2 | ================
3 |
4 | A `pre-commit `__ hook for `Djade `__.
5 | Distributed as a standalone repository to enable installing Djade via prebuilt wheels from PyPI.
6 |
7 | For installation instructions, see `the main repository `__.
8 |
--------------------------------------------------------------------------------
/mirror.py:
--------------------------------------------------------------------------------
1 | # /// script
2 | # requires-python = ">=3.12"
3 | # dependencies = [
4 | # "packaging",
5 | # "tomli",
6 | # "tomli-w",
7 | # "urllib3",
8 | # ]
9 | # ///
10 | import subprocess
11 | from pathlib import Path
12 |
13 | import tomli
14 | import tomli_w
15 | import urllib3
16 | from packaging.requirements import Requirement
17 | from packaging.version import Version
18 |
19 |
20 | def main():
21 | with open(Path(__file__).parent / "pyproject.toml", "rb") as f:
22 | pyproject = tomli.load(f)
23 |
24 | # get current version of black
25 | deps = pyproject["project"]["dependencies"]
26 | assert len(deps) == 1
27 | djade_dep = Requirement(deps[0])
28 | assert djade_dep.name == "djade"
29 | djade_specs = list(djade_dep.specifier)
30 | assert len(djade_specs) == 1
31 | assert djade_specs[0].operator == "=="
32 | current_version = Version(djade_specs[0].version)
33 |
34 | # get all versions of djade from PyPI
35 | resp = urllib3.request("GET", "https://pypi.org/pypi/djade/json")
36 | if resp.status != 200:
37 | raise RuntimeError
38 |
39 | versions = [Version(release) for release in resp.json()["releases"]]
40 | versions = [v for v in versions if v > current_version and not v.is_prerelease]
41 | versions.sort()
42 |
43 | for version in versions:
44 | pyproject["project"]["dependencies"] = [f"djade=={version}"]
45 | with open(Path(__file__).parent / "pyproject.toml", "wb") as f:
46 | tomli_w.dump(pyproject, f)
47 | subprocess.run(["git", "add", "pyproject.toml"])
48 | subprocess.run(["git", "commit", "-m", f"Djade {version}"])
49 | subprocess.run(
50 | [
51 | "git",
52 | "tag",
53 | "--annotate",
54 | f"{version}",
55 | "--message",
56 | f"Version {version}",
57 | ]
58 | )
59 |
60 |
61 | if __name__ == "__main__":
62 | main()
63 |
--------------------------------------------------------------------------------
/pyproject.toml:
--------------------------------------------------------------------------------
1 | [project]
2 | name = "djade-pre-commit"
3 | version = "0.0.0"
4 | dependencies = [
5 | "djade==1.4.0",
6 | ]
7 |
--------------------------------------------------------------------------------