Release: use independent component repositories
Container CI / release-build (push) Successful in 16m22s
Nightly release / publish-nightly (push) Successful in 16m6s

This commit is contained in:
faumaray committed 2026-07-28 21:24:30 +03:00
1 parent 8c69efc56f
commit f78004e822
26 files changed
+571 -49

No files matched your search

+25 -7
View File
@@ -320,7 +320,9 @@ def atomic_write(path: Path, content: bytes, mode: int = 0o644) -> None:
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--new-payload", type=Path, required=True)
parser.add_argument(
"--new-payload", type=Path, action="append", required=True
)
parser.add_argument("--existing-envelope", type=Path)
parser.add_argument("--public-key", type=Path, required=True)
parser.add_argument("--private-key", type=Path, required=True)
@@ -346,7 +348,9 @@ def main() -> None:
fail("--valid-days must be between 1 and 365")
if arguments.nightly_retention < 1:
fail("--nightly-retention must be positive")
new_payload_path = regular_file(arguments.new_payload, "new payload")
new_payload_paths = [
regular_file(path, "new payload") for path in arguments.new_payload
]
public_key = regular_file(arguments.public_key, "Ed25519 public key")
private_key = regular_file(
arguments.private_key, "Ed25519 private key", private=True
@@ -368,8 +372,17 @@ def main() -> None:
if previous is not None and previous != key_path:
fail(f"conflicting public keys for key id: {key_id}")
trusted_existing_keys[key_id] = key_path
new_document = load_json_bytes(new_payload_path.read_bytes(), "new feed payload")
new_releases = validate_payload(new_document, "new feed payload")
new_documents = [
load_json_bytes(path.read_bytes(), "new feed payload")
for path in new_payload_paths
]
new_document = new_documents[0]
new_releases: list[dict[str, Any]] = []
for document in new_documents:
releases = validate_payload(document, "new feed payload")
if document["feedId"] != new_document["feedId"]:
fail("new feed identifiers differ")
new_releases.extend(releases)
existing_document: dict[str, Any] | None = None
existing_payload_bytes = b""
@@ -389,7 +402,7 @@ def main() -> None:
output_payload = arguments.output_payload.resolve()
output_envelope = arguments.output_envelope.resolve()
inputs = {
new_payload_path,
*new_payload_paths,
private_key,
*trusted_existing_keys.values(),
}
@@ -422,7 +435,10 @@ def main() -> None:
)
generated = max(
generated,
parse_timestamp(new_document["generatedAt"], "new feed generatedAt"),
max(
parse_timestamp(document["generatedAt"], "new feed generatedAt")
for document in new_documents
),
)
if existing_document is not None:
generated = max(
@@ -431,7 +447,9 @@ def main() -> None:
existing_document["generatedAt"], "existing feed generatedAt"
),
)
minimum_sequence = int(new_document["sequence"])
minimum_sequence = max(
int(document["sequence"]) for document in new_documents
)
if existing_document is not None:
minimum_sequence = max(minimum_sequence, int(existing_document["sequence"]) + 1)
sequence = arguments.sequence
+66 -4
View File
@@ -341,6 +341,7 @@ configure_args=(
-DBUILD_SHARED_LIBS=ON
-DECHOION_STATIC_LINK=OFF
-DECHOION_REPRODUCIBLE_BUILD=ON
"-DECHOION_RELEASE_VERSION=$version"
"-DECHOION_RUNTIME_VERSION=$version"
)
official_update_keys="$source_dir/.gitea/release-keys/official-update-keys.json"
@@ -428,9 +429,9 @@ cmake \
# Bootstrap plugins are copied into writable managed-plugin state by the
# installer. Search the active release closure from managed, portable/manual,
# and immutable bootstrap locations, then allow plugin-private dependencies.
# shellcheck disable=SC2016 # Dynamic linker token, not a shell variable.
plugin_runpath='$ORIGIN/../../../../../../current/lib:$ORIGIN/../../current/lib:$ORIGIN/lib'
for plugin_library in "${resolver_libraries[@]:1}"; do
# shellcheck disable=SC2016 # Dynamic linker token, not a shell variable.
patchelf --set-rpath "$plugin_runpath" "$plugin_library"
done
@@ -550,10 +551,19 @@ installer="$dist_dir/$artifact_base.run"
external_manifest="$dist_dir/$artifact_base.manifest.json"
external_report="$dist_dir/$artifact_base.dependencies.txt"
feed_payload="$dist_dir/$artifact_base.update-payload.json"
core_artifact="$dist_dir/echoion-core-${version}-linux-x86_64.so"
core_feed_payload="$dist_dir/echoion-core-${version}-linux-x86_64.update-payload.json"
internal_plugin_artifact="$dist_dir/url-shortener-internal-${version}-linux-x86_64.so"
internal_plugin_feed_payload="$dist_dir/url-shortener-internal-${version}-linux-x86_64.update-payload.json"
external_plugin_artifact="$dist_dir/url-shortener-external-${version}-linux-x86_64.so"
external_plugin_feed_payload="$dist_dir/url-shortener-external-${version}-linux-x86_64.update-payload.json"
rm -f -- \
"$archive" "$archive.tmp" \
"$installer" "$installer.tmp" \
"$external_manifest" "$external_report" "$feed_payload" \
"$core_artifact" "$core_feed_payload" \
"$internal_plugin_artifact" "$internal_plugin_feed_payload" \
"$external_plugin_artifact" "$external_plugin_feed_payload" \
"$dist_dir/SHA256SUMS"
bash "$source_dir/scripts/package-release-payload.sh" \
@@ -562,6 +572,13 @@ bash "$source_dir/scripts/package-release-payload.sh" \
install -m 0644 "$stage/manifest.json" "$external_manifest"
install -m 0644 "$dependency_report" "$external_report"
install -m 0644 "$stage/lib/Echoion.ts" "$core_artifact"
install -m 0644 \
"$stage/share/echoion/bootstrap-plugins/url-shortener-internal/$version/url-shortener-internal.so" \
"$internal_plugin_artifact"
install -m 0644 \
"$stage/share/echoion/bootstrap-plugins/url-shortener-external/$version/url-shortener-external.so" \
"$external_plugin_artifact"
if [[ -n $update_url ]]; then
feed_args=(
--artifact "$archive"
@@ -576,6 +593,35 @@ if [[ -n $update_url ]]; then
[[ -z $update_sequence ]] ||
feed_args+=(--sequence "$update_sequence")
python3 "$source_dir/scripts/generate-update-feed.py" "${feed_args[@]}"
artifact_url_root=${update_url%/*}
component_feed_args=(
--version "$version"
--channel "$update_channel"
--feed-id "$update_feed_id"
--valid-days "$update_valid_days"
)
[[ -z $update_sequence ]] ||
component_feed_args+=(--sequence "$update_sequence")
python3 "$source_dir/scripts/generate-update-feed.py" \
--artifact "$core_artifact" \
--component core \
--url "$artifact_url_root/$(basename "$core_artifact")" \
--output-payload "$core_feed_payload" \
"${component_feed_args[@]}"
python3 "$source_dir/scripts/generate-update-feed.py" \
--artifact "$internal_plugin_artifact" \
--component plugin \
--artifact-id url-shortener-internal \
--url "$artifact_url_root/$(basename "$internal_plugin_artifact")" \
--output-payload "$internal_plugin_feed_payload" \
"${component_feed_args[@]}"
python3 "$source_dir/scripts/generate-update-feed.py" \
--artifact "$external_plugin_artifact" \
--component plugin \
--artifact-id url-shortener-external \
--url "$artifact_url_root/$(basename "$external_plugin_artifact")" \
--output-payload "$external_plugin_feed_payload" \
"${component_feed_args[@]}"
fi
(
cd "$dist_dir"
@@ -583,9 +629,17 @@ fi
"$(basename "$archive")" \
"$(basename "$installer")" \
"$(basename "$external_manifest")" \
"$(basename "$external_report")"
"$(basename "$external_report")" \
"$(basename "$core_artifact")" \
"$(basename "$internal_plugin_artifact")" \
"$(basename "$external_plugin_artifact")"
)
[[ -z $update_url ]] || checksum_files+=(
"$(basename "$feed_payload")"
"$(basename "$core_feed_payload")"
"$(basename "$internal_plugin_feed_payload")"
"$(basename "$external_plugin_feed_payload")"
)
[[ -z $update_url ]] || checksum_files+=("$(basename "$feed_payload")")
sha256sum "${checksum_files[@]}" >SHA256SUMS
)
@@ -594,5 +648,13 @@ echo " $archive"
echo " $installer"
echo " $external_manifest"
echo " $external_report"
[[ -z $update_url ]] || echo " $feed_payload"
echo " $core_artifact"
echo " $internal_plugin_artifact"
echo " $external_plugin_artifact"
if [[ -n $update_url ]]; then
echo " $feed_payload"
echo " $core_feed_payload"
echo " $internal_plugin_feed_payload"
echo " $external_plugin_feed_payload"
fi
echo " $dist_dir/SHA256SUMS"
+87
View File
@@ -0,0 +1,87 @@
#!/usr/bin/env python3
"""Clone the independently versioned Echoion component repositories."""
from __future__ import annotations
import argparse
import json
import subprocess
from pathlib import Path
def run(*args: str, cwd: Path | None = None) -> None:
subprocess.run(args, cwd=cwd, check=True)
def output(*args: str, cwd: Path) -> str:
return subprocess.check_output(args, cwd=cwd, text=True).strip()
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument(
"--update",
action="store_true",
help="fetch and check out locked revisions in existing clean repositories",
)
parser.add_argument(
"--record",
action="store_true",
help="record the current clean component HEADs in components.lock.json",
)
args = parser.parse_args()
if args.update and args.record:
parser.error("--update and --record are mutually exclusive")
root = Path(__file__).resolve().parents[1]
lock_path = root / "components.lock.json"
lock = json.loads(lock_path.read_text())
if lock.get("schemaVersion") != 1:
raise SystemExit("unsupported components.lock.json schema")
if args.record:
for name, component in lock["components"].items():
destination = root / name
if not (destination / ".git").exists():
raise SystemExit(f"component repository is missing: {destination}")
if output("git", "status", "--porcelain", cwd=destination):
raise SystemExit(
f"refusing to record dirty repository: {destination}"
)
component["revision"] = output(
"git", "rev-parse", "HEAD", cwd=destination
)
temporary = lock_path.with_suffix(".json.tmp")
temporary.write_text(json.dumps(lock, indent=2) + "\n")
temporary.replace(lock_path)
return 0
for name, component in lock["components"].items():
destination = root / name
revision = component["revision"]
if not destination.exists():
run(
"git",
"clone",
"--no-checkout",
component["url"],
str(destination),
)
run("git", "fetch", "--depth=1", "origin", revision, cwd=destination)
run("git", "checkout", "--detach", "FETCH_HEAD", cwd=destination)
continue
if not (destination / ".git").exists():
raise SystemExit(f"{destination} exists but is not a Git repository")
if not args.update:
continue
if output("git", "status", "--porcelain", cwd=destination):
raise SystemExit(f"refusing to update dirty repository: {destination}")
run("git", "fetch", "origin", revision, cwd=destination)
run("git", "checkout", "--detach", revision, cwd=destination)
return 0
if __name__ == "__main__":
raise SystemExit(main())
@@ -178,6 +178,34 @@ class AggregateUpdateFeedTest(unittest.TestCase):
self.assertNotEqual(collision.returncode, 0)
self.assertIn("immutable release identity", collision.stderr)
def test_multiple_component_payloads_are_signed_together(self) -> None:
runtime_payload = self.root / "runtime.json"
core_payload = self.root / "core.json"
runtime_release = release("1.2.3", "stable")
core_release = {
**release("1.2.3", "stable"),
"component": "core",
"url": "https://updates.example.invalid/echoion-core-1.2.3.so",
"packageType": "shared-library",
}
core_release.pop("releaseManifestSha256")
payload(runtime_payload, [runtime_release], 100)
payload(core_payload, [core_release], 100)
output = self.root / "components-output.json"
self.run_script(
runtime_payload,
output,
self.root / "components-envelope.json",
"--new-payload",
os.fspath(core_payload),
)
releases = json.loads(output.read_text(encoding="utf-8"))["releases"]
self.assertEqual(
{(item["component"], item["version"]) for item in releases},
{("runtime", "1.2.3"), ("core", "1.2.3")},
)
def test_tampered_existing_envelope_is_rejected(self) -> None:
first = self.root / "first.json"
first_output = self.root / "first-output.json"