Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-07-25 23:44:48 +03:00
1 parent 639362fbf5
commit bdd69f0aad
101 files changed
+22691 -531

No files matched your search

+137
View File
@@ -0,0 +1,137 @@
# Echoion releases on Gitea
Echoion release builds run only through `scripts/release.sh`, whose default
mode builds, tests, validates, and packages inside
`containers/release.Dockerfile`. The runner host only checks out sources and
controls Docker; the workflow never starts `echoiond`.
## One-time Gitea setup
Register exactly one trusted Linux AMD64 Actions runner with the
`echoion-release` label and Docker access. Using one runner serializes release
and feed writes on Gitea versions that do not implement workflow
`concurrency`. Do not attach this label to runners serving untrusted
repositories. The runner host needs Bash, Git with SSH-signature support,
OpenSSH client tools, Python 3.10 or newer, OpenSSL with Ed25519 support,
coreutils, and Docker. The release builder itself remains containerized.
The Docker-capable runner executes only protected `main` pushes, manual runs,
scheduled nightlies, and signed release tags. The container CI workflow does
not run for pull requests because contributor-controlled scripts must not
receive a privileged Docker socket or the private-submodule checkout key. If
pre-merge CI is required, register a separate ephemeral `echoion-pr` runner
without release secrets or host-level Docker access and give it a dedicated
workflow.
Enable Actions and add these repository secrets:
| Secret | Purpose |
| --- | --- |
| `RELEASE_CHECKOUT_SSH_KEY` | Read-only deploy key that can clone every private nested repository in `.gitmodules`. |
| `RELEASE_BOT_TOKEN` | PAT owned by a dedicated bot, limited to writing releases, tags, and the `release-feed` branch in this repository. |
| `RELEASE_TAG_ALLOWED_SIGNERS` | Complete OpenSSH `allowed_signers` lines for maintainers allowed to publish `v*` tags. |
| `RELEASE_FEED_ED25519_PRIVATE_KEY` | PEM private key matching `release-keys/echoion-release-2026-07.pub.pem`. Preserve its newlines. |
The release PAT must not be shared with checkout of nested repositories. The
feed signing key must not be stored in Git, runner images, Actions variables,
or release assets.
Create an orphan `release-feed` branch containing a tracked `feeds/`
directory, then protect it so only the release bot can push. Protect the `v*`
tag pattern so only the release maintainers represented by
`RELEASE_TAG_ALLOWED_SIGNERS` can create, update, or delete matching tags. The
workflow requires the exact `v*` rule to have an explicit non-empty user or
team allowlist. Gitea uses the same allowlist for tag creation and later tag
changes; when immutable release tags are required, add a server-side
pre-receive policy that rejects updates and deletion after creation. Protect
`main` in the normal way.
The updater feed URL is:
```text
https://<gitea>/<owner>/<repo>/raw/branch/release-feed/feeds/echoion-runtime.json
```
The embedded updater trust configuration is represented by
`release-keys/official-update-keys.json`. `scripts/release.sh` validates and
embeds that JSON automatically. Release workflows also pass the HTTPS
`release-feed` branch URL through `--official-update-feed-url`, so a fresh
installation has a signed official source without operator-side duplication.
## Stable and beta releases
Create an annotated SSH-signed tag. A version without a prerelease suffix goes
to `stable`; any strict SemVer prerelease goes to `beta`.
```bash
git config gpg.format ssh
git config user.signingkey ~/.ssh/echoion-release-maintainer.pub
git tag -s -a v1.2.3 -m 'Echoion 1.2.3'
git push origin v1.2.3
```
`.gitea/workflows/release.yml` rejects a lightweight tag, a non-SSH
signature, an untrusted signer, a repository without the exact `v*` protected
tag rule and explicit allowlist, a non-SemVer name, an event object unrelated
to the tag, or a checkout whose commit differs from the signed tag target.
Release notes contain the signed tag subject and body but not its SSH signature
armor.
The workflow creates or resumes a draft, replaces incomplete draft assets,
uploads every file in `dist/`, downloads every asset through Gitea, checks
its size and SHA-256, and only then publishes. A rerun against an already
published release is read-only and succeeds only when all remote assets still
match. The signed aggregate feed is committed after release publication; a
feed failure can therefore be retried without replacing a published release.
## Nightly releases
`.gitea/workflows/nightly.yml` runs at 02:17 UTC and can also be dispatched
manually. Nightly versions use
`0.0.0-nightly.YYYYMMDD.RUN_NUMBER`, publish as prereleases on the `nightly`
channel, and keep the newest 14 Gitea releases. The aggregate feed also keeps
the newest 14 distinct nightly versions while retaining stable and beta
records.
Every aggregate envelope expires 45 days after generation. Scheduled
nightlies normally refresh it daily. Alert when the feed branch has not
advanced for more than seven days, and treat 30 days without a successful
signing run as urgent.
## Feed key custody and rotation
The active public key id is `echoion-release-2026-07`. To rotate, generate the
private key on a trusted operator machine:
```bash
umask 077
openssl genpkey -algorithm ED25519 -out echoion-release-YYYY-MM.pem
openssl pkey -in echoion-release-YYYY-MM.pem -pubout \
-out echoion-release-YYYY-MM.pub.pem
```
Add the new public key to official builds before signing any feed with it.
Keep the old public key embedded for at least one full update lifetime. During
the first signing run with the new key, pass each prior envelope key explicitly
to `aggregate_update_feed.py` as
`--trusted-existing-key OLD_KEY_ID=OLD_PUBLIC_KEY_PATH`; this permits only
verification of the old envelope and never selects the old key for signing.
Update the signing key id and public-key paths in both release workflows, add
the old-key verification argument while an old envelope may exist, and replace
the private-key secret. The merger verifies the newly generated signature
against the new committed public key before writing either output. Never print
the private key or pass it as a command-line argument.
## Recovery rules
- A failed build creates no Gitea release.
- A failed upload leaves a draft. Rerun the same workflow to replace the
partial draft assets.
- A failed verification never publishes the draft.
- A published release with mismatched assets is immutable; investigate and
create a new version instead of replacing it.
- A failed feed push leaves the published release available but undiscoverable
to auto-update. Rerun the workflow; publication verification is idempotent
and the feed step will run again.
- Never edit `release-feed` manually. The merger verifies the existing
Ed25519 envelope before using any prior entries.
@@ -0,0 +1,3 @@
-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEASj3V/xDWSJ37MwLjhyZ0MZPwj/DoJUEWZdYSv+R5NNI=
-----END PUBLIC KEY-----
@@ -0,0 +1,6 @@
[
{
"id": "echoion-release-2026-07",
"ed25519": "Sj3V/xDWSJ37MwLjhyZ0MZPwj/DoJUEWZdYSv+R5NNI="
}
]
+50
View File
@@ -0,0 +1,50 @@
name: Container CI
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
jobs:
release-build:
runs-on: echoion-release
steps:
- name: Check out source and nested repositories
uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with:
fetch-depth: 0
submodules: recursive
ssh-key: ${{ secrets.RELEASE_CHECKOUT_SSH_KEY }}
persist-credentials: false
- name: Verify runner isolation prerequisites
run: |
set -eu
test "$(uname -s)" = Linux
docker version
- name: Build, test, and package without starting Echoion
env:
CI_VERSION: 0.0.0-ci.${{ gitea.run_number }}.${{ gitea.run_attempt }}
run: |
set -eu
scripts/release.sh --version "$CI_VERSION"
- name: Test release control-plane scripts
run: |
set -eu
bash scripts/tests/test-gitea-tag-verification.sh
docker run --rm --network none \
--volume "$PWD:/workspace:ro" \
--workdir /workspace \
echoion-release-builder:gcc-16.1.0 \
python3 scripts/tests/test_aggregate_update_feed.py
docker run --rm --network none \
--volume "$PWD:/workspace:ro" \
--workdir /workspace \
echoion-release-builder:gcc-16.1.0 \
python3 scripts/tests/test_gitea_release.py
+158
View File
@@ -0,0 +1,158 @@
name: Nightly release
on:
schedule:
- cron: '17 2 * * *'
workflow_dispatch:
permissions:
contents: read
jobs:
publish-nightly:
runs-on: echoion-release
steps:
- name: Check out main and nested repositories
uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with:
ref: main
fetch-depth: 0
submodules: recursive
ssh-key: ${{ secrets.RELEASE_CHECKOUT_SSH_KEY }}
persist-credentials: false
- name: Derive the nightly identity
shell: bash
env:
SERVER_URL: ${{ gitea.server_url }}
REPOSITORY: ${{ gitea.repository }}
RUN_NUMBER: ${{ gitea.run_number }}
run: |
set -euo pipefail
date_id=$(date -u +%Y%m%d)
version="0.0.0-nightly.${date_id}.${RUN_NUMBER}"
tag="nightly-${date_id}-${RUN_NUMBER}"
artifact="echoion-${version}-linux-x86_64.tar.zst"
url="${SERVER_URL}/${REPOSITORY}/releases/download/${tag}/${artifact}"
feed_url="${SERVER_URL}/${REPOSITORY}/raw/branch/release-feed/feeds/echoion-runtime.json"
python3 scripts/validate-semver.py "$version"
{
printf 'RELEASE_TAG=%s\n' "$tag"
printf 'RELEASE_VERSION=%s\n' "$version"
printf 'RELEASE_CHANNEL=nightly\n'
printf 'RELEASE_PRERELEASE=true\n'
printf 'RELEASE_ARTIFACT_URL=%s\n' "$url"
printf 'RELEASE_FEED_URL=%s\n' "$feed_url"
printf 'RELEASE_TARGET=%s\n' "$(git rev-parse HEAD)"
} >>"$GITHUB_ENV"
- name: Build and test the dynamic nightly in Docker
shell: bash
run: |
set -euo pipefail
scripts/release.sh \
--version "$RELEASE_VERSION" \
--update-url "$RELEASE_ARTIFACT_URL" \
--official-update-feed-url "$RELEASE_FEED_URL" \
--update-channel nightly \
--update-valid-days 45
{
printf 'Automated nightly from %s.\n\n' "$RELEASE_TARGET"
printf 'This prerelease is retained for fourteen nightly runs.\n'
} >"$RUNNER_TEMP/release-notes.md"
- name: Create draft, upload, download-verify, and publish
shell: bash
env:
GITEA_RELEASE_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }}
API_URL: ${{ gitea.api_url }}
REPOSITORY: ${{ gitea.repository }}
run: |
set -euo pipefail
owner=${REPOSITORY%%/*}
repo=${REPOSITORY#*/}
python3 scripts/gitea_release.py \
--api-url "$API_URL" \
publish \
--owner "$owner" \
--repo "$repo" \
--tag "$RELEASE_TAG" \
--target "$RELEASE_TARGET" \
--name "Echoion nightly $RELEASE_VERSION" \
--body-file "$RUNNER_TEMP/release-notes.md" \
--artifacts dist \
--prerelease
- name: Retain fourteen Gitea nightly releases
shell: bash
env:
GITEA_RELEASE_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }}
API_URL: ${{ gitea.api_url }}
REPOSITORY: ${{ gitea.repository }}
run: |
set -euo pipefail
owner=${REPOSITORY%%/*}
repo=${REPOSITORY#*/}
python3 scripts/gitea_release.py \
--api-url "$API_URL" \
prune-nightlies \
--owner "$owner" \
--repo "$repo" \
--tag-prefix nightly- \
--keep 14 \
--protect-tag "$RELEASE_TAG"
- name: Check out the aggregate feed branch
uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with:
ref: release-feed
path: feed-state
token: ${{ secrets.RELEASE_BOT_TOKEN }}
fetch-depth: 1
- name: Sign and push the aggregate feed last
shell: bash
env:
FEED_PRIVATE_KEY: ${{ secrets.RELEASE_FEED_ED25519_PRIVATE_KEY }}
run: |
set -euo pipefail
key="$RUNNER_TEMP/echoion-release-2026-07.pem"
payload="$RUNNER_TEMP/echoion-runtime.payload.json"
envelope="$RUNNER_TEMP/echoion-runtime.json"
trap 'rm -f -- "$key" "$payload" "$envelope"' EXIT
umask 077
printf '%s\n' "$FEED_PRIVATE_KEY" >"$key"
chmod 0600 "$key"
openssl pkey -in "$key" -noout
mkdir -p feed-state/feeds
existing=()
if [[ -s feed-state/feeds/echoion-runtime.json ]]; then
existing+=(
--existing-envelope feed-state/feeds/echoion-runtime.json
)
fi
python3 scripts/aggregate_update_feed.py \
--new-payload \
"dist/echoion-${RELEASE_VERSION}-linux-x86_64.update-payload.json" \
"${existing[@]}" \
--public-key \
.gitea/release-keys/echoion-release-2026-07.pub.pem \
--private-key "$key" \
--key-id echoion-release-2026-07 \
--valid-days 45 \
--nightly-retention 14 \
--output-payload "$payload" \
--output-envelope "$envelope"
install -m 0644 "$payload" \
feed-state/feeds/echoion-runtime.payload.json
install -m 0644 "$envelope" feed-state/feeds/echoion-runtime.json
git -C feed-state config user.name 'Echoion Release Bot'
git -C feed-state config user.email 'release-bot@echoion.invalid'
git -C feed-state add \
feeds/echoion-runtime.json feeds/echoion-runtime.payload.json
if git -C feed-state diff --cached --quiet; then
exit 0
fi
git -C feed-state commit -m \
"Feed: nightly ${RELEASE_VERSION}"
git -C feed-state push origin HEAD:release-feed
+180
View File
@@ -0,0 +1,180 @@
name: Signed release
on:
push:
tags:
- v*
permissions:
contents: read
jobs:
publish:
runs-on: echoion-release
steps:
- name: Check out the signed tag
uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with:
ref: ${{ gitea.ref }}
fetch-depth: 0
submodules: recursive
ssh-key: ${{ secrets.RELEASE_CHECKOUT_SSH_KEY }}
persist-credentials: false
- name: Verify protected annotated SSH tag
shell: bash
env:
TAG: ${{ gitea.ref_name }}
EXPECTED_EVENT_SHA: ${{ gitea.sha }}
EXPECTED_REF: ${{ gitea.ref }}
EXPECTED_REF_TYPE: ${{ gitea.ref_type }}
TAG_ALLOWED_SIGNERS: ${{ secrets.RELEASE_TAG_ALLOWED_SIGNERS }}
GITEA_RELEASE_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }}
API_URL: ${{ gitea.api_url }}
REPOSITORY: ${{ gitea.repository }}
run: |
set -euo pipefail
test "$EXPECTED_REF_TYPE" = tag
test "$EXPECTED_REF" = "refs/tags/$TAG"
allowed_signers="$RUNNER_TEMP/echoion-release-allowed-signers"
trap 'rm -f -- "$allowed_signers"' EXIT
umask 077
printf '%s\n' "$TAG_ALLOWED_SIGNERS" >"$allowed_signers"
test -s "$allowed_signers"
target_commit=$(
scripts/verify-gitea-release-tag.sh \
--tag "$TAG" \
--event-sha "$EXPECTED_EVENT_SHA" \
--allowed-signers "$allowed_signers" \
--notes-output "$RUNNER_TEMP/release-notes.md"
)
printf 'RELEASE_TARGET=%s\n' "$target_commit" >>"$GITHUB_ENV"
owner=${REPOSITORY%%/*}
repo=${REPOSITORY#*/}
python3 scripts/gitea_release.py \
--api-url "$API_URL" \
verify-tag-protection \
--owner "$owner" \
--repo "$repo" \
--required-pattern 'v*'
- name: Derive the stable or beta release
shell: bash
env:
TAG: ${{ gitea.ref_name }}
SERVER_URL: ${{ gitea.server_url }}
REPOSITORY: ${{ gitea.repository }}
run: |
set -euo pipefail
version=${TAG#v}
test "$version" != "$TAG"
python3 scripts/validate-semver.py "$version"
channel=stable
prerelease=false
if [[ "$version" == *-* ]]; then
channel=beta
prerelease=true
fi
artifact="echoion-${version}-linux-x86_64.tar.zst"
url="${SERVER_URL}/${REPOSITORY}/releases/download/${TAG}/${artifact}"
feed_url="${SERVER_URL}/${REPOSITORY}/raw/branch/release-feed/feeds/echoion-runtime.json"
{
printf 'RELEASE_TAG=%s\n' "$TAG"
printf 'RELEASE_VERSION=%s\n' "$version"
printf 'RELEASE_CHANNEL=%s\n' "$channel"
printf 'RELEASE_PRERELEASE=%s\n' "$prerelease"
printf 'RELEASE_ARTIFACT_URL=%s\n' "$url"
printf 'RELEASE_FEED_URL=%s\n' "$feed_url"
} >>"$GITHUB_ENV"
- name: Build and test the dynamic release in Docker
shell: bash
run: |
set -euo pipefail
scripts/release.sh \
--version "$RELEASE_VERSION" \
--update-url "$RELEASE_ARTIFACT_URL" \
--official-update-feed-url "$RELEASE_FEED_URL" \
--update-channel "$RELEASE_CHANNEL" \
--update-valid-days 45
- name: Create draft, upload, download-verify, and publish
shell: bash
env:
GITEA_RELEASE_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }}
API_URL: ${{ gitea.api_url }}
REPOSITORY: ${{ gitea.repository }}
run: |
set -euo pipefail
owner=${REPOSITORY%%/*}
repo=${REPOSITORY#*/}
prerelease=()
if [[ "$RELEASE_PRERELEASE" = true ]]; then
prerelease+=(--prerelease)
fi
python3 scripts/gitea_release.py \
--api-url "$API_URL" \
publish \
--owner "$owner" \
--repo "$repo" \
--tag "$RELEASE_TAG" \
--target "$RELEASE_TARGET" \
--name "Echoion $RELEASE_VERSION" \
--body-file "$RUNNER_TEMP/release-notes.md" \
--artifacts dist \
"${prerelease[@]}"
- name: Check out the aggregate feed branch
uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with:
ref: release-feed
path: feed-state
token: ${{ secrets.RELEASE_BOT_TOKEN }}
fetch-depth: 1
- name: Sign and push the aggregate feed last
shell: bash
env:
FEED_PRIVATE_KEY: ${{ secrets.RELEASE_FEED_ED25519_PRIVATE_KEY }}
run: |
set -euo pipefail
key="$RUNNER_TEMP/echoion-release-2026-07.pem"
payload="$RUNNER_TEMP/echoion-runtime.payload.json"
envelope="$RUNNER_TEMP/echoion-runtime.json"
trap 'rm -f -- "$key" "$payload" "$envelope"' EXIT
umask 077
printf '%s\n' "$FEED_PRIVATE_KEY" >"$key"
chmod 0600 "$key"
openssl pkey -in "$key" -noout
mkdir -p feed-state/feeds
existing=()
if [[ -s feed-state/feeds/echoion-runtime.json ]]; then
existing+=(
--existing-envelope feed-state/feeds/echoion-runtime.json
)
fi
python3 scripts/aggregate_update_feed.py \
--new-payload \
"dist/echoion-${RELEASE_VERSION}-linux-x86_64.update-payload.json" \
"${existing[@]}" \
--public-key \
.gitea/release-keys/echoion-release-2026-07.pub.pem \
--private-key "$key" \
--key-id echoion-release-2026-07 \
--valid-days 45 \
--nightly-retention 14 \
--output-payload "$payload" \
--output-envelope "$envelope"
install -m 0644 "$payload" \
feed-state/feeds/echoion-runtime.payload.json
install -m 0644 "$envelope" feed-state/feeds/echoion-runtime.json
git -C feed-state config user.name 'Echoion Release Bot'
git -C feed-state config user.email 'release-bot@echoion.invalid'
git -C feed-state add \
feeds/echoion-runtime.json feeds/echoion-runtime.payload.json
if git -C feed-state diff --cached --quiet; then
exit 0
fi
git -C feed-state commit -m \
"Feed: ${RELEASE_CHANNEL} ${RELEASE_VERSION}"
git -C feed-state push origin HEAD:release-feed