Skip to content

Commit

Permalink
Add: github action build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
sqzw-x committed Jan 13, 2024
1 parent 848f07b commit fd2a4be
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 6 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
on:
push:
branches:
- master
# schedule:
# - cron: '15 20 * * *' # 每天 20:15 UTC+0

jobs:
build-release:
runs-on: windows-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
cache: pip

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller==5.8.0
- name: Build with PyInstaller
run: |
$COMMITSHA = "${{ github.sha }}".Substring(0, 7)
./build-action
- name: Create Release
uses: Shopify/upload-to-release@v2.0.0
with:
name: ${{ github.sha }}
path: dist/MDCx-$COMMITSHA.exe
repo-token: ${{ secrets.GITHUB_TOKEN }}
17 changes: 17 additions & 0 deletions build-action.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$env:PYTHONPATH = "$PWD\src"

$FileName = "MDCx-$COMMITSHA.exe"
Write-Output "Output File: $FileName"

python -m PyInstaller -n "$FileName" -F `
-i resources/Img/MDCx.ico `
-w main.py `
-p "./src" `
--add-data "resources;resources" `
--add-data "libs;." `
--hidden-import socks `
--hidden-import urllib3 `
--hidden-import _cffi_backend `
--collect-all curl_cffi

Write-Output 'Done'
40 changes: 40 additions & 0 deletions build-conda.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
conda activate mdcx-py
$time = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"

# 即时构建, 可选后缀
$suffix = Read-Host -Prompt "Suffix(Optional)"
if ($suffix -ne "")
{
$suffix = "-$suffix"
}
$FileName = "MDCx-$time$suffix.exe"

# 正式版
$release = Read-Host -Prompt "Release version(Optional)"
if ($release -ne "")
{
$FileName = "MDCx-$release$suffix.exe"
}


Write-Output "Output File: $FileName"

pyi-makespec -n "$FileName" -F `
-i resources/Img/MDCx.ico `
-w main.py `
-p "./src" `
--add-data "resources;resources" `
--add-data "libs;." `
--hidden-import socks `
--hidden-import urllib3 `
--hidden-import _cffi_backend `
--collect-all curl_cffi

Remove-Item -Recurse -Force dist

pyinstaller "$FileName.spec"

Remove-Item -Recurse -Force build
Remove-Item -Force "$FileName.spec"

Write-Output 'Done'
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Pillow==9.4.0
PyQt5==5.15.6
PySocks==1.7.1
urllib3==1.25.11
zhconv
langid
zhconv==1.4.3
langid==1.1.6
opencv-contrib-python-headless==4.7.0.68
deepl-translate
ping3
oshash
curl_cffi
deepl-translate==1.2.0
ping3==4.0.4
oshash==0.1.1
curl-cffi==0.5.10

0 comments on commit fd2a4be

Please sign in to comment.