build: update workflow #16
This file contains 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
name: Generate application | |
on: | |
workflow_dispatch: | |
pull_request: | |
paths: | |
- '**.py' | |
push: | |
branches: | |
- main | |
paths: | |
- '**.py' | |
tags: | |
- "v*.*.*" | |
permissions: | |
contents: write | |
jobs: | |
build: | |
name: Build | |
runs-on: windows-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11.4' | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
python -m venv .venv | |
.venv\Scripts\activate | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt pyinstaller | |
- name: Generate program | |
run: | | |
.venv\Scripts\activate | |
pyinstaller -F --distpath .\dist\March7thAssistant\ -i .\assets\logo\March7th.ico --uac-admin -n "March7th Assistant" --hidden-import imghdr --collect-all paddleocr --add-binary ".venv\Lib\site-packages\paddle\libs;paddle\libs" main.py -y | |
- name: Move assets to dist directory | |
run: | | |
xcopy .\assets\ .\dist\March7thAssistant\assets\ /E /I /Y | |
xcopy .\config.yaml .\dist\March7thAssistant\ /Y | |
xcopy .\README.md .\dist\March7thAssistant\ /Y | |
- name: Upload artifact | |
if: startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/pull/') | |
uses: actions/upload-artifact@v3 | |
with: | |
name: March7thAssistant | |
path: .\dist\ | |
- name: Create zip archive | |
if: startsWith(github.ref, 'refs/tags/') | |
run: powershell Compress-Archive -Path .\dist\March7thAssistant\ -DestinationPath .\dist\March7thAssistant.zip -Force | |
- name: Create release | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: ./dist/March7thAssistant.zip | |