Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

工作流:修BuildHelper.py #71

Merged
merged 3 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
python-version: '3.x'

- name: Package
run: python BuildHelper.py
run: python BuildHelper.py Debug
env:
PYTHONIOENCODING: 'utf-8'

Expand All @@ -38,4 +38,4 @@ jobs:
if: github.event_name == 'pull_request'
with:
name: Plugin
path: out/*
path: out/Debug/*
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
python-version: '3.x'

- name: Package
run: python BuildHelper.py
run: python BuildHelper.py Release
env:
PYTHONIOENCODING: 'utf-8'

Expand Down
25 changes: 14 additions & 11 deletions BuildHelper.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import os
import glob
import shutil
import sys
import zipfile
print(f"╰(*°▽°*)╯打包脚本By Cai...")
print(f"😋😋😋打包脚本By Cai...")

build_type = sys.argv[1]

def zip_files_in_folder(folder_path, zip_file_path):
# Create a ZipFile object in write mode
Expand All @@ -17,16 +20,16 @@ def zip_files_in_folder(folder_path, zip_file_path):
zipf.write(file_path, arcname=os.path.basename(file_path))
print(f"生成压缩包: {zip_file_path}")

print(f"( •̀ ω •́ )✧开始删除json文件")
for file in glob.glob(os.path.join("out/Debug/", "*.json")):
print(f"😋开始删除json文件")
for file in glob.glob(os.path.join(f"out/{build_type}/", "*.json")):
os.remove(file)
print(f"删除文件: {file}")
print("(●'◡'●)删除json文件成功~")
print("(删除json文件成功~")

# Get the current working directory
print("( •̀ ω •́ )✧开始移动README.md")
print("😋开始移动README.md")
cwd = os.getcwd()
shutil.copyfile("README.md","out/Debug/README.md")
shutil.copyfile("README.md",f"out/{build_type}/README.md")
# Iterate over all directories in the current working directory
for dir_name in os.listdir(cwd):
dir_path = os.path.join(cwd, dir_name)
Expand All @@ -39,17 +42,17 @@ def zip_files_in_folder(folder_path, zip_file_path):
if file_name.endswith('.csproj'):
# Construct the source path of the README.md file
source_path = os.path.join(dir_path, 'README.md')
# Construct the destination path in the out/Debug directory with the same name as the .csproj file
destination_path = os.path.join(cwd, 'out', 'Debug', file_name.replace('.csproj', '.md'))
# Construct the destination path in the out/{build_type} directory with the same name as the .csproj file
destination_path = os.path.join(cwd, 'out', f'{build_type}', file_name.replace('.csproj', '.md'))
# Copy the README.md file to the destination path
shutil.copyfile(source_path, destination_path)
print(f"找到README.md({destination_path})")
except:
print(f"README移动失败({file_name})")
print("(●'◡'●)移动README.md成功~")
print("移动README.md成功~")

# 调用函数来压缩文件夹中的所有文件
# 注意:这里需要替换为实际的文件夹路径和zip文件路径
print("( •̀ ω •́ )✧准备打包插件")
print("😋准备打包插件")
zip_files_in_folder("out", "Plugins.zip")
print("(❁´◡`❁)插件打包成功~")
print("😋😋😋插件打包成功~")
Loading