diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9ff1a1f..d54c2b9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,14 +39,12 @@ jobs: ./scripts/build_image.py \ --stellar-cli-version "${{ steps.pair.outputs.cli }}" \ --rust-version "${{ steps.pair.outputs.rust }}" \ - --rust-image-digest "${{ steps.pair.outputs.digest }}" - name: smoke test run: | ./scripts/smoke_test_image.py \ --image "${{ steps.pair.outputs.image }}" \ --stellar-cli-version "${{ steps.pair.outputs.cli }}" \ --rust-version "${{ steps.pair.outputs.rust }}" \ - --rust-image-digest "${{ steps.pair.outputs.digest }}" - name: wasm reproducibility run: | ./scripts/repro_test.py \ diff --git a/README.md b/README.md index b29c5b4..4dc20e6 100644 --- a/README.md +++ b/README.md @@ -102,10 +102,12 @@ compare the resulting WASM sha256. ./scripts/validate_json.py # Build a local image for a declared (cli, rust base) pair. The rust base is -# given as the label plus its pinned digest (copy the pin from builds.json). +# given as the label; the digest is resolved from builds.json automatically. ./scripts/build_image.py --stellar-cli-version 26.0.0 \ - --rust-version 1.94.0-slim-trixie \ - --rust-image-digest sha256:f7bf1c266d9e48c8d724733fd97ba60464c44b743eb4f46f935577d3242d81d0 + --rust-version 1.94.0-slim-trixie + +# Only when a label carries more than one digest in builds.json do you need +# --rust-image-digest to say which pin to build. # Smoke-test the built image. docker run --rm stellar-cli:26.0.0-rust1.94.0-slim-trixie --version diff --git a/RELEASE.md b/RELEASE.md index a3a5890..7764bc6 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -102,11 +102,11 @@ The script prints the chosen release tag as its final stdout line. Commit and pu ```sh ./scripts/validate_json.py -# --rust-version is the label; --rust-image-digest is the pin's digest from -# builds.json (it pins the FROM and is cross-checked against the image's +# --rust-version is the label; build_image.py resolves its pinned digest from +# builds.json (the digest pins the FROM and is cross-checked against the image's # org.opencontainers.image.base.digest label). The built tag is label-only. -./scripts/build_image.py --stellar-cli-version 26.1.0 --rust-version 1.95.0-slim-trixie \ - --rust-image-digest sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0 +# Pass --rust-image-digest only when one label carries multiple digests. +./scripts/build_image.py --stellar-cli-version 26.1.0 --rust-version 1.95.0-slim-trixie ./scripts/smoke_test_image.py --image stellar-cli:26.1.0-rust1.95.0-slim-trixie \ --stellar-cli-version 26.1.0 --rust-version 1.95.0-slim-trixie \ --rust-image-digest sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0 diff --git a/scripts/build_image.py b/scripts/build_image.py index 27d3636..74bebbe 100755 --- a/scripts/build_image.py +++ b/scripts/build_image.py @@ -17,7 +17,7 @@ def build_parser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) parser.add_argument("--stellar-cli-version", required=True, metavar="V") parser.add_argument("--rust-version", required=True, metavar="KEY") - parser.add_argument("--rust-image-digest", required=True, metavar="DIGEST") + parser.add_argument("--rust-image-digest", default=None, metavar="DIGEST") parser.add_argument("--platform", default="", metavar="P") parser.add_argument("--tag", default="", metavar="REF") parser.add_argument("--source-repo", default="stellar/stellar-cli-docker", metavar="SLUG") @@ -29,10 +29,9 @@ def main(argv: list[str] | None = None) -> int: common.preflight_checks(["buildx"]) data = builds.load() - rust_digest = args.rust_image_digest try: - builds.assert_pair_declared( - data, args.stellar_cli_version, f"{args.rust_version}@{rust_digest}" + rust_digest = builds.resolve_rust_digest( + data, args.stellar_cli_version, args.rust_version, args.rust_image_digest ) stellar_ref = builds.stellar_cli_ref(data, args.stellar_cli_version) parsed = rust_keys.parse(args.rust_version) diff --git a/scripts/lib/builds.py b/scripts/lib/builds.py index 3d169a6..4ff0d76 100644 --- a/scripts/lib/builds.py +++ b/scripts/lib/builds.py @@ -81,6 +81,35 @@ def assert_pair_declared(data: dict[str, Any], cli: str, rust_pin: str) -> None: ) +def resolve_rust_digest( + data: dict[str, Any], cli: str, label: str, digest: str | None = None +) -> str: + """Resolve the pinned base digest for a (cli, rust label) pair. + + When `digest` is given, assert the exact `