release.py: Use click for the CLI

This commit is contained in:
Šarūnas Nejus 2024-06-04 12:30:51 +01:00
parent c0ef37c46a
commit be778b8da0
No known key found for this signature in database
GPG key ID: DD28F6704DBE3435
2 changed files with 14 additions and 9 deletions

View file

@ -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

View file

@ -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()