Skip to content

Commit

Permalink
actions (#1128)
Browse files Browse the repository at this point in the history
  • Loading branch information
test123456654321 authored Nov 2, 2024
1 parent 83af7fc commit f004380
Show file tree
Hide file tree
Showing 12 changed files with 321 additions and 238 deletions.
65 changes: 44 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,60 @@ on:
paths: [ '.github/workflows/build.yml','src/**']

jobs:
build:
pyrt:
runs-on: windows-latest
strategy:
matrix:
include:
- architecture: x86
fname: LunaTranslator_x86
- architecture: x64
fname: LunaTranslator
architecture: [x86, x64]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Windows 10 SDK
uses: GuillaumeFalourd/setup-windows10-sdk-action@v2
with:
sdk-version: 22621
- name: Install Python
uses: actions/setup-python@v5
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.7.9'
architecture: ${{ matrix.architecture }}

- name: Install Python 3.11
uses: actions/setup-python@v5
- run: python src/build.py pyrt ${{ matrix.architecture }} 3.7.9
- uses: actions/upload-artifact@v4
with:
python-version: '3.11'
name: pyrt_${{ matrix.architecture }}
path: src/pyrt
build_cpp:
runs-on: windows-latest
strategy:
matrix:
architecture: [x86, x64]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: GuillaumeFalourd/setup-windows10-sdk-action@v2
with:
sdk-version: 22621

- run: python src/build.py cpp ${{ matrix.architecture }}
- uses: actions/upload-artifact@v4
with:
name: cpp_${{ matrix.architecture }}
path: src/plugins/builds

- name: Run build script
run: |
python src/build.py ${{ matrix.architecture }} 3.7.9

release:
runs-on: windows-latest
needs: [pyrt,build_cpp]
strategy:
matrix:
include:
- architecture: x86
fname: LunaTranslator_x86
- architecture: x64
fname: LunaTranslator
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: build
- run: python src/build.py merge ${{ matrix.architecture }}
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.fname }}
path: src/build/${{ matrix.fname }}.zip
path: src/build/${{matrix.fname}}.zip
94 changes: 55 additions & 39 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,72 @@ on:
workflow_dispatch:

jobs:
build:
loadversion:
runs-on: windows-latest
outputs:
version: ${{ steps.loadversion.outputs.version }}
steps:
- uses: actions/checkout@v4
- id: loadversion
run: python src/build.py loadversion | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append

pyrt:
runs-on: windows-latest
strategy:
matrix:
include:
- architecture: x86
fname: LunaTranslator_x86
- architecture: x64
fname: LunaTranslator
permissions:
id-token: write
attestations: write
contents: write
architecture: [x86, x64]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Windows 10 SDK
uses: GuillaumeFalourd/setup-windows10-sdk-action@v2
with:
sdk-version: 22621
- name: Install Python
uses: actions/setup-python@v5
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.7.9'
architecture: ${{ matrix.architecture }}
- name: Install Python 3.11
uses: actions/setup-python@v5

- run: python src/build.py pyrt ${{ matrix.architecture }} 3.7.9
- uses: actions/upload-artifact@v4
with:
name: pyrt_${{ matrix.architecture }}
path: src/pyrt
build_cpp:
runs-on: windows-latest
strategy:
matrix:
architecture: [x86, x64]
steps:
- uses: actions/checkout@v4
with:
python-version: '3.11'
- name: Run build script
run: |
python src/build.py ${{ matrix.architecture }} 3.7.9
# - name: Generate attestation for artifact
# uses: actions/attest-build-provenance@v1
# with:
# subject-path: build/${{ matrix.fname }}.zip
submodules: recursive
- uses: GuillaumeFalourd/setup-windows10-sdk-action@v2
with:
sdk-version: 22621

- run: python src/build.py cpp ${{ matrix.architecture }}
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.fname }}
path: src/build/${{ matrix.fname }}.zip
name: cpp_${{ matrix.architecture }}
path: src/plugins/builds

- name: loadversion
id: loadversion
run: python src/build.py loadversion | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Release LunaTranslator
uses: softprops/action-gh-release@v2

