From ff055c8a5f18819f151219a960602a5a872c4f45 Mon Sep 17 00:00:00 2001 From: Matt Bacchi Date: Fri, 18 Oct 2019 08:55:55 -0400 Subject: [PATCH 1/2] Uplift of #3736 (squashed) to beta --- script/publish_release.py | 11 ++++++++++- script/test/test_publish.py | 11 +++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/script/publish_release.py b/script/publish_release.py index ec69fe7d176e..4fedab9c770b 100755 --- a/script/publish_release.py +++ b/script/publish_release.py @@ -38,9 +38,18 @@ def main(): repo = GitHub(get_env_var('GITHUB_TOKEN')).repos(BRAVE_REPO) - release = get_draft(repo, BRAVE_VERSION) + tag = get_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) diff --git a/script/test/test_publish.py b/script/test/test_publish.py index 7c2e5ff4ac91..b6c73d191d0d 100644 --- a/script/test/test_publish.py +++ b/script/test/test_publish.py @@ -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__': From a6eac6a4b2e9739c285d343e97ac0917de3a02d5 Mon Sep 17 00:00:00 2001 From: Matt Bacchi Date: Mon, 21 Oct 2019 14:23:59 -0400 Subject: [PATCH 2/2] Use BRAVE_VERSION as tag passed in from Jenkins job This was the fix for issue 6551 --- script/publish_release.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/publish_release.py b/script/publish_release.py index 4fedab9c770b..5b283445bbf1 100755 --- a/script/publish_release.py +++ b/script/publish_release.py @@ -38,7 +38,7 @@ def main(): repo = GitHub(get_env_var('GITHUB_TOKEN')).repos(BRAVE_REPO) - tag = get_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