Skip to content

Commit

Permalink
Github保佑我
Browse files Browse the repository at this point in the history
  • Loading branch information
lilingfengdev committed Jun 10, 2024
1 parent bc639f9 commit ab44a38
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
permissions:
contents: write

on:
[push]

jobs:
build:
name: Auto Release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install Dependencies and Generate Bundle
run: |
python generate-bundle.py
- name: Auto release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ matrix.os }}
prerelease: true
files: |
dist/*
23 changes: 23 additions & 0 deletions generate-bundle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os
import shutil
import urllib.request
import zipfile
import platform

os.system("python3 -m pip install cn_bing_translator requests pyinstaller")
if platform.system() == 'Windows':
urllib.request.urlretrieve("https://github.com/upx/upx/releases/download/v4.2.4/upx-4.2.4-win64.zip",
"upx.zip")
zip = zipfile.ZipFile("upx.zip")
zip.extract("upx-4.2.4-win64/upx.exe", path=os.getcwd())
shutil.move("upx-4.2.4-win64/upx.exe", os.path.join(os.getcwd(), "upx.exe"))

import PyInstaller.__main__

os.mkdir("dist")

flag = ["-F", "main.py", "--optimize", "2"]
if platform.system() != 'Windows':
flag.append("--strip")
PyInstaller.__main__.run(flag)

2 changes: 2 additions & 0 deletions plugin/utils/translate.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from cn_bing_translator import Translator
from functools import lru_cache

EN = "en"
ZH_CN = "zh-Hans"


@lru_cache(maxsize=None)
def translate(text, to_lang=ZH_CN) -> str:
translator = Translator()
return translator.process(text, toLang=to_lang)
Expand Down

0 comments on commit ab44a38

Please sign in to comment.