From be778b8da0107f350b0f9ca2bf7bdcc24c2398e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0ar=C5=ABnas=20Nejus?= Date: Tue, 4 Jun 2024 12:30:51 +0100 Subject: [PATCH] release.py: Use click for the CLI --- .github/workflows/make_release.yaml | 4 ++-- extra/release.py | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/make_release.yaml b/.github/workflows/make_release.yaml index 0fa54b301..6c7d13e17 100644 --- a/.github/workflows/make_release.yaml +++ b/.github/workflows/make_release.yaml @@ -21,7 +21,7 @@ jobs: - name: Run version script id: script run: | - python extra/release.py "${{ inputs.version }}" + python extra/release.py bump "${{ inputs.version }}" - uses: EndBug/add-and-commit@v9 name: Commit the changes with: @@ -91,4 +91,4 @@ jobs: - name: Publish distribution 📦 to PyPI uses: pypa/gh-action-pypi-publish@release/v1 - \ No newline at end of file + diff --git a/extra/release.py b/extra/release.py index 273bf96ea..3bd90f992 100755 --- a/extra/release.py +++ b/extra/release.py @@ -2,15 +2,14 @@ """A utility script for automating the beets release process. """ -import argparse import datetime import os import re +import click + BASE = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) CHANGELOG = os.path.join(BASE, "docs", "changelog.rst") -parser = argparse.ArgumentParser() -parser.add_argument("version", type=str) # Locations (filenames and patterns) of the version number. VERSION_LOCS = [ @@ -155,12 +154,18 @@ def datestamp(): f.write(line) -def prep(args: argparse.Namespace): +@click.group() +def cli(): + pass + + +@cli.command() +@click.argument("version") +def bump(version: str) -> None: # Version number bump. datestamp() - bump_version(args.version) + bump_version(version) if __name__ == "__main__": - args = parser.parse_args() - prep(args) + cli()