mirror of
https://github.com/Findus23/new-github-changelog-generator.git
synced 2024-08-27 19:52:18 +02:00
better cli and README.md
This commit is contained in:
parent
1fda4f19ef
commit
6887f2d53b
4 changed files with 70 additions and 12 deletions
31
README.md
Normal file
31
README.md
Normal file
|
@ -0,0 +1,31 @@
|
|||
# github-changelog-generator
|
||||
|
||||
*quickly generate changelogs based on closed github issues and merged PRs since the last release*
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
pip3 install --user https://github.com/Findus23/new-github-changelog-generator/archive/master.zip
|
||||
```
|
||||
(at least until it is published on pypi)
|
||||
|
||||
## Usage
|
||||
|
||||
Run `github-changelog-generator init` to create an example config file.
|
||||
The GitHub API limits to 60 requests per hour by default, so to use this properly, create a [*personal access token*](https://github.com/settings/tokens) (you don't need to tick any box) and paste it into the `api_token` setting in the config file.
|
||||
|
||||
Afterwards you can simply create changelogs by specifying the tag or date of the previous release:
|
||||
|
||||
```bash
|
||||
github-changelog-generator generate --since "2019-01-25 00:00:00" --debian-changelog
|
||||
|
||||
github-changelog-generator generate --previous-version="3.8.0" --html
|
||||
```
|
||||
|
||||
You can find more options with `--help`:
|
||||
|
||||
```bash
|
||||
github-changelog-generator --help
|
||||
github-changelog-generator init --help
|
||||
github-changelog-generator generate --help
|
||||
```
|
|
@ -1,5 +1,11 @@
|
|||
import argparse
|
||||
from datetime import datetime, timedelta
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from os import path
|
||||
from os.path import expanduser
|
||||
from shutil import copyfile
|
||||
|
||||
import pkg_resources
|
||||
|
||||
from generator import generate_changelog
|
||||
|
||||
|
@ -12,20 +18,42 @@ def parsed_date(s):
|
|||
raise argparse.ArgumentTypeError(msg)
|
||||
|
||||
|
||||
def main():
|
||||
since = datetime.today() - timedelta(5)
|
||||
def initfile(globally: bool):
|
||||
home = expanduser("~")
|
||||
targetfile = home + "/.config/github-changelog-generator.yaml" if globally else "./github-changelog-generator.yaml"
|
||||
if path.exists(targetfile):
|
||||
sys.exit("The config file at '{path}' already exists.".format(path=targetfile))
|
||||
default_config_file = pkg_resources.resource_filename('generator', 'defaultconfig.yaml')
|
||||
copyfile(default_config_file, targetfile)
|
||||
print("An example config has been copied to '{path}'. \n".format(path=targetfile) +
|
||||
"Please edit it to your use case and don't forget to add a GitHub api_token to not run into rate limits.")
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Generate changelogs from closed GitHub issues and merged PRs.')
|
||||
sincegroup = parser.add_mutually_exclusive_group()
|
||||
subparsers = parser.add_subparsers(dest="command")
|
||||
|
||||
init = subparsers.add_parser("init")
|
||||
init.add_argument("--global", dest="globally", action='store_true', help="store config file in ~/.config/")
|
||||
init.set_defaults(globally=False)
|
||||
generate = subparsers.add_parser("generate")
|
||||
sincegroup = generate.add_mutually_exclusive_group()
|
||||
|
||||
sincegroup.add_argument('--since', metavar='"YYYY-MM-DD HH:MM:SS"', type=parsed_date,
|
||||
help='date of previous release')
|
||||
sincegroup.add_argument('--previous-version', type=str)
|
||||
group = parser.add_mutually_exclusive_group(required=True)
|
||||
group = generate.add_mutually_exclusive_group(required=True)
|
||||
group.add_argument('--html', action='store_const', const="html", dest="output", help="output as HTML")
|
||||
group.add_argument('--markdown', action='store_const', const="markdown", dest="output", help="output as markdown")
|
||||
group.add_argument('--debian-changelog', action='store_const', const="debianchangelog", dest="output",
|
||||
help="output as debian changelog file")
|
||||
|
||||
args = parser.parse_args()
|
||||
generate_changelog(args.since, args.output, args.previous_version)
|
||||
print(args)
|
||||
|
||||
if args.command == "init":
|
||||
initfile(args.globally)
|
||||
elif args.command == "generate":
|
||||
generate_changelog(args.since, args.output, args.previous_version)
|
||||
else:
|
||||
raise ValueError("invalid subcommand")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
api_token: null
|
||||
api_token: null # replace 'null' with a proper token from https://github.com/settings/tokens to avoid rate limiting issues.
|
||||
repositories:
|
||||
- matomo-org/matomo
|
||||
- matomo-org/tag-manager
|
||||
|
@ -39,4 +39,4 @@ sort_by_labels:
|
|||
- 'c: i18n'
|
||||
- RFC
|
||||
|
||||
is_matomo: True
|
||||
is_matomo: True # set to False if you don't want to generate changelogs for the Matomo project
|
7
setup.py
7
setup.py
|
@ -6,9 +6,8 @@ setup(
|
|||
name='github-changelog-generator',
|
||||
version='0.0.1',
|
||||
packages=setuptools.find_packages(),
|
||||
entry_points = {
|
||||
entry_points={
|
||||
'console_scripts': ['github-changelog-generator=generator.cli:main'],
|
||||
}
|
||||
# license='Creative Commons Attribution-Noncommercial-Share Alike license',
|
||||
# long_description=open('README.md').read(),
|
||||
},
|
||||
long_description=open('README.md').read()
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue