Skip to content

Commit 67fabcc

Browse files
committed
测试自动化打包流
1 parent 51e2af7 commit 67fabcc

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

.github/workflows/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Publish template to Github Release
2+
on:
3+
push:
4+
branches:
5+
- master
6+
7+
jobs:
8+
deploy:
9+
name: Deploy docs
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout main
13+
uses: actions/checkout@v2
14+
15+
- name: Setup Python
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: "3.10"
19+
20+
- name: Package
21+
run: python3 ./workflow-action/deploy.py
22+
23+
- name: Release
24+
uses: ncipollo/release-action@v1
25+
with:
26+
artifacts: "release/*"
27+
bodyFile: "./workflow-action/body.md"

workflow-action/body.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
测试自动化打包流程

workflow-action/deploy.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import zipfile
2+
import pathlib
3+
import os
4+
5+
print("Starting")
6+
7+
# 创建工作目录
8+
os.makedirs("release", exist_ok=True)
9+
10+
# 排除掉文件和特殊文件夹
11+
florders = pathlib.Path(".").glob("*/")
12+
for directory in florders:
13+
if (
14+
not directory.name.startswith(".")
15+
and not directory.name.startswith("sp")
16+
and os.path.isdir("./" + directory.name)
17+
and directory.name != "release"
18+
):
19+
print("Current florder: " + directory.name)
20+
# test\<directory>.zip
21+
with zipfile.ZipFile(
22+
pathlib.Path("release") / directory.with_suffix(".zip").name,
23+
"w",
24+
compression=zipfile.ZIP_DEFLATED,
25+
compresslevel=9,
26+
) as zfile:
27+
for item in directory.rglob("*"):
28+
zfile.write(item, arcname=item.relative_to(directory))
29+
30+
print("All Done")

0 commit comments

Comments
 (0)