feat(package): download and verify prebuilt binary variants
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 1m5s

This commit is contained in:
faumaray committed 2026-12-03 20:17:17 +03:00
1 parent 118c0dc860
commit 9b405ce772
9 files changed
+199 -3

No files matched your search

+31
View File
@@ -379,6 +379,37 @@ download_release_archive(std::string_view registry_url, std::string_view package
return dest_file;
}
Void::Result::Result<std::filesystem::path, Void::Result::Error>
download_binary_artifact(std::string_view url, std::string_view expected_sha256,
const std::filesystem::path &dest_file) {
auto parsed_url = parse_registry_url(url);
if (!parsed_url) {
return std::unexpected{parsed_url.error()};
}
auto reply = send_http_request(*parsed_url, "GET", "", {}, {});
if (!reply) {
return std::unexpected{reply.error()};
}
if (reply->status != 200) {
return std::unexpected{make_error(
reply->status == 404 ? Void::System::SystemErrorCode::not_found
: Void::System::SystemErrorCode::io_error,
std::format("binary artifact GET {} failed with HTTP {}", url, reply->status))};
}
const std::string actual_sha = Util::sha256_hex(reply->body);
if (!expected_sha256.empty() && actual_sha != expected_sha256) {
return std::unexpected{
make_error(Void::System::SystemErrorCode::invalid_argument,
std::format("binary artifact SHA-256 mismatch: expected {}, got {}",
expected_sha256, actual_sha))};
}
auto wrote = Platform::atomic_write_file(dest_file, reply->body, true);
if (!wrote) {
return std::unexpected{wrote.error()};
}
return dest_file;
}
Void::Result::Result<PublishReceipt, Void::Result::Error>
publish_package_archive(const PublishOptions &options) {
if (!Void::Semver::parse_strict(options.version)) {