Merge pull request #107 from vint2k/update-xray-assets

Auto-update Xray assets when deploy
This commit is contained in:
Loren Eteval
2024-10-12 22:10:23 +08:00
committed by GitHub
8 changed files with 58271 additions and 62952 deletions
+14 -4
View File
@@ -35,11 +35,16 @@ jobs:
pip install
setuptools wheel
- name: Install requirements-nocore.txt
- name: Install requirements.txt
run: >-
python3 -m
pip install
-r requirements-nocore.txt
-r requirements.txt
- name: Download latest asset files
run: |
python3 -m pip install requests
python3 Deploy.py --download
- name: Build a binary wheel and a source tarball
run: python3 setup.py sdist bdist_wheel
@@ -133,11 +138,11 @@ jobs:
exit 1
fi
- name: Install requirements-nocore.txt
- name: Install requirements.txt
run: >-
python3 -m
pip install
-r requirements-nocore.txt
-r requirements.txt
- name: Install numpy<2
run: >-
@@ -173,6 +178,11 @@ jobs:
go version
python3 -m pip install "Xray-core >= 1.8.8" "hysteria2 >= 2.0.4" "tun2socks > 2.5.2"
- name: Download latest asset files
run: |
python3 -m pip install requests
python3 Deploy.py --download
- name: Run deploy script
run: python3 Deploy.py
+69 -22
View File
@@ -21,17 +21,11 @@ from Furious.Utility import *
import os
import sys
import time
import shutil
import logging
import argparse
import subprocess
try:
import nuitka
except ImportError:
raise ModuleNotFoundError('please install nuitka to run this script')
logging.basicConfig(
format='[%(asctime)s] [%(name)s] [%(levelname)s] %(message)s',
level=logging.INFO,
@@ -98,9 +92,40 @@ else:
ARTIFACT_NAME = ''
def printArtifactName():
if PLATFORM == 'Windows':
print(f'{ARTIFACT_NAME}.zip', flush=True)
def downloadXrayAssets(url, filename):
try:
import requests
except ImportError:
raise ModuleNotFoundError('missing requests module')
try:
# Make sure the save directory exists
if not os.path.exists(XRAY_ASSET_DIR):
os.makedirs(XRAY_ASSET_DIR)
# Full path where the file will be saved
filepath = os.path.join(XRAY_ASSET_DIR, filename)
# Send an HTTP GET request to the URL
response = requests.get(url)
response.raise_for_status() # Check if the request was successful
# Open the save_path in write-binary mode and write the content of the response
with open(filepath, 'wb') as file:
file.write(response.content)
except Exception as ex:
# Any non-exit exceptions
logger.error(
f'failed to download file from {url}. Status code: {response.status_code}'
)
return False
else:
logger.info(f'file downloaded successfully and saved to {filepath}')
return True
def cleanup():
@@ -156,22 +181,40 @@ def cleanup():
logger.info(f'remove dmg dir success')
def download():
# URLs of geosite and geoip assets
url_geosite = 'https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat'
url_geoip = 'https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat'
# Xray assets names
filename_geosite = 'geosite.dat'
filename_geoip = 'geoip.dat'
return all(
[
downloadXrayAssets(url_geosite, filename_geosite),
downloadXrayAssets(url_geoip, filename_geoip),
]
)
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
'-n', '--name', action='store_true', help='Target artifact name'
'-d',
'--download',
action='store_true',
help='Download latest asset files',
)
parser.add_argument(
'-c', '--cleanup', action='store_true', help='Cleanup deployment files'
'-c',
'--cleanup',
action='store_true',
help='Cleanup deployment files',
)
args = parser.parse_args()
if args.name:
printArtifactName()
sys.exit(0)
if args.cleanup:
cleanup()
@@ -179,6 +222,16 @@ def main():
sys.exit(0)
if args.download:
success = 0 if download() else 1
sys.exit(success)
try:
import nuitka
except ImportError:
raise ModuleNotFoundError('please install nuitka to run this script')
try:
logger.info('building')
@@ -212,9 +265,6 @@ def main():
flush=True,
)
# Sleep for a while for any running nuitka tasks
time.sleep(5)
if PLATFORM == 'Windows':
if PLATFORM_RELEASE.endswith('Server'):
# Windows server. Fixed to windows10
@@ -318,9 +368,6 @@ def main():
logger.info(f'generate dmg success: {output}')
# Sleep for a while for any running tasks
time.sleep(5)
if __name__ == '__main__':
main()
Binary file not shown.
+58184 -47857
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-10
View File
@@ -1,10 +0,0 @@
PySide6-Essentials
qdarkstyle
ujson
pybase64
pyqrcode
pypng
icmplib
sysproxy; sys_platform == "win32"
darkdetect; sys_platform != "darwin"
darkdetect[macos-listener]; sys_platform == "darwin"
-4
View File
@@ -1,9 +1,5 @@
PySide6-Essentials
qdarkstyle
Xray-core
hysteria > 1.3.5
hysteria2 > 2.0.0
tun2socks > 2.5.1
ujson
pybase64
pyqrcode
+4 -30
View File
@@ -22,6 +22,9 @@ from setuptools import setup, find_packages
with open('README.md', 'r', encoding='utf-8') as file:
long_description = file.read()
with open('requirements.txt', 'r', encoding='utf-8') as file:
install_requires = file.read().split('\n')
setup(
name='Furious-GUI',
version=__version__,
@@ -35,36 +38,7 @@ setup(
packages=find_packages(),
package_data={'Furious': ['Data/**']},
include_package_data=True,
install_requires=[
'PySide6',
'qdarkstyle',
'ujson',
'pybase64',
'pyqrcode',
'pypng',
'icmplib',
'sysproxy; platform_system == "Windows"',
'darkdetect; platform_system != "Darwin"',
'darkdetect[macos-listener]; platform_system == "Darwin"',
],
extras_require={
'go1.20': [
'Xray-core < 1.8.5',
'hysteria > 1.3.5',
'hysteria2 == 2.0.0.1',
'tun2socks > 2.5.1, <= 2.5.2; platform_system != "Linux"',
],
'go1.21': [
'Xray-core >= 1.8.5, < 1.8.8',
'hysteria2 >= 2.0.4',
'tun2socks > 2.5.1, <= 2.5.2; platform_system != "Linux"',
],
'go1.22': [
'Xray-core >= 1.8.8',
'hysteria2 >= 2.0.4',
'tun2socks > 2.5.2; platform_system != "Linux"',
],
},
install_requires=install_requires,
entry_points={
'gui_scripts': [
'Furious = Furious.__main__:main',