-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7e5799
commit 72e66c9
Showing
3 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(".") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters