diff --git a/.circleci/config.yml b/.circleci/config.yml index ea563b6..1da5cf1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -91,7 +91,12 @@ jobs: at: /tmp/workspace - checkout - run: pip install --user tox - - run: /home/circleci/.local/bin/tox -- /tmp/workspace/dist/* + - run: | + export GITHUB_RELEASE_CICD_REPO=$(python setup.py --name) + export GITHUB_RELEASE_CICD_CREATE_TAG="v$(python setup.py --version)" + export GITHUB_RELEASE_CICD_CREATE_MESSAGE=$(git show --no-patch --pretty=format:"%s%n%b" ${CIRCLE_SHA1}) + export GITHUB_RELEASE_CICD_CREATE_TARGET=${CIRCLE_SHA1} + /home/circleci/.local/bin/tox -- '/tmp/workspace/dist/*' workflows: version: 2 diff --git a/release.py b/release.py deleted file mode 100644 index d37ea67..0000000 --- a/release.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python - -import glob -import os -import subprocess -import sys - -from github import Github - - -def run_command(command): - return subprocess.check_output( - command, - shell=True - ).strip().decode('utf-8') - - -def main(): - github = Github(os.environ['GITHUB_TOKEN']) - - repo = github.get_user().get_repo( - run_command('python setup.py --name'), - ) - - tag = 'v{}'.format(run_command('python setup.py --version')) - - release = repo.create_git_release( - tag=tag, - name=tag, - message=run_command( - 'git show --no-patch --pretty=format:"%s%n%b" {}'.format( - os.environ['CIRCLE_SHA1'], - ), - ), - target_commitish=os.environ['CIRCLE_SHA1'], - ) - - for item in glob.glob(sys.argv[1]): - release.upload_asset(item) - -if __name__ == '__main__': - if os.environ.get('CIRCLE_TAG'): - main() diff --git a/tox.ini b/tox.ini index c5f0be6..afad4ee 100644 --- a/tox.ini +++ b/tox.ini @@ -29,11 +29,10 @@ commands = python setup.py {posargs} sdist bdist_wheel [testenv:deploy] basepython = python3 -passenv = CIRCLE_* GITHUB_* TWINE_* -skip_install = true +passenv = GITHUB_* TWINE_* deps = - pygithub + github-release-cicd twine commands = twine upload --skip-existing {posargs:dist/*} - python release.py {posargs:dist/*} + github_release_cicd create --assets {posargs:dist/*}