Giter Site home page Giter Site logo

python-semantic-release / python-semantic-release Goto Github PK

View Code? Open in Web Editor NEW
737.0 7.0 235.0 1.88 MB

Automatic semantic versioning for python projects

Home Page: http://python-semantic-release.readthedocs.org/

License: MIT License

Python 99.19% Shell 0.61% Jinja 0.08% Dockerfile 0.12%
python semantic-release release tool tooling

python-semantic-release's Introduction

Python Semantic Release

Ruff pypi conda-forge docs pre-commit

Automatic Semantic Versioning for Python projects. This is a Python implementation of semantic-release for JS by Stephan Bönnemann. If you find this topic interesting you should check out his talk from JSConf Budapest.

The general idea is to be able to detect what the next version of the project should be based on the commits. This tool will use that to automate the whole release, upload to an artifact repository and post changelogs to GitHub. You can run the tool on a CI service, or just run it locally.

Installation

python3 -m pip install python-semantic-release
semantic-release --help

Python Semantic Release is also available from conda-forge or as a GitHub Action. Read more about the setup and configuration in our getting started guide.

python-semantic-release's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-semantic-release's Issues

Changelog generation

Changelog generation requires more of the commit messages than just bumping version number.

It would be great to have support for custom commit message evaluation:

By defining import path of the evaluation function in setup.cfg:

[semantic_release]
commit_evaluator = semantic_release.history.commit_evaluator

The evaluators should take one argument, a string of a commit message, and return a tuple of (bumb_level_string, changelog_section, changelog_string).

The changelog should have 5 sections(please comment if something important is left out):

  • Breaking changes
  • Feature changes
  • Patch changes
  • Documentation changes
  • Other changes

The headers of these sections can be changelog_section.capitilize() (from the evaluator tuple) and thus be customizable.

Add a "getting started" guide.

I'm looking for something to help automate the release of various libraries I write, so something that would bump versions automatically, commit and push tags, generate changelog etc would be great, but I can't for the life of me figure out how to use this project. I've gleaned some information from the various documentation, but when I run semantic-release version it keeps telling me it won't make a new release.

A "getting started" guide with a few steps for how to try this tool out would be very nice.

Add publish command

  • Runs version unless the last commit is a version commit.
  • git push and git push --tags
  • Upload wheel to pypi

Upload api is deprecated

