diff --git a/dodo.py b/dodo.py index 0e0ee51..e46ca13 100644 --- a/dodo.py +++ b/dodo.py @@ -175,8 +175,7 @@ def task_init_release_dir(): return { "actions": [create_release_dir], - "targets": [RELEASE_DIR, RELEASE_DIR / "github", RELEASE_DIR / "tmp"], - "clean": True, + "clean": [f"rm -rf {RELEASE_DIR}"], } @@ -199,13 +198,13 @@ def task_download_tessdata(): def task_build_image(): """Build the container image using ./install/common/build-image.py""" - img_src = "share/container-{VERSION}.tar.gz" - img_dst = RELEASE_DIR / "container-{VERSION}.tar.gz" # FIXME: Add arch + img_src = f"share/container-{VERSION}.tar.gz" + img_dst = RELEASE_DIR / f"container-{VERSION}.tar.gz" # FIXME: Add arch return { "actions": [ - "python install/common/build-image.py --use-cache=%(use_cache)s", - "cp {img_src} {img_dst}", + "python install/common/build-image.py --use-cache=%(use_cache)s --force-tag=%(force_tag)s", + f"cp {img_src} {img_dst}", ], "params": [ { @@ -217,6 +216,15 @@ def task_build_image(): ), "default": False, }, + { + "name": "force_tag", + "long": "force-tag", + "help": ( + "Build the image using the specified tag. For reproducibility" + " reasons, it's best to not use this flag" + ), + "default": "", + }, ], "file_dep": [ "Dockerfile", @@ -226,7 +234,10 @@ def task_build_image(): "install/common/build-image.py", ], "targets": [img_src, img_dst], - "task_dep": ["check_container_runtime"], + "task_dep": [ + "init_release_dir", + "check_container_runtime", + ], "clean": True, } @@ -242,7 +253,7 @@ def task_macos_build_dmg(): """Build the macOS app bundle for Dangerzone.""" dz_dir = RELEASE_DIR / "tmp" / "macos" dmg_src = dz_dir / "dist" / "Dangerzone.dmg" - dmg_dst = RELEASE_DIR / "Dangerzone-{VERSION}.dmg" # FIXME: Add -arch + dmg_dst = RELEASE_DIR / f"Dangerzone-{VERSION}.dmg" # FIXME: Add -arch return { "actions": [ @@ -256,7 +267,6 @@ def task_macos_build_dmg(): ], "params": [PARAM_APPLE_ID], "file_dep": [ - RELEASE_DIR, "poetry.lock", "install/macos/build.app.py", *list_files("assets"), @@ -264,7 +274,10 @@ def task_macos_build_dmg(): *list_files("dangerzone"), f"share/container-{VERSION}.tar.gz", ], - "task_dep": ["poetry_install"], + "task_dep": [ + "init_release_dir", + "poetry_install" + ], "targets": [dmg_dst], "clean": True, } @@ -318,15 +331,15 @@ def task_debian_deb(): ["rm", "-r", dz_dir], ], "file_dep": [ - RELEASE_DIR, "poetry.lock", "install/linux/build-deb.py", *list_files("assets"), *list_files("share"), *list_files("dangerzone"), - "share/container-{VERSION}.tar.gz", + f"share/container-{VERSION}.tar.gz", ], "task_dep": [ + "init_release_dir", "debian_env", ], "targets": [deb_dst], @@ -374,15 +387,15 @@ def task_fedora_rpm(): ["rm", "-r", dz_dir], ], "file_dep": [ - RELEASE_DIR, "poetry.lock", "install/linux/build-rpm.py", *list_files("assets"), *list_files("share"), *list_files("dangerzone"), - "share/container-{VERSION}.tar.gz", + f"share/container-{VERSION}.tar.gz", ], "task_dep": [ + "init_release_dir", f"fedora_env:{version}", ], "targets": rpm_dst, diff --git a/install/common/build-image.py b/install/common/build-image.py index e7b538a..073dabd 100644 --- a/install/common/build-image.py +++ b/install/common/build-image.py @@ -56,19 +56,27 @@ def main(): const=True, help="Use the builder's cache to speed up the builds (not suitable for release builds)", ) + parser.add_argument( + "--force-tag", + default=None, + help="Force tag the image with this tag", + ) args = parser.parse_args() print(f"Building for architecture '{ARCH}'") dirty_tag = secrets.token_hex(2) - tag = subprocess.check_output( - [ - "git", - "describe", - "--first-parent", - f"--dirty=-{dirty_tag}" - ], - ).decode().strip()[1:] # remove the "v" prefix of the tag. + if not args.force_tag: + tag = subprocess.check_output( + [ + "git", + "describe", + "--first-parent", + f"--dirty=-{dirty_tag}" + ], + ).decode().strip()[1:] # remove the "v" prefix of the tag. + else: + tag = args.force_tag image_name_tagged = IMAGE_NAME + ":" + tag print(f"Will tag the container image as '{image_name_tagged}'") diff --git a/pyproject.toml b/pyproject.toml index faa5896..be6ba8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -83,8 +83,9 @@ apple_id = "fpf@example.com" [tool.doit.tasks.macos_codesign] apple_id = "fpf@example.com" -[tool.doit.tasks.build_container] +[tool.doit.tasks.build_image] use_cache = false +force_tag = "" [build-system] requires = ["poetry-core>=1.2.0"]