Require Git tag for completed release
next-build / build (push) Canceled after 0s

This commit is contained in:
2026-10-15 03:09:11 -06:00
parent 8fa9e5d9e6
commit af49d4905d
2 changed files with 16 additions and 1 deletions
+2 -1
View File
@@ -113,7 +113,8 @@ def publish(tag, prerelease, paths, api, repo, sha):
and asset_digest(asset, api) == digests[name]
for name, size in wanted.items()
):
check_tag_commit(api, repo, tag, sha)
if not check_tag_commit(api, repo, tag, sha):
raise ValueError("published release has no Git tag")
print(f"Release {tag} is already complete")
return
if not release.get("draft"):
+14
View File
@@ -114,6 +114,20 @@ class ReleaseTest(unittest.TestCase):
self.assertEqual(fake.uploads, 0)
self.assertFalse(fake.release["draft"])
def test_complete_release_without_git_tag_is_not_accepted(self):
with TemporaryDirectory() as directory:
path = Path(directory) / "image.tar.gz"
path.write_bytes(b"image")
fake = FakeGitea()
fake.release = {"id": 7, "tag_name": "v1.2.3",
"target_commitish": "a" * 40, "draft": False}
fake.assets = [{"id": 1, "name": path.name, "size": path.stat().st_size}]
with patch.object(release, "request", fake.request), \
patch.object(release, "asset_digest", lambda *_: release.sha256_file(path)):
with self.assertRaisesRegex(ValueError, "no Git tag"):
release.publish("v1.2.3", False, [path], "https://api",
"org/repo", "a" * 40)
if __name__ == "__main__":
unittest.main()