diff --git a/ci/release.py b/ci/release.py index f566284..9b78d4f 100644 --- a/ci/release.py +++ b/ci/release.py @@ -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"): diff --git a/ci/test-release.py b/ci/test-release.py index 0b999d2..d936485 100644 --- a/ci/test-release.py +++ b/ci/test-release.py @@ -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()