Allow the indexed pack icon in packwiz channel publication
Build Sanctuary / build (push) Canceled after 0s

This commit is contained in:
koka
2026-09-17 03:12:24 +02:00
parent 468743bfe7
commit 2090380712
5 changed files with 19 additions and 6 deletions
+12 -3
View File
@@ -115,12 +115,21 @@ def remote_tag_commit(tag):
return found.get('refs/tags/' + tag + '^{}') or found.get('refs/tags/' + tag)
def channel_file(relative):
"""The indexed pack icon is the only non-TOML file allowed on the channel."""
path = Path(relative)
return path.suffix == '.toml' or path.as_posix() == 'icon.png'
def publish_channel(origin, version, source_head):
staged = ROOT / 'build/packwiz-release'
pack.check_index(staged)
files = [path for path in staged.rglob('*') if path.is_file()]
pack.require(all(path.suffix == '.toml' for path in files),
'Distribution branch must contain only generated TOML metadata')
pack.require(all(channel_file(path.relative_to(staged)) for path in files),
'Distribution branch must contain only generated TOML metadata and the pack icon')
if (staged / 'icon.png').exists():
pack.require((staged / 'icon.png').read_bytes() == (ROOT / 'packwiz/icon.png').read_bytes(),
'Distribution icon differs from the verified source icon')
remote = git('ls-remote', '--heads', 'origin', 'refs/heads/' + CHANNEL)
with tempfile.TemporaryDirectory(prefix='sanctuary-pack-channel-') as temp:
directory = Path(temp)
@@ -134,7 +143,7 @@ def publish_channel(origin, version, source_head):
git('fetch', '--quiet', 'origin', CHANNEL, cwd=directory)
git('checkout', '--quiet', '-b', CHANNEL, 'FETCH_HEAD', cwd=directory)
tracked = git('ls-files', cwd=directory).splitlines()
pack.require(all(name.endswith('.toml') for name in tracked),
pack.require(all(channel_file(name) for name in tracked),
'Existing distribution branch contains unexpected files')
for name in tracked:
(directory / name).unlink()