mirror of
https://github.com/docker/compose.git
synced 2025-05-02 21:50:15 +02:00
Improve finalize robustness and allow resume using special --finalize-resume flag
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
0b5f68098c
commit
d7f5220292
@ -28,6 +28,7 @@ from release.utils import ScriptError
|
|||||||
from release.utils import update_init_py_version
|
from release.utils import update_init_py_version
|
||||||
from release.utils import update_run_sh_version
|
from release.utils import update_run_sh_version
|
||||||
from release.utils import yesno
|
from release.utils import yesno
|
||||||
|
from requests.exceptions import HTTPError
|
||||||
from twine.commands.upload import main as twine_upload
|
from twine.commands.upload import main as twine_upload
|
||||||
|
|
||||||
|
|
||||||
@ -162,6 +163,24 @@ def distclean():
|
|||||||
shutil.rmtree(folder, ignore_errors=True)
|
shutil.rmtree(folder, ignore_errors=True)
|
||||||
|
|
||||||
|
|
||||||
|
def pypi_upload(args):
|
||||||
|
print('Uploading to PyPi')
|
||||||
|
try:
|
||||||
|
twine_upload([
|
||||||
|
'dist/docker_compose-{}*.whl'.format(args.release),
|
||||||
|
'dist/docker-compose-{}*.tar.gz'.format(args.release)
|
||||||
|
])
|
||||||
|
except HTTPError as e:
|
||||||
|
if e.response.status_code == 400 and 'File already exists' in e.message:
|
||||||
|
if not args.finalize_resume:
|
||||||
|
raise ScriptError(
|
||||||
|
'Package already uploaded on PyPi.'
|
||||||
|
)
|
||||||
|
print('Skipping PyPi upload - package already uploaded')
|
||||||
|
else:
|
||||||
|
raise ScriptError('Unexpected HTTP error uploading package to PyPi: {}'.format(e))
|
||||||
|
|
||||||
|
|
||||||
def resume(args):
|
def resume(args):
|
||||||
try:
|
try:
|
||||||
distclean()
|
distclean()
|
||||||
@ -274,13 +293,13 @@ def finalize(args):
|
|||||||
run_setup(os.path.join(REPO_ROOT, 'setup.py'), script_args=['sdist', 'bdist_wheel'])
|
run_setup(os.path.join(REPO_ROOT, 'setup.py'), script_args=['sdist', 'bdist_wheel'])
|
||||||
|
|
||||||
merge_status = pr_data.merge()
|
merge_status = pr_data.merge()
|
||||||
if not merge_status.merged:
|
if not merge_status.merged and not args.finalize_resume:
|
||||||
raise ScriptError('Unable to merge PR #{}: {}'.format(pr_data.number, merge_status.message))
|
raise ScriptError(
|
||||||
print('Uploading to PyPi')
|
'Unable to merge PR #{}: {}'.format(pr_data.number, merge_status.message)
|
||||||
twine_upload([
|
)
|
||||||
'dist/docker_compose-{}*.whl'.format(args.release),
|
|
||||||
'dist/docker-compose-{}*.tar.gz'.format(args.release)
|
pypi_upload(args)
|
||||||
])
|
|
||||||
img_manager.push_images()
|
img_manager.push_images()
|
||||||
repository.publish_release(gh_release)
|
repository.publish_release(gh_release)
|
||||||
except ScriptError as e:
|
except ScriptError as e:
|
||||||
@ -355,6 +374,10 @@ def main():
|
|||||||
'--skip-ci-checks', dest='skip_ci', action='store_true',
|
'--skip-ci-checks', dest='skip_ci', action='store_true',
|
||||||
help='If set, the program will not wait for CI jobs to complete'
|
help='If set, the program will not wait for CI jobs to complete'
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--finalize-resume', dest='finalize_resume', action='store_true',
|
||||||
|
help='If set, finalize will continue through steps that have already been completed.'
|
||||||
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.action == 'start':
|
if args.action == 'start':
|
||||||
|
@ -81,3 +81,7 @@ class ImageManager(object):
|
|||||||
for chunk in logstream:
|
for chunk in logstream:
|
||||||
if 'status' in chunk:
|
if 'status' in chunk:
|
||||||
print(chunk['status'])
|
print(chunk['status'])
|
||||||
|
if 'error' in chunk:
|
||||||
|
raise ScriptError(
|
||||||
|
'Error pushing {name}: {err}'.format(name=name, err=chunk['error'])
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user