Skip to content

Commit

Permalink
Add detailed log when git commands fail in debug mode
Browse files Browse the repository at this point in the history
Set github actions to build on release tag
Update README.md and add more classifiers on pypi
  • Loading branch information
dormant-user committed Dec 17, 2022
1 parent 885627e commit 0ac3cc3
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 25 deletions.
25 changes: 9 additions & 16 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,32 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see:
# https://docs.github.com/en/actions/guides/building-and-testing-python#publishing-to-package-registries
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
# https://pypi.org/help/#apitoken

name: pypi-publish

# Controls when the workflow will run
on:
workflow_dispatch: {}
push:
branches: [ main ]
release:
types: [ published ]

jobs:
deploy:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]
python: [3.9]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
rm -rf build dist
python setup.py bdist_wheel --universal
python setup.py sdist
twine upload -r pypi --repository-url https://upload.pypi.org/legacy/ dist/* -u ${{ secrets.PYPI_USER }} -p ${{ secrets.PYPI_API_TOKEN }}
python setup.py sdist bdist_wheel
twine upload dist/*.whl
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Generate CHANGELOG from git commit history

### Pypi Module
[https://pypi.org/project/changelog-generator/](https://pypi.org/project/changelog-generator/)
[https://pypi.org/project/changelog-generator/][pypi]

### Usage
###### Navigate to the repository and run:
Expand All @@ -40,10 +40,13 @@ changelog reverse
```

###### Flags
- `-b` Gather commit notes specific to a branch. Defaults to `master`/`main`)
- `-b` Gather commit notes specific to a branch. Uses `Default branch` if not passed
- `-f` Write the commit notes to a custom filename. Defaults to `CHANGELOG`
- `-t` Title or index line for the file generated. Defaults to `Change Log`

#### Sample
[release_notes.rst][release_notes]

### Pre-Commit
Install `pre-commit` to run `flake8` and `isort` for linting and `sphinx` for documentation generator.

Expand All @@ -52,10 +55,15 @@ Install `pre-commit` to run `flake8` and `isort` for linting and `sphinx` for do
`pre-commit run --all-files`

### Runbook
[GitHub Docs](https://thevickypedia.github.io/changelog-generator/)
[GitHub Docs][runbook]

## License & copyright

© Vignesh Sivanandha Rao, Changelog Generator

Licensed under the [MIT License](https://github.com/thevickypedia/changelog-generator/blob/master/LICENSE)
Licensed under the [MIT License][license]

[release_notes]: https://github.com/thevickypedia/changelog-generator/blob/main/release_notes.rst
[runbook]: https://thevickypedia.github.io/changelog-generator/
[license]: https://github.com/thevickypedia/changelog-generator/blob/master/LICENSE
[pypi]: https://pypi.org/project/changelog-generator/
18 changes: 14 additions & 4 deletions changemaker/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ def get_branches() -> List:
branches = subprocess.check_output("git branch",
shell=True).decode(encoding='UTF-8').replace('* ', '').strip().splitlines()
return branches
except subprocess.SubprocessError as error:
debugger.error(error) if options['debug'] else None
except (subprocess.CalledProcessError, subprocess.SubprocessError, Exception) as error:
if options['debug']:
if isinstance(error, subprocess.CalledProcessError):
result = error.output.decode(encoding='UTF-8').strip()
debugger.error(f"[{error.returncode}]: {result}")
else:
debugger.error(error)


def get_gitlog(branch: str) -> List:
Expand All @@ -39,8 +44,13 @@ def get_gitlog(branch: str) -> List:
try:
return subprocess.check_output(f'git log --no-merges --reverse {branch}',
shell=True).decode(encoding='UTF-8').splitlines()
except subprocess.SubprocessError as error:
debugger.error(error) if options['debug'] else None
except (subprocess.CalledProcessError, subprocess.SubprocessError, Exception) as error:
if options['debug']:
if isinstance(error, subprocess.CalledProcessError):
result = error.output.decode(encoding='UTF-8').strip()
debugger.error(f"[{error.returncode}]: {result}")
else:
debugger.error(error)


def get_commits(trunk: str) -> int:
Expand Down
11 changes: 10 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@
'Operating System :: MacOS :: MacOS X',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.9',
'Topic :: Software Development :: Version Control :: Git'
'Topic :: Software Development :: Version Control :: Git',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows :: Windows 10',
'Operating System :: Microsoft :: Windows :: Windows 11',
'Topic :: Documentation :: Sphinx'
]


Expand Down

0 comments on commit 0ac3cc3

Please sign in to comment.