Skip to content

Commit

Permalink
ref #21 优化
Browse files Browse the repository at this point in the history
  • Loading branch information
zy7y committed Apr 2, 2024
1 parent f26bf5c commit 1ec9917
Show file tree
Hide file tree
Showing 42 changed files with 3,449 additions and 584 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import yapf_third_party

params = [
"--windowed",
"--onefile",
"--add-data",
"static:static",
"--add-data",
f'{yapf_third_party.__file__.replace("__init__.py", "")}:yapf_third_party',
"--clean",
"--noconfirm",
"client.py",
]

from PyInstaller import __main__ as pyi

pyi.run(params)
6 changes: 2 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ jobs:
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install pywebview
pip install pyinstaller
pip install pillow
- name: Build executable
run: |
python build.py
python .github/workflows/build.py
- name: Upload executables
uses: actions/upload-release-asset@v1
Expand Down Expand Up @@ -77,13 +76,12 @@ jobs:
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install pywebview
pip install pyinstaller
pip install pillow
- name: Build executable
run: |
pyinstaller -w -F --add-data static:static client.py
python .github/workflows/build.py
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
zip -r -X client-macos.zip ./dist/client.app
fi
Expand Down
50 changes: 28 additions & 22 deletions .github/workflows/update_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,56 @@

def update_readme():
# 获取环境变量
repo = os.environ.get('REPO_NAME')
readme_path = os.environ.get('README_PATH')
repo = os.environ.get("REPO_NAME")
readme_path = os.environ.get("README_PATH")

# 获取贡献者信息和头像 URL
response = requests.get(f'https://api.github.com/repos/{repo}/contributors')
response = requests.get(f"https://api.github.com/repos/{repo}/contributors")
contributors_data = response.json()

contributors_md = ''
contributors_md = ""
for contributor in contributors_data:
if contributor['type'] != "User":
if contributor["type"] != "User":
continue
login = contributor['login']
avatar_url = contributor['avatar_url']
html_url = contributor['html_url']
contributions = contributor['contributions']
contributor_md = f'<div style="display: inline-block; text-align: center; margin: 10px;">' \
f'<a href="{html_url}" target="_blank"><img src="{avatar_url}" width="100px" height="100px" style="border-radius: 50%;" alt="{login}"></a>' \
f'<br>{login}<br>Contributions: {contributions}</div>'
login = contributor["login"]
avatar_url = contributor["avatar_url"]
html_url = contributor["html_url"]
contributions = contributor["contributions"]
contributor_md = (
f'<div style="display: inline-block; text-align: center; margin: 10px;">'
f'<a href="{html_url}" target="_blank"><img src="{avatar_url}" width="100px" height="100px" style="border-radius: 50%;" alt="{login}"></a>'
f"<br>{login}<br>Contributions: {contributions}</div>"
)
contributors_md += contributor_md

# 更新 README 文件
with open(readme_path, 'r') as f:
with open(readme_path, "r") as f:
readme_content = f.read()

# 定义要进行匹配和替换的正则表达式模式,使用括号分组
pattern = re.compile(r'<!-- CONTRIBUTORS_SECTION -->.*<!-- /CONTRIBUTORS_SECTION -->', re.DOTALL)
pattern = re.compile(
r"<!-- CONTRIBUTORS_SECTION -->.*<!-- /CONTRIBUTORS_SECTION -->", re.DOTALL
)

# 定义要替换的字符串
replacement = f'<!-- CONTRIBUTORS_SECTION -->' \
f'<div align="center">\n{contributors_md}\n</div>' \
f'<!-- /CONTRIBUTORS_SECTION -->'
replacement = (
f"<!-- CONTRIBUTORS_SECTION -->"
f'<div align="center">\n{contributors_md}\n</div>'
f"<!-- /CONTRIBUTORS_SECTION -->"
)

# 使用正则表达式进行匹配和替换
new_readme_content = pattern.sub(replacement, readme_content)

# 提交更改
if new_readme_content != readme_content:
with open(readme_path, 'w') as f:
with open(readme_path, "w") as f:
f.write(new_readme_content)

commit_message = f'CI: Update README (contributors: {len(contributors_data)})'
subprocess.run(['git', 'add', readme_path])
subprocess.run(['git', 'commit', '-m', commit_message])
subprocess.run(['git', 'push'])
commit_message = f"CI: Update README (contributors: {len(contributors_data)})"
subprocess.run(["git", "add", readme_path])
subprocess.run(["git", "commit", "-m", commit_message])
subprocess.run(["git", "push"])
else:
print("no change")

Expand Down
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@
3. [fastapi-crudrouter](https://fastapi-crudrouter.awtkns.com/) 内部通过add_router方式注册路由,虽然代码减少了,但是灵活性变低了
4. 或该更多的使用表之间[逻辑关联](https://www.zhihu.com/question/20006142)

# 上图
![home](image/home.png)
![conf](image/conf.png)
![model_code](image/model_code.png)
![router_code](image/router_code.png)
![db_code](image/db_code.png)

# 使用项目
> 桌面端请在Release处下载
Expand Down
28 changes: 0 additions & 28 deletions build.py

This file was deleted.

35 changes: 0 additions & 35 deletions client.py

This file was deleted.

107 changes: 0 additions & 107 deletions entity.py

This file was deleted.

Empty file removed generate/__init__.py
Empty file.
Loading

0 comments on commit 1ec9917

Please sign in to comment.