Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to publish GitHub pre-release as full release (uplift to 0.70.x) #3744

Merged
merged 2 commits into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion script/publish_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,18 @@ def main():

repo = GitHub(get_env_var('GITHUB_TOKEN')).repos(BRAVE_REPO)

release = get_draft(repo, BRAVE_VERSION)
tag = BRAVE_VERSION
logging.debug("Tag: {}".format(tag))

# If we are publishing a prerelease, the release can only be in draft mode. If we
# are publishing a full release, it is allowed to already be a published release.
if args.prerelease:
release = get_draft(repo, tag)
else:
release = get_release(repo, tag, allow_published_release_updates=True)

tag_name = release['tag_name']
logging.debug("release[id]: {}".format(release['id']))

logging.info("Releasing {}".format(tag_name))
publish_release(repo, release['id'], tag_name, args.prerelease, logging)
Expand Down
11 changes: 3 additions & 8 deletions script/test/test_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,17 @@ class TestPublishGetDraft(unittest.TestCase):
def setUp(self):
self.repo = Repo()

@unittest.skip("TODO: mbacchi fix test")
def test_fails_on_existing_release(self):
self.repo.releases._releases = [{'tag_name': 'test', 'draft': False}]
self.assertRaises(UserWarning, publish_release.get_draft, self.repo,
'test')
self.assertRaises(UserWarning, publish_release.get_draft, self.repo, 'test')

@unittest.skip("TODO: mbacchi fix test")
def test_fails_on_no_draft(self):
self.repo.releases._releases = [{'tag_name': 'old', 'draft': False}]
self.assertRaises(UserWarning, publish_release.get_draft, self.repo,
'new')
self.assertRaises(UserWarning, publish_release.get_draft, self.repo, 'new')

@unittest.skip("TODO: mbacchi fix test")
def test_succeeds_on_existing_draft(self):
self.repo.releases._releases = [{'tag_name': 'test', 'draft': True}]
publish_release.get_draft(self.repo, 'test')
self.assertRaises(UserWarning, publish_release.get_draft, self.repo, 'test')


if __name__ == '__main__':
Expand Down