Author SHA1 Message Date
faumaray 1ff935b727 Release version
Container CI / release-build (push) Has been cancelled
Signed release / publish (push) Successful in 17m39s
2026-07-26 05:25:43 +03:00
faumaray d5db7f2d2a Nightly: derive version from releases
Container CI / release-build (push) Has been cancelled
2026-07-26 05:23:18 +03:00
6 changed files with 238 additions and 31 deletions

No files matched your search

+13 -10
View File
@@ -123,16 +123,19 @@ 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. Gitea materializes a missing `nightly-*` Git tag only when the
download-verified draft is published; the publisher then verifies its commit
immediately and never moves an existing tag whose target differs. Stable and
beta publishing require their signed tag to exist before creating a draft. If
`nightly-*` is protected separately, allow the release bot to create and delete
it.
manually. The highest published `vMAJOR.MINOR.PATCH` release supplies the next
patch as `MAJOR.MINOR.(PATCH+1)-nightly.YYYYMMDD.RUN_NUMBER`. With no published
semantic release, nightlies use the root CMake
`project(Echoion VERSION x.y.z)` value without incrementing it. Drafts, failed
publications, and `nightly-*` releases do not affect the base. Nightlies use the
`nightly` channel, publish as prereleases, and keep the newest 14 Gitea
releases. The aggregate feed also keeps the newest 14 distinct nightly versions
while retaining stable and beta records. Gitea materializes a missing
`nightly-*` Git tag only when the download-verified draft is published; the
publisher then verifies its commit immediately and never moves an existing tag
whose target differs. Stable and beta publishing require their signed tag to
exist before creating a draft. If `nightly-*` is protected separately, allow
the release bot to create and delete it.
Every aggregate envelope expires 45 days after generation. Scheduled
nightlies normally refresh it daily. Alert when the feed branch has not
+14 -1
View File
@@ -36,13 +36,26 @@ jobs:
- name: Derive the nightly identity
shell: bash
env:
GITEA_RELEASE_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }}
API_URL: ${{ gitea.api_url }}
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}"
owner=${REPOSITORY%%/*}
repo=${REPOSITORY#*/}
version=$(
python3 scripts/gitea_release.py \
--api-url "$API_URL" \
derive-nightly-version \
--owner "$owner" \
--repo "$repo" \
--cmake-file CMakeLists.txt \
--date-id "$date_id" \
--run-number "$RUN_NUMBER"
)
tag="nightly-${date_id}-${RUN_NUMBER}"
artifact="echoion-${version}-linux-x86_64.tar.zst"
url="${SERVER_URL}/${REPOSITORY}/releases/download/${tag}/${artifact}"
+1 -1
View File
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 4.0.0)
project(Echoion VERSION 1.0.0 LANGUAGES CXX)
project(Echoion VERSION 1.0.7 LANGUAGES CXX)
include(GNUInstallDirs)
include(cmake/DependencyLock.cmake)
+1 -1
View File
@@ -4,7 +4,7 @@
# and implements IPluginInterface with the reusable VoidTeamspeak client.
cmake_minimum_required(VERSION 4.0.0)
project(EchoionStandalone VERSION 1.0.0 LANGUAGES CXX)
project(EchoionStandalone VERSION 1.0.7 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 26)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
+109 -18
View File
@@ -4,6 +4,7 @@
from __future__ import annotations
import argparse
from datetime import datetime
import hashlib
import http.client
import json
@@ -23,6 +24,22 @@ from urllib.request import HTTPRedirectHandler, Request, build_opener
MAX_JSON_BYTES = 8 * 1024 * 1024
UPLOAD_CHUNK_BYTES = 1024 * 1024
SAFE_NAME = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._+-]{0,255}$")
RELEASE_TAG_VERSION = re.compile(
r"^v(0|[1-9][0-9]*)\."
r"(0|[1-9][0-9]*)\."
r"(0|[1-9][0-9]*)"
r"(?:-((?:0|[1-9][0-9]*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*)"
r"(?:\.(?:0|[1-9][0-9]*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*))*))?"
r"(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$"
)
CMAKE_PROJECT_VERSION = re.compile(
r"\bproject\s*\(\s*Echoion\b[^)]*?\bVERSION\s+"
r"(0|[1-9][0-9]*)\."
r"(0|[1-9][0-9]*)\."
r"(0|[1-9][0-9]*)(?=\s|\))",
re.IGNORECASE | re.DOTALL,
)
MAX_CMAKE_BYTES = 1024 * 1024
class NoRedirect(HTTPRedirectHandler):
@@ -488,23 +505,7 @@ def publish(arguments: argparse.Namespace, api: GiteaApi) -> None:
def prune_nightlies(arguments: argparse.Namespace, api: GiteaApi) -> None:
base = repository_path(arguments.owner, arguments.repo)
releases: list[dict[str, Any]] = []
page = 1
while True:
query = urlencode({"limit": 50, "page": page})
_, batch = api.request_json(
"GET", f"{base}/releases?{query}", allowed_statuses=(200,)
)
if not isinstance(batch, list) or not all(
isinstance(release, dict) for release in batch
):
fail("Gitea returned an invalid release page")
releases.extend(batch)
if len(batch) < 50:
break
page += 1
if page > 1000:
fail("Gitea release pagination exceeded the safety limit")
releases = list_releases(api, base)
nightlies = [
release
for release in releases
@@ -602,6 +603,87 @@ def verify_tag_protection(arguments: argparse.Namespace, api: GiteaApi) -> None:
)
def list_releases(api: GiteaApi, base: str) -> list[dict[str, Any]]:
releases: list[dict[str, Any]] = []
page = 1
while True:
query = urlencode({"limit": 50, "page": page})
_, batch = api.request_json(
"GET", f"{base}/releases?{query}", allowed_statuses=(200,)
)
if not isinstance(batch, list) or not all(
isinstance(release, dict) for release in batch
):
fail("Gitea returned an invalid release page")
releases.extend(batch)
if len(batch) < 50:
return releases
page += 1
if page > 1000:
fail("Gitea release pagination exceeded the safety limit")
def cmake_project_version(path: Path) -> tuple[int, int, int]:
try:
metadata = path.lstat()
if (
not stat.S_ISREG(metadata.st_mode)
or path.is_symlink()
or metadata.st_size > MAX_CMAKE_BYTES
):
fail("the CMake project file must be a small regular file")
content = path.read_text(encoding="utf-8")
except (OSError, UnicodeError) as error:
fail(f"cannot read the CMake project version: {error}")
matches = CMAKE_PROJECT_VERSION.findall(content)
if len(matches) != 1:
fail("the CMake project file must declare one Echoion x.y.z version")
major, minor, patch = matches[0]
return int(major), int(minor), int(patch)
def derive_nightly_version(arguments: argparse.Namespace, api: GiteaApi) -> None:
if not re.fullmatch(r"[0-9]{8}", arguments.date_id):
fail("--date-id must use UTC YYYYMMDD format")
try:
datetime.strptime(arguments.date_id, "%Y%m%d")
except ValueError as error:
fail(f"--date-id is not a valid calendar date: {error}")
if not re.fullmatch(r"[1-9][0-9]*", arguments.run_number):
fail("--run-number must be a positive integer")
base = repository_path(arguments.owner, arguments.repo)
released_versions: list[tuple[int, int, int]] = []
for release in list_releases(api, base):
if (
release.get("draft") is not False
or not isinstance(release.get("published_at"), str)
or not release["published_at"]
):
continue
tag = release.get("tag_name")
match = (
RELEASE_TAG_VERSION.fullmatch(tag)
if isinstance(tag, str)
else None
)
if match is not None:
released_versions.append(
(int(match.group(1)), int(match.group(2)), int(match.group(3)))
)
if released_versions:
major, minor, patch = max(released_versions)
patch += 1
else:
major, minor, patch = cmake_project_version(arguments.cmake_file)
version = (
f"{major}.{minor}.{patch}-nightly."
f"{arguments.date_id}.{arguments.run_number}"
)
print(version)
def parser() -> argparse.ArgumentParser:
result = argparse.ArgumentParser(description=__doc__)
result.add_argument("--api-url", required=True)
@@ -637,6 +719,13 @@ def parser() -> argparse.ArgumentParser:
protection_parser.add_argument("--owner", required=True)
protection_parser.add_argument("--repo", required=True)
protection_parser.add_argument("--required-pattern", default="v*")
nightly_version_parser = subparsers.add_parser("derive-nightly-version")
nightly_version_parser.add_argument("--owner", required=True)
nightly_version_parser.add_argument("--repo", required=True)
nightly_version_parser.add_argument("--cmake-file", type=Path, required=True)
nightly_version_parser.add_argument("--date-id", required=True)
nightly_version_parser.add_argument("--run-number", required=True)
return result
@@ -658,8 +747,10 @@ def main() -> None:
publish(arguments, api)
elif arguments.command == "prune-nightlies":
prune_nightlies(arguments, api)
else:
elif arguments.command == "verify-tag-protection":
verify_tag_protection(arguments, api)
else:
derive_nightly_version(arguments, api)
if __name__ == "__main__":
+100
View File
@@ -579,6 +579,106 @@ class GiteaReleaseTest(unittest.TestCase):
self.assertNotEqual(rejected.returncode, 0)
self.assertIn("empty allowlist", rejected.stderr)
def test_nightly_version_uses_next_patch_after_published_release(self) -> None:
cmake_file = Path(self.temporary.name, "CMakeLists.txt")
cmake_file.write_text(
"project(Echoion VERSION 1.0.0 LANGUAGES CXX)\n",
encoding="utf-8",
)
releases = [
("v1.9.9", False, "2026-07-20T00:00:00Z"),
("v2.4.0-beta.1", False, "2026-07-19T00:00:00Z"),
("v9.0.0", True, None),
("nightly-20260726-16", False, "2026-07-26T00:00:00Z"),
]
for release_id, (tag, draft, published_at) in enumerate(releases, 1):
self.server.state.releases[release_id] = {
"id": release_id,
"tag_name": tag,
"target_commitish": "0123456789abcdef0123456789abcdef01234567",
"name": tag,
"body": "",
"prerelease": "-" in tag,
"draft": draft,
"assets": [],
"created_at": f"2026-07-{release_id:02d}T00:00:00Z",
"published_at": published_at,
}
completed = self.run_script(
"derive-nightly-version",
"--owner",
"Void",
"--repo",
"Echoion",
"--cmake-file",
os.fspath(cmake_file),
"--date-id",
"20260726",
"--run-number",
"17",
)
self.assertEqual(
completed.stdout.strip(),
"2.4.1-nightly.20260726.17",
)
def test_nightly_version_falls_back_to_root_cmake_version(self) -> None:
cmake_file = Path(self.temporary.name, "CMakeLists.txt")
cmake_file.write_text(
"cmake_minimum_required(VERSION 4.0)\n"
"project(\n"
" Echoion\n"
" VERSION 3.2.1\n"
" LANGUAGES CXX\n"
")\n",
encoding="utf-8",
)
self.server.state.releases[1] = {
"id": 1,
"tag_name": "nightly-20260726-16",
"target_commitish": "0123456789abcdef0123456789abcdef01234567",
"name": "nightly",
"body": "",
"prerelease": True,
"draft": False,
"assets": [],
"created_at": "2026-07-26T00:00:00Z",
"published_at": "2026-07-26T00:00:00Z",
}
self.server.state.releases[2] = {
"id": 2,
"tag_name": "v9.0.0",
"target_commitish": "0123456789abcdef0123456789abcdef01234567",
"name": "failed draft",
"body": "",
"prerelease": False,
"draft": True,
"assets": [],
"created_at": "2026-07-26T00:00:00Z",
"published_at": None,
}
completed = self.run_script(
"derive-nightly-version",
"--owner",
"Void",
"--repo",
"Echoion",
"--cmake-file",
os.fspath(cmake_file),
"--date-id",
"20260727",
"--run-number",
"18",
)
self.assertEqual(
completed.stdout.strip(),
"3.2.1-nightly.20260727.18",
)
if __name__ == "__main__":
unittest.main()