更新
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import hashlib
|
||||
import json
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
root = Path(__file__).resolve().parent
|
||||
workspace = root.parents[1]
|
||||
base = root.parent / 'application-20260831-120612/payload/backend-source.zip'
|
||||
changed = ['backend/internal/app/im.go', 'backend/internal/app/im_unread_integration_test.go']
|
||||
source = root / 'backend-source.zip'
|
||||
with zipfile.ZipFile(str(base)) as old, zipfile.ZipFile(str(source), 'w', zipfile.ZIP_DEFLATED) as new:
|
||||
for item in old.infolist():
|
||||
if item.filename not in changed:
|
||||
new.writestr(item, old.read(item))
|
||||
for name in changed:
|
||||
new.write(str(root / name), name)
|
||||
with zipfile.ZipFile(str(base)) as old, zipfile.ZipFile(str(source)) as new:
|
||||
def hashes(z):
|
||||
return {i.filename: hashlib.sha256(z.read(i)).hexdigest() for i in z.infolist() if not i.is_dir()}
|
||||
left, right = hashes(old), hashes(new)
|
||||
actual = sorted(name for name in left.keys() | right.keys() if left.get(name) != right.get(name))
|
||||
assert actual == changed, actual
|
||||
files = {name: hashlib.sha256((root / name).read_bytes()).hexdigest() for name in ['xingyu-api', 'backend-source.zip']}
|
||||
manifest = json.dumps({'files': files}, indent=2)
|
||||
(root / 'manifest.json').write_text(manifest, encoding='utf-8')
|
||||
with zipfile.ZipFile(str(root / 'release.zip'), 'w', zipfile.ZIP_DEFLATED) as package:
|
||||
for name in [*files, 'manifest.json']:
|
||||
package.write(str(root / name), name)
|
||||
package.write(str(workspace / 'deploy/baota_publish_im_unread.py'), 'baota_publish_im_unread.py')
|
||||
result = {'sha256': hashlib.sha256((root / 'release.zip').read_bytes()).hexdigest(), 'files': files, 'changed': actual}
|
||||
(root / 'package-result.json').write_text(json.dumps(result, indent=2), encoding='utf-8')
|
||||
print(json.dumps(result))
|
||||
Reference in New Issue
Block a user