Merge pull request #5740 from nicoddemus/use-repo-env-var

Use TRAVIS_REPO_SLUG instead of hard-coding pytest-dev/pytest
This commit is contained in:
Bruno Oliveira 2019-08-14 21:46:57 -03:00 committed by GitHub
commit 0822a1e53a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 4 deletions

View File

@ -25,9 +25,10 @@ import github3
import pypandoc import pypandoc
def publish_github_release(token, tag_name, body): def publish_github_release(slug, token, tag_name, body):
github = github3.login(token=token) github = github3.login(token=token)
repo = github.repository("pytest-dev", "pytest") owner, repo = slug.split("/")
repo = github.repository(owner, repo)
return repo.create_release(tag_name=tag_name, body=body) return repo.create_release(tag_name=tag_name, body=body)
@ -71,14 +72,22 @@ def main(argv):
print("GH_RELEASE_NOTES_TOKEN not set", file=sys.stderr) print("GH_RELEASE_NOTES_TOKEN not set", file=sys.stderr)
return 1 return 1
slug = os.environ.get("TRAVIS_REPO_SLUG")
if not slug:
print("TRAVIS_REPO_SLUG not set", file=sys.stderr)
return 1
rst_body = parse_changelog(tag_name) rst_body = parse_changelog(tag_name)
md_body = convert_rst_to_md(rst_body) md_body = convert_rst_to_md(rst_body)
if not publish_github_release(token, tag_name, md_body): if not publish_github_release(slug, token, tag_name, md_body):
print("Could not publish release notes:", file=sys.stderr) print("Could not publish release notes:", file=sys.stderr)
print(md_body, file=sys.stderr) print(md_body, file=sys.stderr)
return 5 return 5
print(f"Release notes for {tag_name} published successfully") print()
print(f"Release notes for {tag_name} published successfully:")
print(f"https://github.com/{slug}/releases/tag/{tag_name}")
print()
return 0 return 0