Skip to content

Commit

Permalink
Merge pull request #381 from Controllerdestiny/main
Browse files Browse the repository at this point in the history
工作流: 干掉PDF转换
  • Loading branch information
Controllerdestiny authored Aug 10, 2024
2 parents 6339234 + 4c44dbd commit 2735f9b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/plugins_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 插件发布

on:
push:
branches: [ "master","cai"]
branches: [ "master","cai", "main"]

jobs:
Build:
Expand Down Expand Up @@ -61,13 +61,12 @@ jobs:
echo "非Controllerdestiny/TShockPlugin仓库,跳过提交."
fi
- name: 初始化Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: 安装beautifulsoup4
- name: 安装Py模块
run: |
sudo pip install beautifulsoup4
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/pull_request_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: 安装Py模块
run: |
sudo pip install beautifulsoup4
- name: 打包插件
run: python BuildHelper.py Debug
Expand Down
11 changes: 7 additions & 4 deletions BuildHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ def zip_files_in_folder(folder_path, zip_file_path):
file_path = os.path.join(foldername, filename)
zipf.write(file_path, arcname=os.path.basename(file_path))
print(f"📦 压缩包已生成: {zip_file_path}")

def md_to_pdf(file_name):
os.system(f"pandoc --pdf-engine=xelatex -V mainfont=LXGWWenKaiMono-Regular.ttf -V geometry:margin=0.5in --template eisvogel.tex {file_name} -o {file_name.replace('.md', '.pdf')}")

if __name__ == '__main__':
print(f"🚀 开始执行打包脚本...(By Cai 😋)")
build_type = sys.argv[1]
Expand All @@ -25,7 +25,7 @@ def md_to_pdf(file_name):
os.remove(file)
print(f"✅ 已删除文件: {file}")
print("✅ json文件删除成功!")

print("📝 开始移动README.md...")
cwd = os.getcwd()
for dir_name in os.listdir(cwd):
Expand All @@ -40,10 +40,12 @@ def md_to_pdf(file_name):
print(f"🔍 找到README.md({destination_path})")
except:
print(f"⚠️ README移动失败({file_name})")
shutil.copyfile('README.md', f"out/{build_type}/README.md")

shutil.copyfile('README.md', f"out/{build_type}/TShockPlugin.md")
print("✅ README.md移动成功!")
shutil.copyfile('Plugins.json', f"out/{build_type}/Plugins.json")
print("✅ Plugins.json移动成功!")
'''
if build_type == "Release":
print("🔄 准备转换PDF...")
urllib.request.urlretrieve("https://raw.githubusercontent.com/lxgw/LxgwWenKai/main/fonts/TTF/LXGWWenKaiMono-Regular.ttf", "LXGWWenKaiMono-Regular.ttf")
Expand All @@ -59,6 +61,7 @@ def md_to_pdf(file_name):
os.remove(f"{cwd}/out/{build_type}/{file_name}")
print(f"✅ {file_name}转换成功...")
print("✅ PDF转换完成!")
'''

print("📦 准备打包插件...")
zip_files_in_folder("out", "Plugins.zip")
Expand Down

0 comments on commit 2735f9b

Please sign in to comment.