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 - name: Run version script
id: script id: script
run: | run: |
python extra/release.py "${{ inputs.version }}" python extra/release.py bump "${{ inputs.version }}"
- uses: EndBug/add-and-commit@v9 - uses: EndBug/add-and-commit@v9
name: Commit the changes name: Commit the changes
with: with:

View file

@ -2,15 +2,14 @@
"""A utility script for automating the beets release process. """A utility script for automating the beets release process.
""" """
import argparse
import datetime import datetime
import os import os
import re import re
import click
BASE = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
CHANGELOG = os.path.join(BASE, "docs", "changelog.rst") 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. # Locations (filenames and patterns) of the version number.
VERSION_LOCS = [ VERSION_LOCS = [
@ -155,12 +154,18 @@ def datestamp():
f.write(line) 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. # Version number bump.
datestamp() datestamp()
bump_version(args.version) bump_version(version)
if __name__ == "__main__": if __name__ == "__main__":
args = parser.parse_args() cli()
prep(args)