Export stable C ABI and add component releases

This commit is contained in:
faumaray committed 2026-07-29 22:40:35 +03:00
1 parent 3e6279d9e9
commit 5c98e71d9b
5 files changed
+216 -51

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
name: Independent component release
on:
push:
tags: [v*]
schedule:
- cron: '17 2 * * *'
workflow_dispatch:
jobs:
publish:
runs-on: echoion-release-serial
steps:
- name: Check out component
uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with:
fetch-depth: 0
ssh-key: ${{ secrets.RELEASE_CHECKOUT_SSH_KEY }}
persist-credentials: false
- name: Check out pinned public release tools
uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with:
repository: Void/Echoion
ref: ${{ vars.ECHOION_RELEASE_TOOLS_REF }}
path: .echoion-release-tools
fetch-depth: 0
ssh-key: ${{ secrets.RELEASE_CHECKOUT_SSH_KEY }}
persist-credentials: false
- name: Build, publish, and merge feed transaction
shell: bash
env:
AWS_ACCESS_KEY_ID: ${{ secrets.COMPONENT_OBJECT_STORAGE_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.COMPONENT_OBJECT_STORAGE_SECRET_KEY }}
AWS_DEFAULT_REGION: ${{ vars.COMPONENT_OBJECT_STORAGE_REGION }}
ECHOION_COMPONENT_SSH_KEY: ${{ secrets.RELEASE_CHECKOUT_SSH_KEY }}
ECHOION_DISTRIBUTION_BASE_URL: ${{ vars.ECHOION_DISTRIBUTION_BASE_URL }}
ECHOION_FEED_BASE_URL: ${{ vars.ECHOION_FEED_BASE_URL }}
ECHOION_FEED_COMMIT_SIGNING_KEY: ${{ secrets.RELEASE_FEED_GIT_SIGNING_KEY }}
ECHOION_FEED_PRIVATE_KEY: ${{ secrets.RELEASE_FEED_ED25519_PRIVATE_KEY }}
ECHOION_FEED_REPOSITORY: ssh://gitea@git.faumaray.ru/Void/Echoion.git
ECHOION_FEED_SIGNING_KEY_ID: ${{ vars.ECHOION_FEED_SIGNING_KEY_ID }}
ECHOION_OBJECT_STORAGE_BUCKET: ${{ vars.COMPONENT_OBJECT_STORAGE_BUCKET }}
ECHOION_OBJECT_STORAGE_ENDPOINT: ${{ vars.COMPONENT_OBJECT_STORAGE_ENDPOINT }}
ECHOION_OBJECT_STORAGE_PREFIX: ${{ vars.COMPONENT_OBJECT_STORAGE_PREFIX }}
ECHOION_RELEASE_TAG_ALLOWED_SIGNERS: ${{ secrets.RELEASE_TAG_ALLOWED_SIGNERS }}
GITEA_API_URL: ${{ gitea.api_url }}
GITEA_EVENT_NAME: ${{ gitea.event_name }}
GITEA_REF_NAME: ${{ gitea.ref_name }}
GITEA_RUN_NUMBER: ${{ gitea.run_number }}
GITEA_SHA: ${{ gitea.sha }}
GITEA_REPOSITORY: ${{ gitea.repository }}
GITEA_RELEASE_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }}
RELEASE_TOOLS_REF: ${{ vars.ECHOION_RELEASE_TOOLS_REF }}
run: |
set -euo pipefail
[[ "$RELEASE_TOOLS_REF" =~ ^[0-9a-f]{40}$ ]]
test "$(git -C .echoion-release-tools rev-parse HEAD)" = "$RELEASE_TOOLS_REF"
.echoion-release-tools/scripts/release-component.sh component.release.json
+10 -3
View File
@@ -1,9 +1,12 @@
cmake_minimum_required(VERSION 4.0.0) cmake_minimum_required(VERSION 4.0.0)
if(NOT DEFINED ECHOION_PRODUCT_VERSION) if(NOT DEFINED ECHOION_PRODUCT_VERSION)
set(ECHOION_PRODUCT_VERSION 2.0.0) set(ECHOION_PRODUCT_VERSION 0.0.0)
endif()
if(NOT DEFINED ECHOION_COMPONENT_VERSION)
set(ECHOION_COMPONENT_VERSION "${ECHOION_PRODUCT_VERSION}")
endif() endif()
project(EchoionPluginUrlShortenerInternal project(EchoionPluginUrlShortenerInternal
VERSION "${ECHOION_PRODUCT_VERSION}" LANGUAGES CXX) VERSION "${ECHOION_COMPONENT_VERSION}" LANGUAGES CXX)
include(GNUInstallDirs) include(GNUInstallDirs)
@@ -42,7 +45,11 @@ target_include_directories(EchoionUrlShortenerInternalPlugin PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/include") "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_compile_features(EchoionUrlShortenerInternalPlugin PRIVATE cxx_std_26) target_compile_features(EchoionUrlShortenerInternalPlugin PRIVATE cxx_std_26)
target_compile_definitions(EchoionUrlShortenerInternalPlugin PRIVATE target_compile_definitions(EchoionUrlShortenerInternalPlugin PRIVATE
"ECHOION_COMPONENT_VERSION=\"${PROJECT_VERSION}\"") "ECHOION_COMPONENT_VERSION=\"${PROJECT_VERSION}\""
ECHOION_COMPONENT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
ECHOION_COMPONENT_VERSION_MINOR=${PROJECT_VERSION_MINOR}
ECHOION_COMPONENT_VERSION_PATCH=${PROJECT_VERSION_PATCH}
ECHOION_MODULE_BUILD)
target_link_libraries(EchoionUrlShortenerInternalPlugin PRIVATE target_link_libraries(EchoionUrlShortenerInternalPlugin PRIVATE
Echoion::ApiPlugin Echoion::ApiPlugin
Echoion::ApiConfig Echoion::ApiConfig
+4 -2
View File
@@ -1,14 +1,16 @@
{ {
"schemaVersion": 1, "schemaVersion": 1,
"contractId": "echoion.plugin.url-shortener-internal", "contractId": "echoion.plugin.url-shortener-internal",
"descriptor": "Void::Plugin::ModuleDescriptor", "descriptor": "echoion_module_descriptor_v1",
"querySymbol": "echoion_module_abi_query",
"moduleId": "url-shortener-internal", "moduleId": "url-shortener-internal",
"activationPolicy": "reloadable", "activationPolicy": "reloadable",
"services": [ "services": [
{ {
"id": "void.short-url", "id": "void.short-url",
"version": 1, "version": 1,
"type": "Void::ShortUrl::IShortener" "contract": "void.short-url.v1",
"transport": "opaque-service-table"
} }
] ]
} }
+7
View File
@@ -0,0 +1,7 @@
{
"schemaVersion": 1,
"componentId": "EchoionPluginUrlShortenerInternal",
"productCompatibility": ">=2.0.0 <3.0.0",
"publishNightly": true,
"cmakeOptions": {}
}
+139 -46
View File
@@ -1,5 +1,5 @@
#include <echoion/api/module/LegacyModuleAbi.hpp>
#include <echoion/api/plugin/ShortUrlSupport.hpp> #include <echoion/api/plugin/ShortUrlSupport.hpp>
#include <echoion/api/module/Module.hpp>
#include <echoion/plugins/short_url/InternalStore.hpp> #include <echoion/plugins/short_url/InternalStore.hpp>
#include <ExtensionPlugin.hpp> #include <ExtensionPlugin.hpp>
@@ -11,6 +11,7 @@
#include <cstdint> #include <cstdint>
#include <filesystem> #include <filesystem>
#include <format> #include <format>
#include <iterator>
#include <memory> #include <memory>
#include <string> #include <string>
#include <string_view> #include <string_view>
@@ -26,38 +27,38 @@ namespace Echoion::Plugins::ShortUrl
constexpr std::string_view kPluginId{"url-shortener-internal"}; constexpr std::string_view kPluginId{"url-shortener-internal"};
constexpr std::string_view kPluginVersion{ECHOION_COMPONENT_VERSION}; constexpr std::string_view kPluginVersion{ECHOION_COMPONENT_VERSION};
[[nodiscard]] const Void::Json::Value& [[nodiscard]] const Void::Json::Value &
settingsObject(const Void::Json::Value& root) noexcept settingsObject(const Void::Json::Value &root) noexcept
{ {
if (const auto* settings = root.child_object("settings")) { if (const auto *settings = root.child_object("settings")) {
return *settings; return *settings;
} }
return root; return root;
} }
[[nodiscard]] const Void::Json::Value* [[nodiscard]] const Void::Json::Value *
hostObject(const Void::Json::Value& root) noexcept hostObject(const Void::Json::Value &root) noexcept
{ {
if (const auto* host = root.child_object("_host")) { if (const auto *host = root.child_object("_host")) {
return host; return host;
} }
return root.child_object("host"); return root.child_object("host");
} }
[[nodiscard]] Result<InternalConfig> [[nodiscard]] Result<InternalConfig>
parseInternalConfig(const std::string& payload) parseInternalConfig(const std::string &payload)
{ {
auto root = parseConfigObject(payload.c_str()); auto root = parseConfigObject(payload.c_str());
if (!root) { if (!root) {
return std::unexpected{std::move(root).error()}; return std::unexpected{std::move(root).error()};
} }
const auto& settings = settingsObject(*root); const auto &settings = settingsObject(*root);
auto publicBaseUrl = optionalString(settings, "publicBaseUrl"); auto publicBaseUrl = optionalString(settings, "publicBaseUrl");
if (!publicBaseUrl) { if (!publicBaseUrl) {
return std::unexpected{std::move(publicBaseUrl).error()}; return std::unexpected{std::move(publicBaseUrl).error()};
} }
if (publicBaseUrl->empty()) { if (publicBaseUrl->empty()) {
if (const auto* host = hostObject(*root)) { if (const auto *host = hostObject(*root)) {
publicBaseUrl = optionalString(*host, "publicBaseUrl"); publicBaseUrl = optionalString(*host, "publicBaseUrl");
} }
} }
@@ -77,8 +78,8 @@ namespace Echoion::Plugins::ShortUrl
} }
} }
const Void::Json::Value* host = hostObject(*root); const Void::Json::Value *host = hostObject(*root);
const auto& stateObject = host != nullptr ? *host : settings; const auto &stateObject = host != nullptr ? *host : settings;
auto stateDirectory = requireString(stateObject, "stateDirectory"); auto stateDirectory = requireString(stateObject, "stateDirectory");
if (!stateDirectory && host != nullptr) { if (!stateDirectory && host != nullptr) {
stateDirectory = requireString(*host, "stateDir"); stateDirectory = requireString(*host, "stateDir");
@@ -141,7 +142,7 @@ namespace Echoion::Plugins::ShortUrl
} }
[[nodiscard]] Api::Result<Void::Json::Value> [[nodiscard]] Api::Result<Void::Json::Value>
parseRpcParams(const Api::ExtensionRpcRequest& request) parseRpcParams(const Api::ExtensionRpcRequest &request)
{ {
const auto payload = request.params.empty() ? "{}" : request.params; const auto payload = request.params.empty() ? "{}" : request.params;
auto parsed = Void::Json::parse(payload); auto parsed = Void::Json::parse(payload);
@@ -193,7 +194,7 @@ namespace Echoion::Plugins::ShortUrl
}; };
} }
void applyConfig(const char* config) void applyConfig(const char *config)
{ {
configPayload_ = config != nullptr ? config : ""; configPayload_ = config != nullptr ? config : "";
} }
@@ -218,28 +219,41 @@ namespace Echoion::Plugins::ShortUrl
void on_unload() override { store_.reset(); } void on_unload() override { store_.reset(); }
[[nodiscard]] Void::ShortUrl::ShortenResult [[nodiscard]] Void::ShortUrl::ShortenResult
shorten(const Void::ShortUrl::ShortenRequest& request) override shorten(const Void::ShortUrl::ShortenRequest &request) override
{ {
if (store_ == nullptr) { if (store_ == nullptr) {
return {.error = { return {
.short_url = {},
.key = {},
.expires_at_unix_seconds = {},
.error =
{
.code = Void::ShortUrl::ErrorCode::unavailable, .code = Void::ShortUrl::ErrorCode::unavailable,
.message = "internal shortener is unavailable", .message = "internal shortener is unavailable",
}}; },
};
} }
auto result = auto result =
store_->shorten(request.target_url, request.custom_key, store_->shorten(request.target_url, request.custom_key,
request.expires_at_unix_seconds); request.expires_at_unix_seconds);
if (!result) { if (!result) {
auto error = std::move(result).error(); auto error = std::move(result).error();
return {.error = { return {
.short_url = {},
.key = {},
.expires_at_unix_seconds = {},
.error =
{
.code = toServiceError(error.code), .code = toServiceError(error.code),
.message = std::move(error.message), .message = std::move(error.message),
}}; },
};
} }
return { return {
.short_url = std::move(result->shortUrl), .short_url = std::move(result->shortUrl),
.key = std::move(result->key), .key = std::move(result->key),
.expires_at_unix_seconds = result->expiresAtUnixSeconds, .expires_at_unix_seconds = result->expiresAtUnixSeconds,
.error = {},
}; };
} }
@@ -249,25 +263,36 @@ namespace Echoion::Plugins::ShortUrl
} }
[[nodiscard]] Void::ShortUrl::ResolveResult [[nodiscard]] Void::ShortUrl::ResolveResult
resolve(const Void::ShortUrl::ResolveRequest& request) override resolve(const Void::ShortUrl::ResolveRequest &request) override
{ {
if (store_ == nullptr) { if (store_ == nullptr) {
return {.error = { return {
.target_url = {},
.expires_at_unix_seconds = {},
.error =
{
.code = Void::ShortUrl::ErrorCode::unavailable, .code = Void::ShortUrl::ErrorCode::unavailable,
.message = "internal shortener is unavailable", .message = "internal shortener is unavailable",
}}; },
};
} }
auto result = store_->resolve(request.key); auto result = store_->resolve(request.key);
if (!result) { if (!result) {
auto error = std::move(result).error(); auto error = std::move(result).error();
return {.error = { return {
.target_url = {},
.expires_at_unix_seconds = {},
.error =
{
.code = toServiceError(error.code), .code = toServiceError(error.code),
.message = std::move(error.message), .message = std::move(error.message),
}}; },
};
} }
return { return {
.target_url = std::move(result->targetUrl), .target_url = std::move(result->targetUrl),
.expires_at_unix_seconds = result->expiresAtUnixSeconds, .expires_at_unix_seconds = result->expiresAtUnixSeconds,
.error = {},
}; };
} }
@@ -283,7 +308,7 @@ namespace Echoion::Plugins::ShortUrl
} }
Api::Result<std::string> Api::Result<std::string>
callRpc(const Api::ExtensionRpcRequest& request) override callRpc(const Api::ExtensionRpcRequest &request) override
{ {
if (store_ == nullptr) { if (store_ == nullptr) {
return Api::fail(Api::ErrorCode::ServiceUnavailable, return Api::fail(Api::ErrorCode::ServiceUnavailable,
@@ -324,7 +349,7 @@ namespace Echoion::Plugins::ShortUrl
} }
Api::Result<std::string> Api::Result<std::string>
revokeRpc(const Api::ExtensionRpcRequest& request) revokeRpc(const Api::ExtensionRpcRequest &request)
{ {
auto params = parseRpcParams(request); auto params = parseRpcParams(request);
if (!params) { if (!params) {
@@ -345,7 +370,7 @@ namespace Echoion::Plugins::ShortUrl
} }
Api::Result<std::string> Api::Result<std::string>
cleanupRpc(const Api::ExtensionRpcRequest& request) cleanupRpc(const Api::ExtensionRpcRequest &request)
{ {
auto params = parseRpcParams(request); auto params = parseRpcParams(request);
if (!params) { if (!params) {
@@ -378,17 +403,25 @@ namespace Echoion::Plugins::ShortUrl
return std::make_unique<InternalShortenerPlugin>(); return std::make_unique<InternalShortenerPlugin>();
} }
const Void::Plugin::ModuleDescriptor& moduleDescriptor() const Void::Plugin::ModuleDescriptor &moduleDescriptor()
{ {
static const Void::Plugin::ModuleDescriptor descriptor{ static const Void::Plugin::ModuleDescriptor descriptor{
.module_id = "url-shortener-internal", .module_id = "url-shortener-internal",
.component_version = {.major = 2, .minor = 0, .patch = 0}, .component_version =
.abi_hash = {
"sha256:68e338e9fd65bfad73364587af7e1c95f6ce98fe2ab08922113d9d240a4c8a39", .major = ECHOION_COMPONENT_VERSION_MAJOR,
.minor = ECHOION_COMPONENT_VERSION_MINOR,
.patch = ECHOION_COMPONENT_VERSION_PATCH,
.pre_release = {},
.build = {},
},
.abi_hash = "sha256:"
"40a9d5a3cd47bd0bb02cb38fb530ce0fc0d59f813749565a1d7fcf"
"dabbb53688",
.abi_contract = Void::Json::object({ .abi_contract = Void::Json::object({
{"schemaVersion", 1}, {"schemaVersion", 1},
{"contractId", "echoion.plugin.url-shortener-internal"}, {"contractId", "echoion.plugin.url-shortener-internal"},
{"descriptor", "Void::Plugin::ModuleDescriptor"}, {"descriptor", "echoion_module_descriptor_v1"},
}), }),
.dependencies = .dependencies =
{ {
@@ -396,7 +429,9 @@ namespace Echoion::Plugins::ShortUrl
.module_id = "EchoionApi", .module_id = "EchoionApi",
.version_range = "^2.0.0", .version_range = "^2.0.0",
.abi_hash = .abi_hash =
"sha256:336492a52097dd12f222bb6d9acab19e8eb6a502eab45bb78127bce6d733fbd3", "sha256:"
"d50293d345a97e52f9844088bdd42277f566bc815a21b763"
"6d3e053f06c6c113",
}, },
}, },
.activation_policy = Void::Plugin::ActivationPolicy::Reloadable, .activation_policy = Void::Plugin::ActivationPolicy::Reloadable,
@@ -405,26 +440,84 @@ namespace Echoion::Plugins::ShortUrl
return descriptor; return descriptor;
} }
const echoion_module_descriptor_v1 &moduleAbiDescriptor()
{
using Bridge = Api::Module::LegacyModuleAbi<createModule>;
static const echoion_module_dependency_v1 dependencies[]{
{
.struct_size = sizeof(echoion_module_dependency_v1),
.component_id = Api::Module::Detail::stringView("EchoionApi"),
.version_range =
Api::Module::Detail::stringView(">=2.0.0 <3.0.0"),
.abi_hash = Api::Module::Detail::stringView(
"sha256:"
"d50293d345a97e52f9844088bdd42277f566bc815a21b7636d3e053f06"
"c6c11"
"3"),
.optional = 0,
.reserved_bytes = {},
},
{
.struct_size = sizeof(echoion_module_dependency_v1),
.component_id = Api::Module::Detail::stringView("EchoionCore"),
.version_range =
Api::Module::Detail::stringView(">=2.0.0 <3.0.0"),
.abi_hash = Api::Module::Detail::stringView(
"sha256:"
"9cb668e2a502dcfe02d145ed63635d63619732d77ff574968583438270"
"5e8d2"
"1"),
.optional = 0,
.reserved_bytes = {},
},
};
static const echoion_module_descriptor_v1 descriptor{
.struct_size = sizeof(echoion_module_descriptor_v1),
.abi_version = ECHOION_MODULE_ABI_VERSION,
.component_id = Api::Module::Detail::stringView(
"EchoionPluginUrlShortenerInternal"),
.version_major = ECHOION_COMPONENT_VERSION_MAJOR,
.version_minor = ECHOION_COMPONENT_VERSION_MINOR,
.version_patch = ECHOION_COMPONENT_VERSION_PATCH,
.version_prerelease = {},
.abi_hash = Api::Module::Detail::stringView(
"sha256:"
"40a9d5a3cd47bd0bb02cb38fb530ce0fc0d59f813749565a1d7fcfdabbb536"
"88"),
.dependencies = dependencies,
.dependency_count = std::size(dependencies),
.activation_policy = ECHOION_ACTIVATION_RELOADABLE_V1,
.api = &Bridge::api,
.reserved = {},
};
return descriptor;
}
} // namespace Echoion::Plugins::ShortUrl } // namespace Echoion::Plugins::ShortUrl
extern "C" { extern "C" {
const Void::Plugin::ModuleDescriptor* echoion_module_query() const Void::Plugin::ModuleDescriptor *echoion_module_query()
{ {
return &Echoion::Plugins::ShortUrl::moduleDescriptor(); return &Echoion::Plugins::ShortUrl::moduleDescriptor();
} }
void* void_plugin_create() const echoion_module_descriptor_v1 *echoion_module_abi_query()
{
return &Echoion::Plugins::ShortUrl::moduleAbiDescriptor();
}
void *void_plugin_create()
{ {
return std::make_unique< return std::make_unique<
Echoion::Plugins::ShortUrl::InternalShortenerPlugin>() Echoion::Plugins::ShortUrl::InternalShortenerPlugin>()
.release(); .release();
} }
void void_plugin_destroy(void* instance) void void_plugin_destroy(void *instance)
{ {
std::unique_ptr<Echoion::Plugins::ShortUrl::InternalShortenerPlugin>{ std::unique_ptr<Echoion::Plugins::ShortUrl::InternalShortenerPlugin>{
static_cast<Echoion::Plugins::ShortUrl::InternalShortenerPlugin*>( static_cast<Echoion::Plugins::ShortUrl::InternalShortenerPlugin *>(
instance)}; instance)};
} }
@@ -438,16 +531,16 @@ Void::Plugin::PluginInfo void_plugin_info()
}; };
} }
void void_plugin_configure(void* instance, const char* config) void void_plugin_configure(void *instance, const char *config)
{ {
static_cast<Echoion::Plugins::ShortUrl::InternalShortenerPlugin*>(instance) static_cast<Echoion::Plugins::ShortUrl::InternalShortenerPlugin *>(instance)
->applyConfig(config); ->applyConfig(config);
} }
int void_plugin_ready(void* instance) int void_plugin_ready(void *instance)
{ {
const auto health = const auto health =
static_cast<Echoion::Plugins::ShortUrl::InternalShortenerPlugin*>( static_cast<Echoion::Plugins::ShortUrl::InternalShortenerPlugin *>(
instance) instance)
->health(); ->health();
return health.status == Void::ShortUrl::HealthStatus::healthy || return health.status == Void::ShortUrl::HealthStatus::healthy ||
@@ -456,13 +549,13 @@ int void_plugin_ready(void* instance)
: 1; : 1;
} }
Void::Service::IService* void_plugin_service(void* instance) Void::Service::IService *void_plugin_service(void *instance)
{ {
auto* plugin = auto *plugin =
static_cast<Echoion::Plugins::ShortUrl::InternalShortenerPlugin*>( static_cast<Echoion::Plugins::ShortUrl::InternalShortenerPlugin *>(
instance); instance);
return static_cast<Void::Service::IService*>( return static_cast<Void::Service::IService *>(
static_cast<Void::ShortUrl::IShortener*>(plugin)); static_cast<Void::ShortUrl::IShortener *>(plugin));
} }
} // extern "C" } // extern "C"