From dd50d15ff6ee64f9e5f15619d081365ded5adc1a Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Tue, 21 Jan 2025 23:04:00 +0100 Subject: [PATCH 1/3] Fix broken readme test badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7c21164..d7ecbb1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # [chartpress](https://github.com/jupyterhub/chartpress) [![Latest PyPI version](https://img.shields.io/pypi/v/chartpress?logo=pypi)](https://pypi.python.org/pypi/chartpress) -[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/jupyterhub/chartpress/Test?logo=github)](https://github.com/jupyterhub/chartpress/actions) +[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/jupyterhub/chartpress/test.yaml?logo=github)](https://github.com/jupyterhub/chartpress/actions) [![GitHub](https://img.shields.io/badge/issue_tracking-github-blue?logo=github)](https://github.com/jupyterhub/chartpress/issues) [![Discourse](https://img.shields.io/badge/help_forum-discourse-blue?logo=discourse)](https://discourse.jupyter.org/c/jupyterhub) [![Gitter](https://img.shields.io/badge/social_chat-gitter-blue?logo=gitter)](https://gitter.im/jupyterhub/jupyterhub) From 8ad71ce05fa83cced02afb714f07a2b518f9ccb7 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Tue, 21 Jan 2025 23:07:34 +0100 Subject: [PATCH 2/3] Transition to pyproject.toml --- .github/workflows/test.yaml | 5 +-- .pre-commit-config.yaml | 8 ---- README.md | 6 +-- dev-requirements.txt | 6 --- pyproject.toml | 88 +++++++++++++++++++++++++++++++++++++ setup.py | 60 ------------------------- 6 files changed, 92 insertions(+), 81 deletions(-) delete mode 100644 dev-requirements.txt create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3eaaf52..8990707 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -61,8 +61,7 @@ jobs: - name: Install Python dependencies run: | pip install --upgrade pip - pip install . - pip install -r dev-requirements.txt + pip install ".[test]" pip freeze - name: Install helm @@ -102,7 +101,7 @@ jobs: - name: Run tests run: | - pytest --verbose --color=yes --cov chartpress + pytest env: HELM2: ${{ matrix.helm2 }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4af44b4..4e4d496 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,20 +22,12 @@ repos: rev: 24.10.0 hooks: - id: black - args: - - --target-version=py37 - - --target-version=py38 - - --target-version=py39 - - --target-version=py310 - - --target-version=py311 # Autoformat: Python code - repo: https://github.com/pycqa/isort rev: 5.13.2 hooks: - id: isort - args: - - --profile=black # Autoformat: markdown, yaml - repo: https://github.com/pre-commit/mirrors-prettier diff --git a/README.md b/README.md index d7ecbb1..9e5cc8a 100644 --- a/README.md +++ b/README.md @@ -363,12 +363,10 @@ testing, see [tests/README.md](tests/README.md). ```bash # install chartpress locally -pip install -e . - -# install dev dependencies -pip install -r dev-requirements.txt +pip install -e ".[test]" # format and lint code +pip install pre-commit pre-commit run -a # run tests diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index aca07e7..0000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -bump2version -gitpython -pre-commit -pytest -pytest-cov -tbump diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4b48af8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,88 @@ +# build-system +# - ref: https://peps.python.org/pep-0517/ +# +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" + + +# project +# - ref 1: https://peps.python.org/pep-0621/ +# - ref 2: https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html +# +[project] +name = "chartpress" +version = "2.3.1.dev" +authors = [ + {name = "Jupyter Development Team", email = "jupyter@googlegroups.com"}, +] +description = "ChartPress: render and publish helm charts and images" +keywords = ["helm", "kubernetes"] +dynamic = ["readme"] +license = {file = "LICENSE"} +requires-python = ">=3.7" +classifiers = [ + "Intended Audience :: Developers", + "Intended Audience :: System Administrators", + "License :: OSI Approved :: BSD License", + "Operating System :: POSIX :: Linux", + "Operating System :: MacOS :: MacOS X", + "Programming Language :: Python", + "Programming Language :: Python :: 3", +] +dependencies = [ + "ruamel.yaml>=0.15.44", + # Bug in 5.0.0: https://github.com/docker/docker-py/pull/2844 + "docker>=3.2.0,!=5.0.0", +] + +[project.optional-dependencies] +test = [ + "gitpython", + "pytest", + "pytest-cov", + "tbump", +] + +[project.urls] +Documentation = "https://github.com/jupyterhub/chartpress#readme" +Source = "https://github.com/jupyterhub/chartpress" +Issues = "https://github.com/jupyterhub/chartpress/issues" + +[project.scripts] +chartpress = "chartpress:main" + + +# setuptools +# - ref: https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#setuptools-specific-configuration +# +[tool.setuptools] +py-modules = ["chartpress"] + +[tool.setuptools.dynamic] +readme = { file = "README.md", content-type = "text/markdown" } + + +# black is used for autoformatting Python code +# +# ref: https://black.readthedocs.io/en/stable/ +# +[tool.black] +skip-string-normalization = false + + +# isort is used for autoformatting Python code +# +# ref: https://pycqa.github.io/isort/ +# +[tool.isort] +profile = "black" + + +# pytest is used for running Python based tests +# +# ref: https://docs.pytest.org/en/stable/ +# +[tool.pytest.ini_options] +addopts = "--verbose --color=yes --durations=10 --cov=chartpress" +testpaths = ["tests"] diff --git a/setup.py b/setup.py deleted file mode 100644 index 00045f9..0000000 --- a/setup.py +++ /dev/null @@ -1,60 +0,0 @@ -import sys - -from setuptools import setup -from setuptools.command.bdist_egg import bdist_egg - - -class bdist_egg_disabled(bdist_egg): - """Disabled version of bdist_egg - - Prevents setup.py install from performing setuptools' default easy_install, - which it should never ever do. - """ - - def run(self): - sys.exit( - "Aborting implicit building of eggs." - "Use `pip install .` to install from source." - ) - - -cmdclass = { - "bdist_egg": bdist_egg if "bdist_egg" in sys.argv else bdist_egg_disabled, -} - -with open("README.md") as f: - readme = f.read() - -setup( - name="chartpress", - version="2.3.1.dev", - py_modules=["chartpress"], - cmdclass=cmdclass, - entry_points={ - "console_scripts": [ - "chartpress = chartpress:main", - ], - }, - description="ChartPress: render and publish helm charts and images", - long_description=readme, - long_description_content_type="text/markdown", - author="Jupyter Development Team", - author_email="jupyter@googlegroups.com", - url="https://github.com/jupyterhub/chartpress", - license="BSD", - platforms="Linux, Mac OS X", - keywords=["helm", "kubernetes"], - python_requires=">=3.7", - install_requires=[ - "ruamel.yaml>=0.15.44", - # Bug in 5.0.0: https://github.com/docker/docker-py/pull/2844 - "docker>=3.2.0,!=5.0.0", - ], - classifiers=[ - "Intended Audience :: Developers", - "Intended Audience :: System Administrators", - "License :: OSI Approved :: BSD License", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - ], -) From fd4cb3a504c18a1a01442e349232d8e56dc1de68 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Tue, 21 Jan 2025 23:09:03 +0100 Subject: [PATCH 3/3] Transition to tbump --- .bumpversion.cfg | 20 ----- .../workflows/{publish.yaml => release.yaml} | 28 +++---- RELEASE.md | 83 ++++++++----------- pyproject.toml | 29 +++++++ 4 files changed, 78 insertions(+), 82 deletions(-) delete mode 100644 .bumpversion.cfg rename .github/workflows/{publish.yaml => release.yaml} (69%) diff --git a/.bumpversion.cfg b/.bumpversion.cfg deleted file mode 100644 index d12889d..0000000 --- a/.bumpversion.cfg +++ /dev/null @@ -1,20 +0,0 @@ -[bumpversion] -current_version = 2.3.1.dev -parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.(?P[a-z0-9]+))? -tag_name = {new_version} -allow_dirty = True -commit = True -tag = False -serialize = - {major}.{minor}.{patch}.{release} - {major}.{minor}.{patch} - -[bumpversion:file:chartpress.py] - -[bumpversion:file:setup.py] - -[bumpversion:part:release] -optional_value = stable -values = - dev - stable diff --git a/.github/workflows/publish.yaml b/.github/workflows/release.yaml similarity index 69% rename from .github/workflows/publish.yaml rename to .github/workflows/release.yaml index 7e4a24f..794639b 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/release.yaml @@ -1,35 +1,33 @@ # This is a GitHub workflow defining a set of jobs with a set of steps. # ref: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions # -# Publish to PyPI on push of version like tags -# -name: Publish +name: Release +# Always tests wheel building, but only publish to PyPI on pushed tags. on: pull_request: paths-ignore: - - "**.md" - - ".github/workflows/*" - - "!.github/workflows/publish.yaml" + - ".github/workflows/*.yaml" + - "!.github/workflows/release.yaml" push: paths-ignore: - - "**.md" - - ".github/workflows/*" - - "!.github/workflows/publish.yaml" + - ".github/workflows/*.yaml" + - "!.github/workflows/release.yaml" branches-ignore: - "dependabot/**" - "pre-commit-ci-update-config" - tags: - - "**" + tags: ["**"] + workflow_dispatch: jobs: - publish-to-pypi: - runs-on: ubuntu-22.04 + build-release: + runs-on: ubuntu-24.04 + steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.10" + python-version: "3.13" - name: install build package run: | @@ -40,7 +38,7 @@ jobs: - name: build release run: | python -m build --sdist --wheel . - ls -alh dist + ls -l dist - name: publish to pypi uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/RELEASE.md b/RELEASE.md index 50d1644..95fe536 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,71 +1,60 @@ # How to make a release -`chartpress` is a package [available on -PyPI](https://pypi.org/project/chartpress/). These are instructions on how to -make a release on PyPI. The PyPI release is packaged and published automatically -by a GitHub workflow when a git tag is pushed. +`chartpress` is a package available on [PyPI] and [conda-forge]. -For you to follow along according to these instructions, you need: +These are the instructions on how to make a release. -- To have push rights to the [chartpress GitHub - repository](https://github.com/jupyterhub/chartpress). +## Pre-requisites + +- Push rights to this GitHub repository ## Steps to make a release -1. Update [CHANGELOG.md](CHANGELOG.md) if it is not up to date, and verify - [README.md](README.md) has an updated output of running `--help`. Make a PR - to review the CHANGELOG notes. +1. Create a PR updating `CHANGELOG.md` with [github-activity] and continue when + its merged. For details about this, see the [team-compass documentation] + about it. - To get the foundation of the changelog written, you can install - [github-activity](https://github.com/choldgraf/github-activity) and run - `github-activity jupyterhub/chartpress` after setting up - credentials as described in the project's README.md file. + [team-compass documentation]: https://jupyterhub-team-compass.readthedocs.io/en/latest/practices/releases.html -1. Once the changelog is up to date, checkout main and make sure it is up to date and clean. +2. Checkout main and make sure it is up to date. - ```bash - ORIGIN=${ORIGIN:-origin} # set to the canonical remote, e.g. 'upstream' if 'origin' is not the official repo + ```shell git checkout main - git fetch $ORIGIN main - git reset --hard $ORIGIN/main - # WARNING! This next command deletes any untracked files in the repo - git clean -xfd + git fetch origin main + git reset --hard origin/main ``` -1. Update the version with `bump2version` (can be installed with `pip install -r dev-requirements.txt`) +3. Update the version, make commits, and push a git tag with `tbump`. - ```bash - VERSION=... # e.g. 1.2.3 - bump2version --tag --new-version $VERSION - + ```shell + pip install tbump ``` -1. Reset the version to the next development version with `bump2version` + `tbump` will ask for confirmation before doing anything. - ```bash - bump2version --no-tag patch + ```shell + # Example versions to set: 1.0.0, 1.0.0b1 + VERSION= + tbump ${VERSION} ``` -1. Push your two commits to main along with the annotated tags referencing - commits on main. - - ``` - git push --follow-tags $ORIGIN main - ``` + Following this, the [CI system] will build and publish a release. -## Manually uploading to PyPI +4. Reset the version back to dev, e.g. `1.0.1.dev` after releasing `1.0.0`. -We are using CI with GitHub workflows to automatically publish to PyPI, but if -you want to do it manually when you are on a tagged commit in a otherwise -cleaned repository, you can do this. - -1. Package the release - - ```bash - python3 setup.py sdist bdist_wheel + ```shell + # Example version to set: 1.0.1.dev + NEXT_VERSION= + tbump --no-tag ${NEXT_VERSION}.dev ``` -1. Upload it to PyPI +5. Following the release to PyPI, an automated PR should arrive within 24 hours + to [conda-forge/chartpress-feedstock] with instructions + on releasing to conda-forge. You are welcome to volunteer doing this, but + aren't required as part of making this release to PyPI. - ```bash - twine upload dist/* - ``` +[github-activity]: https://github.com/executablebooks/github-activity +[pypi]: https://pypi.org/project/chartpress/ +[conda-forge]: https://anaconda.org/conda-forge/chartpress +[conda-forge/chartpress-feedstock]: https://github.com/conda-forge/chartpress-feedstock +[ci system]: https://github.com/jupyterhub/chartpress/actions/workflows/release.yaml diff --git a/pyproject.toml b/pyproject.toml index 4b48af8..d8ed799 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,3 +86,32 @@ profile = "black" [tool.pytest.ini_options] addopts = "--verbose --color=yes --durations=10 --cov=chartpress" testpaths = ["tests"] + + +# tbump is used to simplify and standardize the release process when updating +# the version, making a git commit and tag, and pushing changes. +# +# ref: https://github.com/your-tools/tbump#readme +# +[tool.tbump] +github_url = "https://github.com/jupyterhub/chartpress" + +[tool.tbump.version] +current = "2.3.1.dev" +regex = ''' + (?P\d+) + \. + (?P\d+) + \. + (?P\d+) + (?P
((a|b|rc)\d+)|)
+    \.?
+    (?P(?<=\.)dev\d*|)
+'''
+
+[tool.tbump.git]
+message_template = "Bump to {new_version}"
+tag_template = "{new_version}"
+
+[[tool.tbump.file]]
+src = "chartpress.py"