Skip to content

Commit

Permalink
Remove AIK
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdWindScholar committed Feb 12, 2024
1 parent d7e5799 commit 72e66c9
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 2 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "Build Tool"
permissions:
contents: write
discussions: write
on:
push:
paths:
- "build.py"
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8.10
uses: actions/setup-python@v4
with:
# Semantic version range syntax or exact version of a Python version
python-version: '3.8.10'
# Optional - x64 or x86 architecture, defaults to x64
architecture: 'x64'
- name: Update pip
run: python -m pip install -U --force-reinstall pip
- name: Build tool
run: |
python build.py
- name: Rename Tool
run: |
move ./NH4RomTool-win.zip ../NH4RomTool-${{ github.run_number }}-win.zip
- name: Upload release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
omitBodyDuringUpdate: true
removeArtifacts: true
name: "NH4RomTool.${{ github.run_number }}"
tag: "CI_BUILD_${{ github.run_number }}"
body: |
Build times: ${{ github.run_number }}
Version: 4
Note:If u cannot run it in linux,you may need do "chmod a+x ./*"
Minimum support: Ubuntu 20.04 (64bit),Windows Vista (32bit)
artifacts: "*.zip"
66 changes: 66 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import os
import platform
import shutil
import zipfile

print(f'Build for {platform.system()}')
from pip._internal.cli.main import main as _main

with open('requirements.txt', 'r', encoding='utf-8') as l:
for i in l.read().split("\n"):
print(f"Installing {i}")
_main(['install', i])
local = os.getcwd()
name = 'NH4RomTool-win.zip'


def zip_folder(folder_path):
# 获取文件夹的绝对路径和文件夹名称
abs_folder_path = os.path.abspath(folder_path)

# 创建一个同名的zip文件
zip_file_path = os.path.join(local, name)
archive = zipfile.ZipFile(zip_file_path, "w", zipfile.ZIP_DEFLATED)

# 遍历文件夹中的所有文件和子文件夹
for root, dirs, files in os.walk(abs_folder_path):
for file in files:
if file == name:
continue
file_path = os.path.join(root, file)
if ".git" in file_path:
continue
print(f"Adding: {file_path}")
# 将文件添加到zip文件中
archive.write(file_path, os.path.relpath(file_path, abs_folder_path))

# 关闭zip文件
archive.close()
print(f"Done!")


import PyInstaller.__main__

PyInstaller.__main__.run(['-F', 'ui.py', '--exclude-module=numpy', '-i', 'icon.ico'])

if os.name == 'nt':
if os.path.exists(local + os.sep + "dist" + os.sep + "ui.exe"):
shutil.move(local + os.sep + "dist" + os.sep + "ui.exe", local)

for i in os.listdir(local):
if i not in ['run', 'ui.exe', 'bin', 'LICENSE']:
print(f"Removing {i}")
if os.path.isdir(local + os.sep + i):
try:
shutil.rmtree(local + os.sep + i)
except Exception or OSError as e:
print(e)
elif os.path.isfile(local + os.sep + i):
try:
os.remove(local + os.sep + i)
except Exception or OSError as e:
print(e)
else:
print(i)

zip_folder(".")
2 changes: 0 additions & 2 deletions pyscripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ def unzip_file(zip_src, dst_dir):
print('This is not zip')




def zip_file(file, dst_dir):
def get_all_file_paths(directory):
# 初始化文件路径列表
Expand Down

0 comments on commit 72e66c9

Please sign in to comment.