From 3f3a50d5b415458e30c7ca3f8ae2e4c54eb012a6 Mon Sep 17 00:00:00 2001 From: Loren Eteval Date: Sun, 3 Nov 2024 11:33:36 +0800 Subject: [PATCH] Refine deployment tooling Signed-off-by: Loren Eteval --- Deploy.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Deploy.py b/Deploy.py index 43ef3bc..955f31d 100644 --- a/Deploy.py +++ b/Deploy.py @@ -34,6 +34,10 @@ logging.raiseExceptions = False logger = logging.getLogger('Deploy') +# Exit status +EXIT_SUCCESS = 0 +EXIT_FAILURE = 1 + DEPLOY_DIR_NAME = f'{APPLICATION_NAME}-Deploy' if PLATFORM == 'Windows': @@ -159,6 +163,7 @@ def cleanup(): if PLATFORM == 'Windows': # More cleanup on Windows try: + # Remove artifact os.remove(ROOT_DIR / f'{ARTIFACT_NAME}.zip') except Exception as ex: # Any non-exit exceptions @@ -168,6 +173,7 @@ def cleanup(): logger.info(f'remove artifact success') try: + # Remove unzipped folder shutil.rmtree(ROOT_DIR / WIN_UNZIPPED) except Exception as ex: # Any non-exit exceptions @@ -178,6 +184,7 @@ def cleanup(): elif PLATFORM == 'Darwin': # More cleanup on Darwin try: + # Remove artifact os.remove(ROOT_DIR / f'{ARTIFACT_NAME}.dmg') except Exception as ex: # Any non-exit exceptions @@ -187,6 +194,7 @@ def cleanup(): logger.info(f'remove artifact success') try: + # Remove app folder shutil.rmtree(MAC_APP_DIR) except Exception as ex: # Any non-exit exceptions @@ -252,10 +260,10 @@ def main(): logger.info('cleanup done') - sys.exit(0) + sys.exit(EXIT_SUCCESS) if args.download: - success = 0 if download() else 1 + success = EXIT_SUCCESS if download() else EXIT_FAILURE sys.exit(success) @@ -279,7 +287,7 @@ def main(): printStandardStream(err.stdout, err.stderr) - sys.exit(-1) + sys.exit(EXIT_FAILURE) else: logger.info(f'build success') @@ -343,12 +351,17 @@ def main(): printStandardStream(err.stdout, err.stderr) - sys.exit(-1) + sys.exit(EXIT_FAILURE) else: - printStandardStream(result.stdout, result.stderr) - logger.info(f'generate dmg success: {MAC_DMG_FILENAME}') + printStandardStream(result.stdout, result.stderr) + else: + # Deploy: Not implemented + pass + + sys.exit(EXIT_SUCCESS) + if __name__ == '__main__': main()