Skip to content

Commit

Permalink
make_release: Update GitHub API
Browse files Browse the repository at this point in the history
  • Loading branch information
khalim19 committed Oct 22, 2022
1 parent 6cea272 commit f2bf05f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion utils/make_release.py
Expand Up @@ -105,6 +105,7 @@ def _make_release(release_metadata):
print('Active branch:', release_metadata.repo.active_branch.name)

release_metadata.new_version = _get_next_version(release_metadata)
release_metadata.access_token = _get_access_token(release_metadata)

_check_if_tag_with_new_version_already_exists(release_metadata)

Expand Down Expand Up @@ -179,6 +180,13 @@ def _get_next_version(release_metadata):
return str(ver)


def _get_access_token(release_metadata):
if release_metadata.dry_run:
return None

return getpass.getpass('Enter your GitHub access token:')


def _prompt_to_proceed():
response = input('Proceed with release? [y/n] ')

Expand Down Expand Up @@ -396,7 +404,9 @@ def _create_github_release(release_metadata):
}

access_token_header = {
'Authorization': 'token {}'.format(getpass.getpass('Enter your GitHub access token:'))}
'Accept': 'application/vnd.github+json',
'Authorization': 'Bearer {}'.format(release_metadata.access_token),
}

response = requests.post(
releases_url, headers=access_token_header, data=json.dumps(data_dict))
Expand Down

0 comments on commit f2bf05f

Please sign in to comment.