pcsx2/.github/workflows/scripts/releases/rename-release-assets.py

50 lines
1.3 KiB
Python
Raw Normal View History

import os
import shutil
tag = os.environ['TAG'].split("refs/tags/")[1]
scan_dir = os.environ['SCAN_DIR']
output_dir = os.environ['OUT_DIR']
2023-06-05 13:44:12 +00:00
accepted_exts = ["AppImage", "flatpak", "tar.xz", "7z"]
2022-05-14 17:07:57 +00:00
for dir_name in os.listdir(scan_dir):
asset_name = "pcsx2-{}".format(tag)
2022-05-14 17:07:57 +00:00
if "macos" in dir_name.lower():
asset_name += "-macos"
2022-05-14 17:07:57 +00:00
elif "linux" in dir_name.lower():
2023-06-05 13:44:12 +00:00
if "flatpak" in dir_name.lower():
asset_name += "-linux-flatpak-x64"
2023-06-05 13:44:12 +00:00
else:
asset_name += "-linux-appimage-x64"
2022-05-14 17:07:57 +00:00
elif "windows" in dir_name.lower():
asset_name += "-windows-x64"
else:
continue;
if "avx2" in dir_name.lower():
asset_name += "-AVX2"
elif "sse4" in dir_name.lower():
asset_name += "-SSE4"
asset_name += "-Qt"
2022-05-14 17:07:57 +00:00
if "symbols" in dir_name.lower():
asset_name += "-symbols"
print(asset_name)
dir_handled = False
2022-05-14 17:07:57 +00:00
for file in os.listdir(os.path.join(scan_dir, dir_name)):
for ext in accepted_exts:
if file.endswith(ext):
dir_handled = True
print("Moving {} to out dir".format(file))
2022-05-14 17:07:57 +00:00
shutil.move(os.path.join(scan_dir, dir_name, file), os.path.join(output_dir, asset_name + "." + ext))
break
if dir_handled:
break
if not dir_handled:
print("Could not find asset in directory when one was expected")
exit(1)