-
Notifications
You must be signed in to change notification settings - Fork 101
create a GitHub Action workflow to build and publish an EXE file #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fd8bf58
create a GitHub Action workflow to build and publish an EXE file
1b59d59
Improved GitHub Actions Workflow for Automated Builds of Nightly Buil…
d56a5c5
fix GitHub Actions Workflow for Automated Builds.
13bba95
Update .github/workflows/nightly-build.yml
LovingThresh cfdd273
Update .github/workflows/release-build.yml
LovingThresh 352b658
Update .github/workflows/nightly-build.yml
LovingThresh 6ffd8c7
Update .github/workflows/release-build.yml
LovingThresh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| name: Nightly Build Windows Executable 🌙 | ||
| on: | ||
| push: | ||
| branches: [main, master] | ||
| schedule: | ||
| # Run automatically at 00:00 UTC daily (08:00 Beijing Time) | ||
| - cron: '0 0 * * *' | ||
| workflow_dispatch: # Allow manual trigger | ||
| jobs: | ||
| build-windows: | ||
| name: Build Windows executable 🖥️ | ||
| runs-on: windows-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.x" | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
| pip install pyinstaller | ||
| pip install paddle | ||
| pip install paddleocr | ||
|
|
||
| - name: Regenerate Resources (if using PyQt) | ||
| run: | | ||
| pip install pyqt5 | ||
| pyrcc5 -o libs/resources.py resources.qrc | ||
|
|
||
| - name: Build executable with PyInstaller | ||
| run: | | ||
| 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 | ||
|
|
||
| - name: Store the executable | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: windows-executable | ||
| path: dist/*.exe | ||
|
|
||
| publish-nightly: | ||
| name: Publish Nightly Build to GitHub Release | ||
| needs: | ||
| - build-windows | ||
| runs-on: windows-latest | ||
| permissions: | ||
| contents: write # IMPORTANT: mandatory for making GitHub Releases | ||
| steps: | ||
| - name: Download the executable | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: windows-executable | ||
| path: dist/ | ||
|
|
||
| - name: Create or Update Nightly Release | ||
| env: | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
| run: | | ||
| $BUILD_DATE="$(Get-Date -Format 'yyyy.MM.dd')" | ||
| try { | ||
| gh release view nightly --repo ${{ github.repository }} 2>&1 | Out-Null | ||
| # Release exists, delete it | ||
| gh release delete nightly --yes --repo ${{ github.repository }} | ||
| } catch { | ||
| # Release doesn't exist, continue | ||
| } | ||
| # Create new nightly release | ||
| gh release create nightly --repo ${{ github.repository }} --prerelease --notes "PPOCRLabel Windows Nightly Build ($BUILD_DATE)" | ||
|
|
||
| - name: Rename executable file | ||
| run: | | ||
| $DATE="$(Get-Date -Format 'yyyyMMdd')" | ||
| $FILES = Get-ChildItem -Path "dist" -Filter "*.exe" -File | ||
| foreach ($FILE in $FILES) { | ||
| $NEW_NAME = "PPOCRLabel-nightly-$DATE.exe" | ||
| Copy-Item -Path $FILE.FullName -Destination "dist/$NEW_NAME" | ||
| } | ||
|
|
||
| - name: Upload executable to GitHub Release | ||
| env: | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
| run: | | ||
| $DATE="$(Get-Date -Format 'yyyyMMdd')" | ||
| # Upload the exe file directly | ||
| gh release upload nightly "dist/PPOCRLabel-nightly-$DATE.exe" --repo ${{ github.repository }} --clobber | ||
|
|
||
| - name: Generate SHA256 checksums | ||
| run: | | ||
| cd dist | ||
| Get-FileHash -Algorithm SHA256 *.exe | Out-File -FilePath SHA256SUMS.txt | ||
| cd .. | ||
|
|
||
| - name: Upload checksums to GitHub Release | ||
| env: | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
| run: | | ||
| gh release upload nightly (Join-Path -Path "dist" -ChildPath "SHA256SUMS.txt") --repo ${{ github.repository }} --clobber | ||
LovingThresh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| name: Release Build Windows Executable 🚀 | ||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' # Run only when a tag starting with 'v' is pushed | ||
| workflow_dispatch: # Allow manual trigger for testing | ||
| jobs: | ||
| build-windows: | ||
| name: Build Windows executable 🖥️ | ||
| runs-on: windows-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.x" | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
| pip install pyinstaller | ||
| pip install paddle | ||
LovingThresh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pip install paddleocr | ||
|
|
||
| - name: Regenerate Resources (if using PyQt) | ||
| run: | | ||
| pip install pyqt5 | ||
| pyrcc5 -o libs/resources.py resources.qrc | ||
|
|
||
| - name: Build executable with PyInstaller | ||
| run: | | ||
| 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 | ||
|
|
||
| - name: Store the executable | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: windows-executable | ||
| path: dist/*.exe | ||
|
|
||
| publish-release: | ||
| name: Publish Release to GitHub | ||
| needs: | ||
| - build-windows | ||
| runs-on: windows-latest | ||
| permissions: | ||
| contents: write # IMPORTANT: mandatory for making GitHub Releases | ||
| steps: | ||
| - name: Download the executable | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: windows-executable | ||
| path: dist/ | ||
|
|
||
| - name: Get the version | ||
| id: get_version | ||
| run: echo "VERSION=${{ github.ref_name }}" >> $env:GITHUB_OUTPUT | ||
|
|
||
| - name: Rename executable file | ||
| run: | | ||
| $TAG_NAME="${{ steps.get_version.outputs.VERSION }}" | ||
| $FILES = Get-ChildItem -Path "dist" -Filter "*.exe" -File | ||
| foreach ($FILE in $FILES) { | ||
| $NEW_NAME = "PPOCRLabel-$TAG_NAME.exe" | ||
| Copy-Item -Path $FILE.FullName -Destination "dist/$NEW_NAME" | ||
| } | ||
|
|
||
| - name: Upload executable to GitHub Release | ||
| env: | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
| run: | | ||
| $TAG_NAME="${{ steps.get_version.outputs.VERSION }}" | ||
| # Upload the exe file directly | ||
| gh release upload $TAG_NAME "dist/PPOCRLabel-$TAG_NAME.exe" --repo ${{ github.repository }} --clobber | ||
|
|
||
| - name: Generate SHA256 checksums | ||
| run: | | ||
| cd dist | ||
| Get-FileHash -Algorithm SHA256 *.exe | Out-File -FilePath SHA256SUMS.txt | ||
| cd .. | ||
|
|
||
| - name: Upload checksums to GitHub Release | ||
| env: | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
| run: | | ||
| $TAG_NAME="${{ steps.get_version.outputs.VERSION }}" | ||
| gh release upload $TAG_NAME (Join-Path -Path "dist" -ChildPath "SHA256SUMS.txt") --repo ${{ github.repository }} --clobber | ||
LovingThresh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.