From 2c8164584b49d70132ce173d4585acd7cb9d3a2e Mon Sep 17 00:00:00 2001 From: faumaray Date: Wed, 29 Jul 2026 23:45:09 +0300 Subject: [PATCH] Publish components through Gitea packages --- .gitea/RELEASING.md | 2 +- components.lock.json | 36 +++---- docs/adr/0001-paid-binary-distribution.md | 13 ++- docs/component-releases.md | 37 ++++---- scripts/release-component.sh | 111 ++++++++++++++++------ 5 files changed, 136 insertions(+), 63 deletions(-) diff --git a/.gitea/RELEASING.md b/.gitea/RELEASING.md index d1f4606..bad9a05 100644 --- a/.gitea/RELEASING.md +++ b/.gitea/RELEASING.md @@ -62,7 +62,7 @@ Enable Actions and add these repository secrets: | Secret | Purpose | | --- | --- | | `RELEASE_CHECKOUT_SSH_KEY` | Release-bot SSH key used to read every private component/dependency repository and to fast-forward the protected Echoion `release-feed` branch. | -| `RELEASE_BOT_TOKEN` | PAT owned by a dedicated bot. It needs read access to every component repository plus release/tag write access in this repository. It does not need `release-feed` write access. | +| `RELEASE_BOT_TOKEN` | PAT owned by a dedicated bot. It needs repository write scope for component releases and package write scope for the public organization registry. It does not need `release-feed` write access. | | `RELEASE_TAG_ALLOWED_SIGNERS` | Complete OpenSSH `allowed_signers` lines for maintainers allowed to publish `v*` tags. | | `RELEASE_FEED_ED25519_PUBLIC_KEY` | PEM public key matching the component-feed signing key. It verifies independently published components without exposing signing authority to the product workflow. | diff --git a/components.lock.json b/components.lock.json index e38de27..3717aeb 100644 --- a/components.lock.json +++ b/components.lock.json @@ -4,74 +4,74 @@ "components": { "EchoionApi": { "repository": "Void/EchoionApi", - "revision": "21e158fae0e85849e154f31d43d9310ac9c66243", + "revision": "fccdb2e159c114a3d6709cbd9b53ce41876c273d", "componentVersion": "2.0.0", "abiHash": "sha256:d50293d345a97e52f9844088bdd42277f566bc815a21b7636d3e053f06c6c113", - "sourceTreeHash": "git-sha1:c2f0a0f1eb8165e74eb6c7f05e14f8dd45d43a8f", + "sourceTreeHash": "git-sha1:0a6ba08c80ca5a6f2b00756ad7e5daa20eb57edb", "artifactIdentity": "echoion-api-2.0.0-linux-x86_64" }, "EchoionHost": { "repository": "Void/EchoionHost", - "revision": "0547b86eba696ac0f06005408fd91895cde4bd0a", + "revision": "a1d02147966a3c2c5f27f27d97179c22f49c9125", "componentVersion": "2.0.0", "abiHash": "sha256:84517536db29851cc78eeb09e8bf3aae71a82d42772fe1f2abd4edbf183f20fc", - "sourceTreeHash": "git-sha1:1eddb72d93e377f84eb877a7a4cd5cb61175c8bd", + "sourceTreeHash": "git-sha1:c7f47784ba081ec105694c24c87dfb02b4288f46", "artifactIdentity": "echoion-host-2.0.0-linux-x86_64" }, "EchoionCore": { "repository": "Void/EchoionCore", - "revision": "d456257d0cb6ed01e55aefa445c4d9b55e98353e", + "revision": "16d9a667eb0174002cf6957e1918c8a3a5c5a257", "componentVersion": "2.0.0", "abiHash": "sha256:9cb668e2a502dcfe02d145ed63635d63619732d77ff5749685834382705e8d21", - "sourceTreeHash": "git-sha1:18f7e28f0f0642a5873850113adb00a855559c91", + "sourceTreeHash": "git-sha1:a34c4822215e0f9d1bf50540c4af3eb79ea8cf98", "artifactIdentity": "echoion-core-2.0.0-linux-x86_64" }, "EchoionWeb": { "repository": "Void/EchoionWeb", - "revision": "a8b91b15c8f0a5dc48d199b693fbcebb4d5b5f2b", + "revision": "41ebd5988e4f20525659c4b64a0d1c9adb4b7584", "componentVersion": "2.0.0", "abiHash": "sha256:e1f826ddb06caadc394af7a3db27af32789a7e580cde6ee516edd0ebda2a5c9f", - "sourceTreeHash": "git-sha1:fe024057d83f45f90eedbda79d6220e02768eeed", + "sourceTreeHash": "git-sha1:652423aadc955886cff70d7881853584a3b5b5ea", "artifactIdentity": "echoion-web-2.0.0-linux-x86_64" }, "EchoionStandalone": { "repository": "Void/EchoionStandalone", - "revision": "5417e342d8447f6f24feaad857bd3e148bde9d33", + "revision": "8f71775ebdc27469a853a4b39a33fd36ed972347", "componentVersion": "2.0.0", "abiHash": null, - "sourceTreeHash": "git-sha1:94116b5cc77976dbab4fe244d96faaf8be6712e8", + "sourceTreeHash": "git-sha1:75869bccff9514ccc1177bdeb7fec98cdba9bd8b", "artifactIdentity": "echoion-standalone-2.0.0-linux-x86_64" }, "EchoionUpdater": { "repository": "Void/EchoionUpdater", - "revision": "1778d89debd18341b54443d9f3fd5f7a1e6b3dfa", + "revision": "adfb06467f64428ce99c5c4bb420edb3cf944f57", "componentVersion": "2.0.0", "abiHash": null, - "sourceTreeHash": "git-sha1:78b9f63ef36ff525e53b70ddc8ff8388953714bc", + "sourceTreeHash": "git-sha1:d26b41913d08746197c905567f76826df6786d79", "artifactIdentity": "echoion-updater-2.0.0-linux-x86_64" }, "EchoionDesktop": { "repository": "Void/EchoionDesktop", - "revision": "88cfb1d443f5ec8f8e8b0c2743c24300efb0076e", + "revision": "bae23b7abcf8b204b9684af5efb3b75b05b4f851", "componentVersion": "2.0.0", "abiHash": null, - "sourceTreeHash": "git-sha1:a253e7e59647e9fd45e4fc10834bc13b25a7f080", + "sourceTreeHash": "git-sha1:abaed06e0dda9e20e529d9bfb437fe2643495fdc", "artifactIdentity": "echoion-desktop-2.0.0-linux-x86_64" }, "EchoionPluginUrlShortenerInternal": { "repository": "Void/EchoionPluginUrlShortenerInternal", - "revision": "243ebcd5994d1676ac8e8f90f19067f5277ff56f", + "revision": "44f6af37d459395c842d4ab6ba39e3bda81d8b88", "componentVersion": "2.0.0", "abiHash": "sha256:40a9d5a3cd47bd0bb02cb38fb530ce0fc0d59f813749565a1d7fcfdabbb53688", - "sourceTreeHash": "git-sha1:0cfbff6a55761a61d0b00abb203e54d911c97244", + "sourceTreeHash": "git-sha1:eae0a45a00754a4ce2f044dec4bed79de12a7939", "artifactIdentity": "echoion-plugin-url-shortener-internal-2.0.0-linux-x86_64" }, "EchoionPluginUrlShortenerExternal": { "repository": "Void/EchoionPluginUrlShortenerExternal", - "revision": "96f040cb036f4dfdb1d8103f62d498ab12b32e47", + "revision": "6a1616aa25fe2747a2c7e38cd08f616b103951b2", "componentVersion": "2.0.0", "abiHash": "sha256:6f6e445a86fc6a67e25dbd0e1f583de9f768f6f4ba88ed2f2ffe6d0540eb85ea", - "sourceTreeHash": "git-sha1:db9733d5dc0bb9ac0081765a55bc6e8f0e7619c8", + "sourceTreeHash": "git-sha1:933bdb2c1f245523de850e23bf03a1d23d2fb6df", "artifactIdentity": "echoion-plugin-url-shortener-external-2.0.0-linux-x86_64" } } diff --git a/docs/adr/0001-paid-binary-distribution.md b/docs/adr/0001-paid-binary-distribution.md index 86f37aa..9fc0f6f 100644 --- a/docs/adr/0001-paid-binary-distribution.md +++ b/docs/adr/0001-paid-binary-distribution.md @@ -28,6 +28,18 @@ Billing authorization and update integrity are separate: No billing, account, license, device, or gateway authorization code is part of the current implementation. +## Current public baseline + +Initial component artifacts are mirrored into the public `Void` organization +Generic Package Registry. This keeps downloads public after component +repositories become private and requires no additional storage service. + +Gitea package URLs are permanently public while the organization is public; +they cannot later become paywalled without breaking their original access +contract. Introduce the entitlement gateway as the distribution base before +publishing the first paid-only artifact. Existing public versions remain +public, while new signed feed entries may point to the gateway. + ## Provider options ### Stripe Billing @@ -83,4 +95,3 @@ binaries, automated updates, and paid support, but cannot prevent someone from building and running the public source. Stronger enforcement would require moving real product value into private components or a hosted service and is outside this decision. - diff --git a/docs/component-releases.md b/docs/component-releases.md index 0911903..e8708fb 100644 --- a/docs/component-releases.md +++ b/docs/component-releases.md @@ -11,22 +11,26 @@ Every runtime component publishes the same verified package to two places: 1. A release in the component's own Gitea repository. This is the provenance and maintainer-facing release after that repository becomes private. -2. An immutable object-storage key exposed through the permanent distribution - gateway: +2. An immutable public distribution key. The default deployment uses the + public `Void` organization Generic Package Registry: ```text - /// + https://git.faumaray.ru/api/packages/Void/generic/// ``` -The signed public feed refers only to the distribution URL. It never contains -Gitea credentials, object-storage credentials, presigned URLs, or private clone -URLs. Private Gitea repositories do not have independently public release -units, so public delivery must remain a separate distribution concern. + Gitea packages belong to the organization rather than a repository, so they + remain anonymously downloadable while component repositories and their + native releases are private. -The object origin should be private from its first deployment. The gateway may -allow anonymous `GET` requests initially; a future entitlement check can return -`401` or `403` at the same permanent URL without rewriting signed immutable -feed documents. +The signed public feed refers only to the distribution URL. It never contains +Gitea credentials, storage credentials, presigned URLs, or private clone URLs. +Private Gitea repositories do not have independently public release units, so +public delivery remains a separate distribution concern. + +The organization registry is the no-infrastructure public backend. A future +paid distribution gateway should use a separate permanent origin from its +first published version; immutable feed documents must not have their URLs +rewritten after signing. ## Release transaction @@ -62,13 +66,14 @@ exact value. The following Gitea Actions variables are required: - `ECHOION_RELEASE_TOOLS_REF` +- `ECHOION_DISTRIBUTION_BACKEND`, currently `gitea-generic` - `ECHOION_DISTRIBUTION_BASE_URL` - `ECHOION_FEED_BASE_URL` - `ECHOION_FEED_SIGNING_KEY_ID` -- `COMPONENT_OBJECT_STORAGE_BUCKET` +- `COMPONENT_OBJECT_STORAGE_BUCKET` only for the optional `s3` backend - `COMPONENT_OBJECT_STORAGE_ENDPOINT` when using a non-AWS S3 service -- `COMPONENT_OBJECT_STORAGE_PREFIX`, normally `components` -- `COMPONENT_OBJECT_STORAGE_REGION` +- `COMPONENT_OBJECT_STORAGE_PREFIX`, normally `components`, for S3 +- `COMPONENT_OBJECT_STORAGE_REGION` for S3 The following secrets are required in each component repository: @@ -79,8 +84,8 @@ The following secrets are required in each component repository: - `RELEASE_BOT_TOKEN` - `RELEASE_FEED_ED25519_PRIVATE_KEY` - `RELEASE_FEED_GIT_SIGNING_KEY` -- `COMPONENT_OBJECT_STORAGE_ACCESS_KEY` -- `COMPONENT_OBJECT_STORAGE_SECRET_KEY` +- `COMPONENT_OBJECT_STORAGE_ACCESS_KEY` only for S3 +- `COMPONENT_OBJECT_STORAGE_SECRET_KEY` only for S3 The Echoion product repository needs only `RELEASE_FEED_ED25519_PUBLIC_KEY` for feed verification. It must not receive diff --git a/scripts/release-component.sh b/scripts/release-component.sh index cf40c64..bd002da 100755 --- a/scripts/release-component.sh +++ b/scripts/release-component.sh @@ -16,10 +16,10 @@ configuration=$(realpath -- "$1") source "$script_dir/lib/component-ssh.sh" required_commands=( - aws cmake cmp ctest + curl find git jq @@ -46,7 +46,6 @@ required_environment=( ECHOION_FEED_PRIVATE_KEY ECHOION_FEED_REPOSITORY ECHOION_FEED_SIGNING_KEY_ID - ECHOION_OBJECT_STORAGE_BUCKET ECHOION_RELEASE_TAG_ALLOWED_SIGNERS GITEA_API_URL GITEA_RELEASE_TOKEN @@ -59,6 +58,37 @@ for variable in "${required_environment[@]}"; do fi done +distribution_backend=${ECHOION_DISTRIBUTION_BACKEND:-s3} +case "$distribution_backend" in + gitea-generic) + if [[ $GITEA_API_URL != */api/v1 ]]; then + echo "release-component: GITEA_API_URL must end in /api/v1" >&2 + exit 2 + fi + gitea_root=${GITEA_API_URL%/api/v1} + if [[ $ECHOION_DISTRIBUTION_BASE_URL != \ + "$gitea_root"/api/packages/*/generic ]]; then + echo "release-component: Gitea distribution URL must use the configured Gitea package registry" >&2 + exit 2 + fi + ;; + s3) + command -v aws >/dev/null || + { + echo "release-component: missing command: aws" >&2 + exit 2 + } + if [[ -z ${ECHOION_OBJECT_STORAGE_BUCKET:-} ]]; then + echo "release-component: ECHOION_OBJECT_STORAGE_BUCKET is required for the S3 backend" >&2 + exit 2 + fi + ;; + *) + echo "release-component: unsupported distribution backend: $distribution_backend" >&2 + exit 2 + ;; +esac + component_id=$(jq -er ' if .schemaVersion == 1 and (.componentId | type == "string" and length > 0) and @@ -258,35 +288,62 @@ archive=$(find "$dist" -maxdepth 1 -type f -name '*.tar.zst' -print) exit 1 } -object_key="${ECHOION_OBJECT_STORAGE_PREFIX:-components}/$component_id/$component_version/$(basename "$archive")" -aws_arguments=() -if [[ -n ${ECHOION_OBJECT_STORAGE_ENDPOINT:-} ]]; then - aws_arguments+=(--endpoint-url "$ECHOION_OBJECT_STORAGE_ENDPOINT") -fi -set +e -aws "${aws_arguments[@]}" s3api put-object \ - --bucket "$ECHOION_OBJECT_STORAGE_BUCKET" \ - --key "$object_key" \ - --body "$archive" \ - --if-none-match '*' >/dev/null -upload_status=$? -set -e -if ((upload_status != 0)); then - existing="$work_root/existing-archive" - aws "${aws_arguments[@]}" s3api get-object \ - --bucket "$ECHOION_OBJECT_STORAGE_BUCKET" \ - --key "$object_key" "$existing" >/dev/null - cmp -- "$archive" "$existing" || +artifact_name=$(basename "$archive") +verified="$work_root/verified-archive" +if [[ $distribution_backend == gitea-generic ]]; then + artifact_url="${ECHOION_DISTRIBUTION_BASE_URL%/}/$component_id/$component_version/$artifact_name" + upload_response="$work_root/gitea-package-upload-response" + upload_status=$( + curl --silent --show-error \ + --output "$upload_response" \ + --write-out '%{http_code}' \ + --header "Authorization: token $GITEA_RELEASE_TOKEN" \ + --upload-file "$archive" \ + "$artifact_url" + ) + if [[ $upload_status != 201 && $upload_status != 409 ]]; then + echo "release-component: Gitea package upload failed with HTTP $upload_status" >&2 + exit 1 + fi + curl --fail --silent --show-error \ + --header "Authorization: token $GITEA_RELEASE_TOKEN" \ + --output "$verified" \ + "$artifact_url" + cmp -- "$archive" "$verified" || { - echo "release-component: immutable object conflict: $object_key" >&2 + echo "release-component: immutable package conflict: $artifact_url" >&2 exit 1 } +else + object_key="${ECHOION_OBJECT_STORAGE_PREFIX:-components}/$component_id/$component_version/$artifact_name" + aws_arguments=() + if [[ -n ${ECHOION_OBJECT_STORAGE_ENDPOINT:-} ]]; then + aws_arguments+=(--endpoint-url "$ECHOION_OBJECT_STORAGE_ENDPOINT") + fi + set +e + aws "${aws_arguments[@]}" s3api put-object \ + --bucket "$ECHOION_OBJECT_STORAGE_BUCKET" \ + --key "$object_key" \ + --body "$archive" \ + --if-none-match '*' >/dev/null + upload_status=$? + set -e + if ((upload_status != 0)); then + existing="$work_root/existing-archive" + aws "${aws_arguments[@]}" s3api get-object \ + --bucket "$ECHOION_OBJECT_STORAGE_BUCKET" \ + --key "$object_key" "$existing" >/dev/null + cmp -- "$archive" "$existing" || + { + echo "release-component: immutable object conflict: $object_key" >&2 + exit 1 + } + fi + aws "${aws_arguments[@]}" s3api get-object \ + --bucket "$ECHOION_OBJECT_STORAGE_BUCKET" \ + --key "$object_key" "$verified" >/dev/null + cmp -- "$archive" "$verified" fi -verified="$work_root/verified-archive" -aws "${aws_arguments[@]}" s3api get-object \ - --bucket "$ECHOION_OBJECT_STORAGE_BUCKET" \ - --key "$object_key" "$verified" >/dev/null -cmp -- "$archive" "$verified" if [[ $channel == nightly ]]; then printf 'Automated %s nightly from %s.\n' "$component_id" "$source_sha" \