release:
runs-on: windows-latest
needs: [pyrt,build_cpp,loadversion]
strategy:
matrix:
include:
- architecture: x86
fname: LunaTranslator_x86
- architecture: x64
fname: LunaTranslator
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: build
- run: python src/build.py merge ${{ matrix.architecture }}
- uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.loadversion.outputs.version }}
tag_name: ${{ needs.loadversion.outputs.version }}
files: |
src/build/${{ matrix.fname }}.zip
src/build/${{ matrix.fname }}.exe
src/build/${{matrix.fname}}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions src/LunaTranslator/LunaTranslator_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ def prepareqtenv():
import windows

# win7 no vcredist2015
windows.addenvpath("./LunaTranslator/runtime/")
windows.loadlibrary("./LunaTranslator/runtime/PyQt5/Qt5/bin/Qt5Core.dll")
windows.addenvpath("./files/runtime/")
windows.loadlibrary("./files/runtime/PyQt5/Qt5/bin/Qt5Core.dll")

from qtsymbols import QApplication, isqt5, Qt, QFont, QLocale

overridepathexists()

if isqt5:
# 中文字符下不能自动加载
QApplication.addLibraryPath("./LunaTranslator/runtime/PyQt5/Qt5/plugins")
QApplication.addLibraryPath("./files/runtime/PyQt5/Qt5/plugins")
QApplication.setAttribute(Qt.ApplicationAttribute.AA_EnableHighDpiScaling)
QApplication.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps)
if os.path.exists("./LunaTranslator/runtime/PyQt5/Qt5/bin/Qt5WebEngineCore.dll"):
if os.path.exists("./files/runtime/PyQt5/Qt5/bin/Qt5WebEngineCore.dll"):
# maybe use qwebengine

QApplication.setAttribute(Qt.ApplicationAttribute.AA_ShareOpenGLContexts)
Expand Down
2 changes: 1 addition & 1 deletion src/LunaTranslator/gobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def gettempdir(filename):


def testuseqwebengine():
return os.path.exists("./LunaTranslator/runtime/PyQt5/Qt5/bin/Qt5WebEngineCore.dll")
return os.path.exists("./files/runtime/PyQt5/Qt5/bin/Qt5WebEngineCore.dll")


from LunaTranslator import MAINUI
Expand Down
2 changes: 1 addition & 1 deletion src/LunaTranslator/gui/setting_display_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def doinstallqweb(self, dd, base):
target = gobject.gettempdir("QWebEngine/")
zipf.extractall(target)
bit = ["x86", "x64"][platform.architecture()[0] == "64bit"]
copytree(f"{target}/{bit}/PyQt5", "LunaTranslator/runtime/PyQt5")
copytree(f"{target}/{bit}/PyQt5", "files/runtime/PyQt5")
getQMessageBox(self, "成功", "安装成功")


Expand Down
11 changes: 1 addition & 10 deletions src/LunaTranslator/gui/usefulwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os, platform, functools, uuid, json, math, csv, io, pickle
from traceback import print_exc
import windows, qtawesome, winsharedutils, gobject
from webviewpy import webview_native_handle_kind_t, Webview, declare_library_path
from webviewpy import webview_native_handle_kind_t, Webview
from winsharedutils import HTMLBrowser
from myutils.config import _TR, globalconfig, _TRL
from myutils.wrapper import Singleton_close, tryprint
Expand Down Expand Up @@ -1225,15 +1225,6 @@ def get_hwnd(self):

def __init__(self, parent=None, debug=True, usedarklight=True) -> None:
super().__init__(parent)
declare_library_path(
os.path.abspath(
os.path.join(
"files/plugins/",
("DLL32", "DLL64")[platform.architecture()[0] == "64bit"],
"webview",
)
)
)
self.webview = None
self.webview = Webview(debug=debug, window=int(self.winId()))
zoomfunc = winsharedutils.add_ZoomFactorChanged_CALLBACK(
Expand Down
Loading

0 comments on commit f004380

Please sign in to comment.