Skip to content

Commit cb94fd3

Browse files
committed
Use TRAVIS_REPO_SLUG instead of hard-coding pytest-dev/pytest
I was doing final tests on the script today, and forgot to change the hardecoded "pytest-dev/pytest", which ended up publishing a `4.99.10` release to the main repository by mistake, as my token has access to both my fork and main repository. I deleted the tag immeditely just a few seconds later, so hopefully this won't cause major problems. This change makes it safer to test this in the future, never publishing to the main repository by mistake (as long as the tags are pushed to the right repositories of course).
1 parent fa75d81 commit cb94fd3

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

scripts/publish_gh_release_notes.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
import pypandoc
2626

2727

28-
def publish_github_release(token, tag_name, body):
28+
def publish_github_release(slug, token, tag_name, body):
2929
github = github3.login(token=token)
30-
repo = github.repository("pytest-dev", "pytest")
30+
owner, repo = slug.split("/")
31+
repo = github.repository(owner, repo)
3132
return repo.create_release(tag_name=tag_name, body=body)
3233

3334

@@ -71,14 +72,22 @@ def main(argv):
7172
print("GH_RELEASE_NOTES_TOKEN not set", file=sys.stderr)
7273
return 1
7374

75+
slug = os.environ.get("TRAVIS_REPO_SLUG")
76+
if not slug:
77+
print("TRAVIS_REPO_SLUG not set", file=sys.stderr)
78+
return 1
79+
7480
rst_body = parse_changelog(tag_name)
7581
md_body = convert_rst_to_md(rst_body)
76-
if not publish_github_release(token, tag_name, md_body):
82+
if not publish_github_release(slug, token, tag_name, md_body):
7783
print("Could not publish release notes:", file=sys.stderr)
7884
print(md_body, file=sys.stderr)
7985
return 5
8086

81-
print(f"Release notes for {tag_name} published successfully")
87+
print()
88+
print(f"Release notes for {tag_name} published successfully:")
89+
print(f"https://github.com/{slug}/releases/tag/{tag_name}")
90+
print()
8291
return 0
8392

8493

0 commit comments

Comments
 (0)