Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9401f19ad5 |
No files matched your search
+11
-5
@@ -72,10 +72,11 @@ directory, then protect it so only the release bot can push. Protect the `v*`
|
|||||||
tag pattern so only the release maintainers represented by
|
tag pattern so only the release maintainers represented by
|
||||||
`RELEASE_TAG_ALLOWED_SIGNERS` can create, update, or delete matching tags. The
|
`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
|
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
|
team allowlist. Configure it under repository **Settings → Tags → Protected
|
||||||
changes; when immutable release tags are required, add a server-side
|
tags**; a similar pattern such as `v*.*` does not satisfy the release check.
|
||||||
pre-receive policy that rejects updates and deletion after creation. Protect
|
Gitea uses the same allowlist for tag creation and later tag changes; when
|
||||||
`main` in the normal way.
|
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:
|
The updater feed URL is:
|
||||||
|
|
||||||
@@ -126,7 +127,12 @@ manually. Nightly versions use
|
|||||||
`0.0.0-nightly.YYYYMMDD.RUN_NUMBER`, publish as prereleases on the `nightly`
|
`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
|
channel, and keep the newest 14 Gitea releases. The aggregate feed also keeps
|
||||||
the newest 14 distinct nightly versions while retaining stable and beta
|
the newest 14 distinct nightly versions while retaining stable and beta
|
||||||
records.
|
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
|
Every aggregate envelope expires 45 days after generation. Scheduled
|
||||||
nightlies normally refresh it daily. Alert when the feed branch has not
|
nightlies normally refresh it daily. Alert when the feed branch has not
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ jobs:
|
|||||||
--name "Echoion nightly $RELEASE_VERSION" \
|
--name "Echoion nightly $RELEASE_VERSION" \
|
||||||
--body-file "$RUNNER_TEMP/release-notes.md" \
|
--body-file "$RUNNER_TEMP/release-notes.md" \
|
||||||
--artifacts dist \
|
--artifacts dist \
|
||||||
|
--allow-missing-draft-tag \
|
||||||
--prerelease
|
--prerelease
|
||||||
|
|
||||||
- name: Retain fourteen Gitea nightly releases
|
- name: Retain fourteen Gitea nightly releases
|
||||||
|
|||||||
@@ -326,9 +326,11 @@ def verify_release_metadata(
|
|||||||
def verify_tag_target(
|
def verify_tag_target(
|
||||||
api: GiteaApi, base: str, tag: str, expected_commit: str
|
api: GiteaApi, base: str, tag: str, expected_commit: str
|
||||||
) -> None:
|
) -> None:
|
||||||
_, document = api.request_json(
|
if not tag_target_exists(api, base, tag, expected_commit):
|
||||||
"GET", f"{base}/tags/{quote(tag, safe='')}", allowed_statuses=(200,)
|
fail("the release tag does not exist")
|
||||||
)
|
|
||||||
|
|
||||||
|
def validate_tag_target(document: Any, expected_commit: str) -> None:
|
||||||
if (
|
if (
|
||||||
not isinstance(document, dict)
|
not isinstance(document, dict)
|
||||||
or not isinstance(document.get("commit"), dict)
|
or not isinstance(document.get("commit"), dict)
|
||||||
@@ -337,6 +339,24 @@ def verify_tag_target(
|
|||||||
fail("the release tag does not target the requested commit")
|
fail("the release tag does not target the requested commit")
|
||||||
|
|
||||||
|
|
||||||
|
def tag_target_exists(
|
||||||
|
api: GiteaApi,
|
||||||
|
base: str,
|
||||||
|
tag: str,
|
||||||
|
expected_commit: str,
|
||||||
|
) -> bool:
|
||||||
|
tag_path = quote(tag, safe="")
|
||||||
|
status, document = api.request_json(
|
||||||
|
"GET",
|
||||||
|
f"{base}/tags/{tag_path}",
|
||||||
|
allowed_statuses=(200, 404),
|
||||||
|
)
|
||||||
|
if status == 404:
|
||||||
|
return False
|
||||||
|
validate_tag_target(document, expected_commit)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def publish(arguments: argparse.Namespace, api: GiteaApi) -> None:
|
def publish(arguments: argparse.Namespace, api: GiteaApi) -> None:
|
||||||
owner = arguments.owner
|
owner = arguments.owner
|
||||||
repo = arguments.repo
|
repo = arguments.repo
|
||||||
@@ -355,6 +375,17 @@ def publish(arguments: argparse.Namespace, api: GiteaApi) -> None:
|
|||||||
or any(character in arguments.name for character in "\r\n\0")
|
or any(character in arguments.name for character in "\r\n\0")
|
||||||
):
|
):
|
||||||
fail("the release name is invalid")
|
fail("the release name is invalid")
|
||||||
|
is_nightly = arguments.prerelease and tag.startswith("nightly-")
|
||||||
|
if arguments.allow_missing_draft_tag and not is_nightly:
|
||||||
|
fail("--allow-missing-draft-tag is restricted to nightly-* prereleases")
|
||||||
|
tag_exists = tag_target_exists(
|
||||||
|
api,
|
||||||
|
base,
|
||||||
|
tag,
|
||||||
|
arguments.target,
|
||||||
|
)
|
||||||
|
if not tag_exists and not is_nightly:
|
||||||
|
fail("the release tag does not exist")
|
||||||
tag_path = quote(tag, safe="")
|
tag_path = quote(tag, safe="")
|
||||||
status, release = api.request_json(
|
status, release = api.request_json(
|
||||||
"GET",
|
"GET",
|
||||||
@@ -379,9 +410,10 @@ def publish(arguments: argparse.Namespace, api: GiteaApi) -> None:
|
|||||||
fail("Gitea returned an invalid release")
|
fail("Gitea returned an invalid release")
|
||||||
if release.get("tag_name") != tag:
|
if release.get("tag_name") != tag:
|
||||||
fail("Gitea returned a release for the wrong tag")
|
fail("Gitea returned a release for the wrong tag")
|
||||||
verify_tag_target(api, base, tag, arguments.target)
|
|
||||||
release_id = release["id"]
|
release_id = release["id"]
|
||||||
if not release.get("draft", False):
|
if not release.get("draft", False):
|
||||||
|
if not tag_exists:
|
||||||
|
fail("a published release has no Git tag")
|
||||||
verify_release_metadata(
|
verify_release_metadata(
|
||||||
release,
|
release,
|
||||||
tag=tag,
|
tag=tag,
|
||||||
@@ -588,6 +620,11 @@ def parser() -> argparse.ArgumentParser:
|
|||||||
body_group.add_argument("--body-file", type=Path)
|
body_group.add_argument("--body-file", type=Path)
|
||||||
publish_parser.add_argument("--artifacts", type=Path, required=True)
|
publish_parser.add_argument("--artifacts", type=Path, required=True)
|
||||||
publish_parser.add_argument("--prerelease", action="store_true")
|
publish_parser.add_argument("--prerelease", action="store_true")
|
||||||
|
publish_parser.add_argument(
|
||||||
|
"--allow-missing-draft-tag",
|
||||||
|
action="store_true",
|
||||||
|
help="declare that a nightly-* tag may be created with its verified draft",
|
||||||
|
)
|
||||||
|
|
||||||
prune_parser = subparsers.add_parser("prune-nightlies")
|
prune_parser = subparsers.add_parser("prune-nightlies")
|
||||||
prune_parser.add_argument("--owner", required=True)
|
prune_parser.add_argument("--owner", required=True)
|
||||||
|
|||||||
@@ -22,9 +22,11 @@ SCRIPT = SOURCE_ROOT / "scripts" / "gitea_release.py"
|
|||||||
class State:
|
class State:
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.releases: dict[int, dict] = {}
|
self.releases: dict[int, dict] = {}
|
||||||
|
self.tags: dict[str, str] = {}
|
||||||
self.assets: dict[int, bytes] = {}
|
self.assets: dict[int, bytes] = {}
|
||||||
self.next_release = 1
|
self.next_release = 1
|
||||||
self.next_asset = 1
|
self.next_asset = 1
|
||||||
|
self.tag_creations = 0
|
||||||
self.uploads = 0
|
self.uploads = 0
|
||||||
self.upload_attempts = 0
|
self.upload_attempts = 0
|
||||||
self.fail_upload_attempt: int | None = None
|
self.fail_upload_attempt: int | None = None
|
||||||
@@ -108,16 +110,15 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
)
|
)
|
||||||
if repository_tag_match:
|
if repository_tag_match:
|
||||||
tag = unquote(repository_tag_match.group(1))
|
tag = unquote(repository_tag_match.group(1))
|
||||||
for release in self.server.state.releases.values():
|
if tag in self.server.state.tags:
|
||||||
if release["tag_name"] == tag:
|
self.json_response(
|
||||||
self.json_response(
|
200,
|
||||||
200,
|
{
|
||||||
{
|
"name": tag,
|
||||||
"name": tag,
|
"commit": {"sha": self.server.state.tags[tag]},
|
||||||
"commit": {"sha": release["target_commitish"]},
|
},
|
||||||
},
|
)
|
||||||
)
|
return
|
||||||
return
|
|
||||||
self.json_response(404, {"message": "not found"})
|
self.json_response(404, {"message": "not found"})
|
||||||
return
|
return
|
||||||
release_match = re.fullmatch(
|
release_match = re.fullmatch(
|
||||||
@@ -200,8 +201,15 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
self.json_response(404, {"message": "unknown route"})
|
self.json_response(404, {"message": "unknown route"})
|
||||||
return
|
return
|
||||||
release_id = int(match.group(1))
|
release_id = int(match.group(1))
|
||||||
self.server.state.releases[release_id].update(self.read_json())
|
release = self.server.state.releases[release_id]
|
||||||
if not self.server.state.releases[release_id]["draft"]:
|
document = self.read_json()
|
||||||
|
if release["draft"] and document.get("draft") is False:
|
||||||
|
tag = release["tag_name"]
|
||||||
|
if tag not in self.server.state.tags:
|
||||||
|
self.server.state.tags[tag] = document["target_commitish"]
|
||||||
|
self.server.state.tag_creations += 1
|
||||||
|
release.update(document)
|
||||||
|
if not release["draft"]:
|
||||||
self.server.state.releases[release_id]["published_at"] = (
|
self.server.state.releases[release_id]["published_at"] = (
|
||||||
"2026-07-22T00:00:00Z"
|
"2026-07-22T00:00:00Z"
|
||||||
)
|
)
|
||||||
@@ -215,6 +223,11 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
r"/api/v1/repos/Void/Echoion/tags/(.+)", target.path
|
r"/api/v1/repos/Void/Echoion/tags/(.+)", target.path
|
||||||
)
|
)
|
||||||
if tag_match:
|
if tag_match:
|
||||||
|
tag = unquote(tag_match.group(1))
|
||||||
|
if tag not in self.server.state.tags:
|
||||||
|
self.empty_response(404)
|
||||||
|
return
|
||||||
|
del self.server.state.tags[tag]
|
||||||
self.empty_response(204)
|
self.empty_response(204)
|
||||||
return
|
return
|
||||||
asset_match = re.fullmatch(
|
asset_match = re.fullmatch(
|
||||||
@@ -314,6 +327,9 @@ class GiteaReleaseTest(unittest.TestCase):
|
|||||||
"--artifacts",
|
"--artifacts",
|
||||||
os.fspath(artifacts),
|
os.fspath(artifacts),
|
||||||
)
|
)
|
||||||
|
self.server.state.tags["v1.2.3"] = (
|
||||||
|
"0123456789abcdef0123456789abcdef01234567"
|
||||||
|
)
|
||||||
self.run_script(*arguments)
|
self.run_script(*arguments)
|
||||||
self.assertFalse(self.server.state.releases[1]["draft"])
|
self.assertFalse(self.server.state.releases[1]["draft"])
|
||||||
self.assertEqual(self.server.state.uploads, 2)
|
self.assertEqual(self.server.state.uploads, 2)
|
||||||
@@ -329,6 +345,124 @@ class GiteaReleaseTest(unittest.TestCase):
|
|||||||
self.assertIn("download verification failed", failed.stderr)
|
self.assertIn("download verification failed", failed.stderr)
|
||||||
self.assertEqual(self.server.state.uploads, 2)
|
self.assertEqual(self.server.state.uploads, 2)
|
||||||
|
|
||||||
|
def test_publish_creates_a_missing_nightly_tag_idempotently(self) -> None:
|
||||||
|
artifacts = Path(self.temporary.name, "artifacts")
|
||||||
|
artifacts.mkdir()
|
||||||
|
Path(artifacts, "nightly.bin").write_bytes(b"nightly")
|
||||||
|
target = "23456789abcdef0123456789abcdef0123456789"
|
||||||
|
arguments = (
|
||||||
|
"publish",
|
||||||
|
"--owner",
|
||||||
|
"Void",
|
||||||
|
"--repo",
|
||||||
|
"Echoion",
|
||||||
|
"--tag",
|
||||||
|
"nightly-20260726-13",
|
||||||
|
"--target",
|
||||||
|
target,
|
||||||
|
"--name",
|
||||||
|
"Echoion nightly",
|
||||||
|
"--artifacts",
|
||||||
|
os.fspath(artifacts),
|
||||||
|
"--prerelease",
|
||||||
|
)
|
||||||
|
|
||||||
|
self.run_script(*arguments)
|
||||||
|
self.assertEqual(
|
||||||
|
self.server.state.tags["nightly-20260726-13"],
|
||||||
|
target,
|
||||||
|
)
|
||||||
|
self.assertEqual(self.server.state.tag_creations, 1)
|
||||||
|
self.run_script(*arguments)
|
||||||
|
self.assertEqual(self.server.state.tag_creations, 1)
|
||||||
|
|
||||||
|
def test_publish_requires_an_existing_tag_by_default(self) -> None:
|
||||||
|
artifacts = Path(self.temporary.name, "artifacts")
|
||||||
|
artifacts.mkdir()
|
||||||
|
Path(artifacts, "stable.bin").write_bytes(b"stable")
|
||||||
|
failed = self.run_script(
|
||||||
|
"publish",
|
||||||
|
"--owner",
|
||||||
|
"Void",
|
||||||
|
"--repo",
|
||||||
|
"Echoion",
|
||||||
|
"--tag",
|
||||||
|
"v9.9.9",
|
||||||
|
"--target",
|
||||||
|
"3456789abcdef0123456789abcdef0123456789a",
|
||||||
|
"--name",
|
||||||
|
"Echoion 9.9.9",
|
||||||
|
"--artifacts",
|
||||||
|
os.fspath(artifacts),
|
||||||
|
check=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertNotEqual(failed.returncode, 0)
|
||||||
|
self.assertIn("release tag does not exist", failed.stderr)
|
||||||
|
self.assertFalse(self.server.state.releases)
|
||||||
|
self.assertFalse(self.server.state.tags)
|
||||||
|
|
||||||
|
def test_missing_tag_exception_is_restricted_to_nightlies(self) -> None:
|
||||||
|
artifacts = Path(self.temporary.name, "artifacts")
|
||||||
|
artifacts.mkdir()
|
||||||
|
Path(artifacts, "beta.bin").write_bytes(b"beta")
|
||||||
|
failed = self.run_script(
|
||||||
|
"publish",
|
||||||
|
"--owner",
|
||||||
|
"Void",
|
||||||
|
"--repo",
|
||||||
|
"Echoion",
|
||||||
|
"--tag",
|
||||||
|
"v9.9.9-beta.1",
|
||||||
|
"--target",
|
||||||
|
"456789abcdef0123456789abcdef0123456789ab",
|
||||||
|
"--name",
|
||||||
|
"Echoion 9.9.9 beta 1",
|
||||||
|
"--artifacts",
|
||||||
|
os.fspath(artifacts),
|
||||||
|
"--allow-missing-draft-tag",
|
||||||
|
"--prerelease",
|
||||||
|
check=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertNotEqual(failed.returncode, 0)
|
||||||
|
self.assertIn("restricted to nightly-*", failed.stderr)
|
||||||
|
self.assertFalse(self.server.state.releases)
|
||||||
|
self.assertFalse(self.server.state.tags)
|
||||||
|
|
||||||
|
def test_publish_never_moves_an_existing_tag(self) -> None:
|
||||||
|
artifacts = Path(self.temporary.name, "artifacts")
|
||||||
|
artifacts.mkdir()
|
||||||
|
Path(artifacts, "nightly.bin").write_bytes(b"nightly")
|
||||||
|
tag = "nightly-20260726-14"
|
||||||
|
existing_target = "456789abcdef0123456789abcdef0123456789ab"
|
||||||
|
requested_target = "56789abcdef0123456789abcdef0123456789abc"
|
||||||
|
self.server.state.tags[tag] = existing_target
|
||||||
|
|
||||||
|
failed = self.run_script(
|
||||||
|
"publish",
|
||||||
|
"--owner",
|
||||||
|
"Void",
|
||||||
|
"--repo",
|
||||||
|
"Echoion",
|
||||||
|
"--tag",
|
||||||
|
tag,
|
||||||
|
"--target",
|
||||||
|
requested_target,
|
||||||
|
"--name",
|
||||||
|
"Echoion nightly",
|
||||||
|
"--artifacts",
|
||||||
|
os.fspath(artifacts),
|
||||||
|
"--allow-missing-draft-tag",
|
||||||
|
"--prerelease",
|
||||||
|
check=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertNotEqual(failed.returncode, 0)
|
||||||
|
self.assertIn("tag does not target", failed.stderr)
|
||||||
|
self.assertEqual(self.server.state.tags[tag], existing_target)
|
||||||
|
self.assertFalse(self.server.state.releases)
|
||||||
|
|
||||||
def test_prune_keeps_fourteen_newest_nightlies(self) -> None:
|
def test_prune_keeps_fourteen_newest_nightlies(self) -> None:
|
||||||
for index in range(1, 17):
|
for index in range(1, 17):
|
||||||
self.server.state.releases[index] = {
|
self.server.state.releases[index] = {
|
||||||
@@ -404,6 +538,9 @@ class GiteaReleaseTest(unittest.TestCase):
|
|||||||
"--artifacts",
|
"--artifacts",
|
||||||
os.fspath(artifacts),
|
os.fspath(artifacts),
|
||||||
)
|
)
|
||||||
|
self.server.state.tags["v2.0.0"] = (
|
||||||
|
"89abcdef0123456789abcdef0123456789abcdef"
|
||||||
|
)
|
||||||
self.server.state.fail_upload_attempt = 2
|
self.server.state.fail_upload_attempt = 2
|
||||||
failed = self.run_script(*arguments, check=False)
|
failed = self.run_script(*arguments, check=False)
|
||||||
self.assertNotEqual(failed.returncode, 0)
|
self.assertNotEqual(failed.returncode, 0)
|
||||||
|
|||||||
Reference in new issue
Block a user