From ec69e113bf3c334a19201adc042fe4f4d41005d9 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Fri, 29 Mar 2024 16:46:07 +0800 Subject: [PATCH] Add signing and environment variables --- lib/renderers.py | 39 +++++++++++++++++++++++++++++++++++++++ multibuild.py | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/lib/renderers.py b/lib/renderers.py index e52016d..680100e 100644 --- a/lib/renderers.py +++ b/lib/renderers.py @@ -40,3 +40,42 @@ def has_files_to_upload(props): @util.renderer def no_files_to_upload(props): return not _files_to_upload(props) + +def _should_build_sign(props): + if props.getProperty('branch') == 'v0.6' \ + and props.getProperty('jobname') == 'android' \ + and props.getProperty('repository') in ( + 'git@github.com:Bitmessage/PyBitmessage.git', + 'https://github.com/Bitmessage/PyBitmessage' + ): + return True + return False + +@util.renderer +def should_build_sign(props): + return _is_build_script_available(props) and _should_build_sign(props) + +@util.renderer +def shouldnt_build_sign(props): + return _is_build_script_available(props) and not _should_build_sign(props) + +@util.renderer + +@util.renderer +def build_env(props): + default_envs = { + BUILDBOT_REPOSITORY: props.getProperty("repository") + BUILDBOT_BRANCH: props.getProperty("branch") + BUILDBOT_JOB: props.getProperty("job") + } + new_envs = {} + if props.getProperty("jobname", default="") == "android": + new_envs = { + "P4A_RELEASE_KEYSTORE": "/var/lib/buildbot/keystore", + "P4A_RELEASE_KEYSTORE_PASSWD": util.Secret("bitmessage-keystore"), + "P4A_RELEASE_KEYALIAS_PASSWD": util.Secret("bitmessage-keystore"), + "P4A_RELEASE_KEYALIAS": "bitmessagetest" + } + if _should_build_sign(props): + return {**default_envs, **new_envs} + return default_envs diff --git a/multibuild.py b/multibuild.py index a9212a7..cab1ca7 100644 --- a/multibuild.py +++ b/multibuild.py @@ -53,18 +53,52 @@ def add_child_sh_steps(build_factory, directory=".buildbot"): Add a step to the download, build and test factory """ + build_factory.addStep( + steps.FileDownload( + name="Upload keystore", + workerdest="/var/lib/buildbot/keystore", + mastersrc=util.Interpolate("keystore/%(prop:jobname)s.keystore") + doStepIf=should_build_sign, + hideStepIf=True, + mode=0o600 + ) + ) + build_factory.addStep( steps.ShellCommand( name=util.Interpolate("build_%(prop:jobname)s"), command=util.Interpolate("%(kw:directory)s/" "%(prop:jobname)s/build.sh", directory=directory), - doStepIf=is_build_script_available, + env=build_env, + doStepIf=should_build_sign, hideStepIf=isnt_build_script_available, timeout=7200, ) ) + build_factory.addStep( + steps.ShellCommand( + name=util.Interpolate("build_and_sign_%(prop:jobname)s"), + command=util.Interpolate("%(kw:directory)s/" + "%(prop:jobname)s/build.sh", + directory=directory), + env=build_env, + doStepIf=should_build_sign, + hideStepIf=isnt_build_script_available, + timeout=7200, + ) + ) + + build_factory.addStep( + steps.ShellCommand( + name="Delete keystore", + command="rm -f /var/lib/buildbot/keystore", + doStepIf=should_build_sign, + hideStepIf=True, + ) + ) + build_factory.addStep( steps.ShellCommand( name=util.Interpolate("test_%(prop:jobname)s"),