410 Client Error: Gone (This API has been deprecated and removed from legacy PyPI in favor of using the APIs available in the new PyPI.org implementation of PyPI (located at https://pypi.org/). 
For more information about migrating your use of this API to PyPI.org, please see https://packaging.python.org/guides/migrating-to-pypi-org/#uploading. 
For more information about the sunsetting of this API, please see https://mail.python.org/pipermail/distutils-sig/2017-June/030766.html) for url: https://pypi.python.org/pypi

Tagging fails if the .git directory is in a different location to setup.py and setup.cfg

I have a project in which the root directory contains src and src contains setup.py and setup.cfg.

When I run a semantic-release operation I get the following crash:


venv) C:\workspace\checklive\src>semantic-release --patch publish
Traceback (most recent call last):
  File "c:\python35\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\python35\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\workspace\checklive\venv\Scripts\semantic-release.exe\__main__.py", line 5, in <module>
  File "c:\workspace\checklive\venv\lib\site-packages\semantic_release\cli.py", line 9, in <module>
    from .history import (evaluate_version_bump, get_current_version, get_new_version,
  File "c:\workspace\checklive\venv\lib\site-packages\semantic_release\history\__init__.py", line 6, in <module>
    from ..vcs_helpers import get_commit_log, get_last_version
  File "c:\workspace\checklive\venv\lib\site-packages\semantic_release\vcs_helpers.py", line 8, in <module>
    repo = Repo('.git', search_parent_directories=True)
  File "c:\workspace\checklive\venv\lib\site-packages\git\repo\base.py", line 135, in __init__
    raise NoSuchPathError(epath)
git.exc.NoSuchPathError: C:\workspace\checklive\src\.git

(venv) C:\workspace\checklive\src>

Use custom parser

I wrote a custom parser as explained in the doc (http://python-semantic-release.readthedocs.io/en/latest/commit-log-parsing.html#writing-your-own-parser) but the lib can't load my function:

semantic_release.errors.ImproperConfigurationError: Unable to import parser "No module named 'semantic_release_config'"

Here's my setup

; setup.cfg
[semantic_release]
version_variable=semantic_release_config/__init__.py:__version__
commit_parser=semantic_release_config.parser
# files:
project_root/
  ├── setup.cfg
  └── semantic_release_config/
       ├── __init__.py
       └── parser.py
from .parser import commit_parser as parser
__version__ = '1.0.25'

What do I miss ?

Thanks !

[docs] add CI and auto release example

It would be great if there would be an example in the documentation on how to setup the release on a ci system like, travis-ci or others.


Edit by @relekang:

Lets add guides for these:

  • Travis CI
  • Circle CI
  • Semaphore CI
  • Snap CI

Add links to commits in generated changelog

The problem with current changelog is that it nicely lists changes, but if one sentence isn't enough for the reader to understand what exactly happened, they have to go and dig up the change somewhere from git history. That's pretty inconvenient.

What JS version of semantic releasing does is it adds link to the particular commit:

image

Add coverage check

Add a check that check coverage and aborts if it is below a certain level.

`semantic-release changelog` outputs nothing

There's no getting started guide that I've found. It doesn't tell you if you did anything wrong, just fails.

Due to some docs and trial and error I have this flow:

cat << EOF > setup.cfg
[semantic_release]
upload_to_pypi=False
version_variable=version.py:__version__
EOF

cat << EOF > version.py
__version__ = '0.0.1'
EOF

git init
git add .
git commit -m "feat(*): Does all the things"
curl https://www.gitignore.io/api/python > .gitignore
pip install python-semantic-release
semantic-release changelog

Commit with author info

Avoid this in on CI services:

- git config --global user.name "semantic-release (via TravisCI)"
- git config --global user.email "semantic-release@travis"

Fix doc build

The docs now only work if the make command is run from the base of a git repo because of Repo(".git").

--noop mode not working

I noticed this bug where the --noop mode is not working. This bug is present on any branch.

Steps to reproduce:

  1. Edit a file
  2. Add the file to git
  3. Commit(make sure that it bumps the version)
  4. Run semantic-release --noop version
  5. Check logs

In the logs it can be seen that the version was bumped as and a new commit as well a new tag is created.

Fallback to whole log if correct tag is not available

The log evaluation looks at v{current_version}... in some cases(e.g. on a unreleased project). This will not be available. It should fall back to the whole log if that happens and the message generator should stop when it hit a commit containing the current version like it worked before.

Start logging

There should be a lot more debug logging than there is now, in order to find out why something is not working.

Add environment specific check for owner and name

This happens at semaphore:

Traceback (most recent call last):
  File "/var/go/py-virtualenv2.7/bin/semantic-release", line 11, in <module>
    sys.exit(main())
  File "/var/go/py-virtualenv2.7/lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/var/go/py-virtualenv2.7/lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/var/go/py-virtualenv2.7/lib/python2.7/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/var/go/py-virtualenv2.7/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/var/go/py-virtualenv2.7/lib/python2.7/site-packages/semantic_release/cli.py", line 32, in main
    globals()[command](**kwargs)
  File "/var/go/py-virtualenv2.7/lib/python2.7/site-packages/semantic_release/cli.py", line 111, in publish
    owner, name = get_repository_owner_and_name()
  File "/var/go/py-virtualenv2.7/lib/python2.7/site-packages/semantic_release/vcs_helpers.py", line 31, in get_repository_owner_and_name
    return parts.group(1), parts.group(2)
AttributeError: 'NoneType' object has no attribute 'group'

Allow global config.

It would be nice if there were a global config file at ~/.config/semantic-release.cfg or similar that had the lowest priority of all the config files and where we could insert configuration lines.

My use case for this is mainly the GH_TOKEN, as storing it in my shell's config is harder to secure. A dedicated config file would be very handy.

Move project to jazzband?

The project seems rather inactive, so I'd like to suggest moving it to the Jazzband group, where people can collectively help maintain it. I'm in the group as well and would be willing to help out.

Running semantic-release when not in a git repository

When running semantic-release in a directory which is not a git repository you get the following error:

Traceback (most recent call last):
  File "/usr/bin/semantic-release", line 7, in <module>
    from semantic_release.cli import main
  File "/usr/lib/python2.7/site-packages/semantic_release/cli.py", line 9, in <module>
    from .history import (evaluate_version_bump, get_current_version, get_new_version,
  File "/usr/lib/python2.7/site-packages/semantic_release/history/__init__.py", line 6, in <module>
    from ..vcs_helpers import get_commit_log, get_last_version
  File "/usr/lib/python2.7/site-packages/semantic_release/vcs_helpers.py", line 8, in <module>
    repo = Repo('.git', search_parent_directories=True)
  File "/usr/lib/python2.7/site-packages/git/repo/base.py", line 135, in __init__
    raise NoSuchPathError(epath)
git.exc.NoSuchPathError: /home/blackhatmonkey/.git

This seems to be an un-caught exception. This also means that you cannot even run semantic-release --help when not in a repository.

Perhaps this error should be caught and a more user-friendly error printed on screen. Also I think parsing of the arguments should happen before any operations so you can get at least the help.

Add type hints

Would accept a patch to add type hints throughout the project? I think they add self documentation as well as help catch bugs.

Release 1.0

If you want to be notified of the 1.0 release, just subscribe to this issue by clicking the subscribe button in the sidebar.

This issue is locked to avoid unnecessary notifications, as it is only here to notify you all of the 1.0 release.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.