@power_session(python=[PY37])
def release(session: PowerSession):
    'Create a release on github corresponding to the latest tag'
    from setuptools_scm import get_version
    from setuptools_scm.version import guess_next_dev_version
    version = []

    def my_scheme(version_):
        version.append(version_)
        return guess_next_dev_version(version_)
    current_tag = get_version('.', version_scheme=my_scheme)
    session.install_reqs(phase='setup.py#dist', phase_reqs=['setuptools_scm'])
    rm_folder(Folders.dist)
    session.run2('python setup.py sdist bdist_wheel')
    if (version[0].dirty or (not version[0].exact)):
        raise ValueError('You need to execute this action on a clean tag version with no local changes.')
    if (len(session.posargs) == 1):
        gh_token = session.posargs[0]
        publish_on_pypi = False
    elif (len(session.posargs) == 0):
        publish_on_pypi = True
        import keyring
        gh_token = keyring.get_password('https://docs.github.com/en/rest', 'token')
        assert (len(gh_token) > 0)
    else:
        raise ValueError('Only a single positional arg is allowed for now')
    if publish_on_pypi:
        session.install_reqs(phase='PyPi', phase_reqs=['twine'])
        session.run2('twine upload dist/* -u smarie')
    session.install_reqs(phase='release', phase_reqs=['click', 'PyGithub'])
    session.run2('python ci_tools/github_release.py -s {gh_token} --repo-slug {gh_org}/{gh_repo} -cf ./docs/changelog.md -d https://{gh_org}.github.io/{gh_repo}/changelog.html {tag}'.format(gh_token=gh_token, gh_org=gh_org, gh_repo=gh_repo, tag=current_tag))
Create a release on github corresponding to the latest tag
@power_session(python=[PY37])
def release(session: PowerSession):
    
    from setuptools_scm import get_version
    from setuptools_scm.version import guess_next_dev_version
    version = []

    def my_scheme(version_):
        version.append(version_)
        return guess_next_dev_version(version_)
    current_tag = get_version('.', version_scheme=my_scheme)
    session.install_reqs(phase='setup.py#dist', phase_reqs=['setuptools_scm'])
    rm_folder(Folders.dist)
    session.run2('python setup.py sdist bdist_wheel')
    if (version[0].dirty or (not version[0].exact)):
        raise ValueError('You need to execute this action on a clean tag version with no local changes.')
    if (len(session.posargs) == 1):
        gh_token = session.posargs[0]
        publish_on_pypi = False
    elif (len(session.posargs) == 0):
        publish_on_pypi = True
        import keyring
        gh_token = keyring.get_password('https://docs.github.com/en/rest', 'token')
        assert (len(gh_token) > 0)
    else:
        raise ValueError('Only a single positional arg is allowed for now')
    if publish_on_pypi:
        session.install_reqs(phase='PyPi', phase_reqs=['twine'])
        session.run2('twine upload dist/* -u smarie')
    session.install_reqs(phase='release', phase_reqs=['click', 'PyGithub'])
    session.run2('python ci_tools/github_release.py -s {gh_token} --repo-slug {gh_org}/{gh_repo} -cf ./docs/changelog.md -d https://{gh_org}.github.io/{gh_repo}/changelog.html {tag}'.format(gh_token=gh_token, gh_org=gh_org, gh_repo=gh_repo, tag=current_tag))