Skip to content

Commit 97282e4

Browse files
LovingThreshLiuYeGreatV
authored
create a GitHub Action workflow to build and publish an EXE file (#139)
* create a GitHub Action workflow to build and publish an EXE file * Improved GitHub Actions Workflow for Automated Builds of Nightly Build Workflow and Release Build Workflow. * fix GitHub Actions Workflow for Automated Builds. * Update .github/workflows/nightly-build.yml Co-authored-by: Wang Xin <xinwang614@gmail.com> * Update .github/workflows/release-build.yml Co-authored-by: Wang Xin <xinwang614@gmail.com> * Update .github/workflows/nightly-build.yml Co-authored-by: Wang Xin <xinwang614@gmail.com> * Update .github/workflows/release-build.yml Co-authored-by: Wang Xin <xinwang614@gmail.com> --------- Co-authored-by: LiuYe <liuy@everdrawing.com> Co-authored-by: Wang Xin <xinwang614@gmail.com>
1 parent df6f1c4 commit 97282e4

File tree

2 files changed

+184
-0
lines changed

2 files changed

+184
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Nightly Build Windows Executable 🌙
2+
on:
3+
push:
4+
branches: [main, master]
5+
schedule:
6+
# Run automatically at 00:00 UTC daily (08:00 Beijing Time)
7+
- cron: '0 0 * * *'
8+
workflow_dispatch: # Allow manual trigger
9+
jobs:
10+
build-windows:
11+
name: Build Windows executable 🖥️
12+
runs-on: windows-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.x"
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install -r requirements.txt
23+
pip install pyinstaller
24+
pip install paddlepaddle==3.0.0rc1 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/
25+
pip install paddleocr
26+
27+
- name: Regenerate Resources (if using PyQt)
28+
run: |
29+
pip install pyqt5
30+
pyrcc5 -o libs/resources.py resources.qrc
31+
32+
- name: Build executable with PyInstaller
33+
run: |
34+
pyinstaller -c PPOCRLabel.py --collect-all paddleocr --collect-all pyclipper --collect-all imghdr --collect-all skimage --collect-all imgaug --collect-all scipy.io --collect-all lmdb --collect-all paddle --hidden-import=pyqt5 -p ./libs -p ./ -p ./data -p ./resources -F
35+
36+
- name: Store the executable
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: windows-executable
40+
path: dist/*.exe
41+
42+
publish-nightly:
43+
name: Publish Nightly Build to GitHub Release
44+
needs:
45+
- build-windows
46+
runs-on: windows-latest
47+
permissions:
48+
contents: write # IMPORTANT: mandatory for making GitHub Releases
49+
steps:
50+
- name: Download the executable
51+
uses: actions/download-artifact@v4
52+
with:
53+
name: windows-executable
54+
path: dist/
55+
56+
- name: Create or Update Nightly Release
57+
env:
58+
GITHUB_TOKEN: ${{ github.token }}
59+
run: |
60+
$BUILD_DATE="$(Get-Date -Format 'yyyy.MM.dd')"
61+
try {
62+
gh release view nightly --repo ${{ github.repository }} 2>&1 | Out-Null
63+
# Release exists, delete it
64+
gh release delete nightly --yes --repo ${{ github.repository }}
65+
} catch {
66+
# Release doesn't exist, continue
67+
}
68+
# Create new nightly release
69+
gh release create nightly --repo ${{ github.repository }} --prerelease --notes "PPOCRLabel Windows Nightly Build ($BUILD_DATE)"
70+
71+
- name: Rename executable file
72+
run: |
73+
$DATE="$(Get-Date -Format 'yyyyMMdd')"
74+
$FILES = Get-ChildItem -Path "dist" -Filter "*.exe" -File
75+
foreach ($FILE in $FILES) {
76+
$NEW_NAME = "PPOCRLabel-nightly-$DATE.exe"
77+
Copy-Item -Path $FILE.FullName -Destination "dist/$NEW_NAME"
78+
}
79+
80+
- name: Upload executable to GitHub Release
81+
env:
82+
GITHUB_TOKEN: ${{ github.token }}
83+
run: |
84+
$DATE="$(Get-Date -Format 'yyyyMMdd')"
85+
# Upload the exe file directly
86+
gh release upload nightly "dist/PPOCRLabel-nightly-$DATE.exe" --repo ${{ github.repository }} --clobber
87+
88+
- name: Generate SHA256 checksums
89+
run: |
90+
cd dist
91+
Get-FileHash -Algorithm SHA256 *.exe | Out-File -FilePath SHA256SUMS.txt
92+
cd ..
93+
94+
- name: Upload checksums to GitHub Release
95+
env:
96+
GITHUB_TOKEN: ${{ github.token }}
97+
run: |
98+
gh release upload nightly (Join-Path -Path "dist" -ChildPath "SHA256SUMS.txt") --repo ${{ github.repository }} --clobber
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Release Build Windows Executable 🚀
2+
on:
3+
push:
4+
tags:
5+
- 'v*' # Run only when a tag starting with 'v' is pushed
6+
workflow_dispatch: # Allow manual trigger for testing
7+
jobs:
8+
build-windows:
9+
name: Build Windows executable 🖥️
10+
runs-on: windows-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Python
14+
uses: actions/setup-python@v5
15+
with:
16+
python-version: "3.x"
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
pip install -r requirements.txt
21+
pip install pyinstaller
22+
pip install paddlepaddle==3.0.0rc1 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/
23+
pip install paddleocr
24+
25+
- name: Regenerate Resources (if using PyQt)
26+
run: |
27+
pip install pyqt5
28+
pyrcc5 -o libs/resources.py resources.qrc
29+
30+
- name: Build executable with PyInstaller
31+
run: |
32+
pyinstaller -c PPOCRLabel.py --collect-all paddleocr --collect-all pyclipper --collect-all imghdr --collect-all skimage --collect-all imgaug --collect-all scipy.io --collect-all lmdb --collect-all paddle --hidden-import=pyqt5 -p ./libs -p ./ -p ./data -p ./resources -F
33+
34+
- name: Store the executable
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: windows-executable
38+
path: dist/*.exe
39+
40+
publish-release:
41+
name: Publish Release to GitHub
42+
needs:
43+
- build-windows
44+
runs-on: windows-latest
45+
permissions:
46+
contents: write # IMPORTANT: mandatory for making GitHub Releases
47+
steps:
48+
- name: Download the executable
49+
uses: actions/download-artifact@v4
50+
with:
51+
name: windows-executable
52+
path: dist/
53+
54+
- name: Get the version
55+
id: get_version
56+
run: echo "VERSION=${{ github.ref_name }}" >> $env:GITHUB_OUTPUT
57+
58+
- name: Rename executable file
59+
run: |
60+
$TAG_NAME="${{ steps.get_version.outputs.VERSION }}"
61+
$FILES = Get-ChildItem -Path "dist" -Filter "*.exe" -File
62+
foreach ($FILE in $FILES) {
63+
$NEW_NAME = "PPOCRLabel-$TAG_NAME.exe"
64+
Copy-Item -Path $FILE.FullName -Destination "dist/$NEW_NAME"
65+
}
66+
67+
- name: Upload executable to GitHub Release
68+
env:
69+
GITHUB_TOKEN: ${{ github.token }}
70+
run: |
71+
$TAG_NAME="${{ steps.get_version.outputs.VERSION }}"
72+
# Upload the exe file directly
73+
gh release upload $TAG_NAME "dist/PPOCRLabel-$TAG_NAME.exe" --repo ${{ github.repository }} --clobber
74+
75+
- name: Generate SHA256 checksums
76+
run: |
77+
cd dist
78+
Get-FileHash -Algorithm SHA256 *.exe | Out-File -FilePath SHA256SUMS.txt
79+
cd ..
80+
81+
- name: Upload checksums to GitHub Release
82+
env:
83+
GITHUB_TOKEN: ${{ github.token }}
84+
run: |
85+
$TAG_NAME="${{ steps.get_version.outputs.VERSION }}"
86+
gh release upload $TAG_NAME (Join-Path -Path "dist" -ChildPath "SHA256SUMS.txt") --repo ${{ github.repository }} --clobber

0 commit comments

Comments
 (0)