-
-
Notifications
You must be signed in to change notification settings - Fork 389
158 lines (136 loc) · 5.47 KB
/
package_ocrweb.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Package ocrweb
on:
push:
branches: main
paths:
- 'ocrweb/rapidocr_web/ocrweb.py'
- 'ocrweb/rapidocr_web/task.py'
- 'ocrweb/rapidocr_web/static/**'
- 'ocrweb/rapidocr_web/templates/**'
env:
package_name: RapidOCRWeb
rapidocr_web_dir: ocrweb/rapidocr_web/
jobs:
create_release:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: get_cur_time
uses: srfrnk/current-time@master
id: get_cur_time
with:
format: YYYY-MM-DD-HH-mm-ss
- name: create_release
id: create_release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: Draft-${{ steps.get_cur_time.outputs.formattedTime }}
prerelease: false
draft: true
build_windows:
name: build_windows
runs-on: ${{ matrix.os }}
needs: create_release
strategy:
matrix:
os: ['windows-2022', 'windows-2019']
steps:
- name: Pull latest code
uses: actions/checkout@v4
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: '3.7'
architecture: 'x64'
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install environments
run: |
pip3 install Pillow pyinstaller Flask>=2.1.0 rapidocr_onnxruntime>=1.2.8 get_pypi_latest_version
- name: Run pyinstaller
id: run_pyinstaller
shell: bash
run: |
cd ${{ env.rapidocr_web_dir }}
pyinstaller ocrweb.spec
cp -r static templates dist/${{ env.package_name }}
rm dist/${{ env.package_name }}/cv2/opencv_videoio_ffmpe*.dll || echo "未找到opencv_videoio_ffmpeg"
echo "VERSION=$(get_pypi_latest_version rapid_videocr)" >> $GITHUB_OUTPUT
- name: Concat file path
id: concat_file_path
shell: bash
env:
ZIP_WIN_NAME: ${{ env.package_name }}-${{ steps.run_pyinstaller.outputs.VERSION }}-${{ matrix.os }}-${{ runner.arch }}-no-installer.zip
Win_DIST_DIR: ${{ github.workspace }}\ocrweb\rapidocr_web\dist
run: |
echo "ZIP_NAME=$ZIP_WIN_NAME" >> $GITHUB_OUTPUT
echo "Win_PACKAGE_DIR=$Win_DIST_DIR\${{ env.package_name }}" >> $GITHUB_OUTPUT
echo "Win_ZIP_FULL_PATH=$Win_DIST_DIR\\$ZIP_WIN_NAME" >> $GITHUB_OUTPUT
- name: Zip package
run: |
powershell Compress-Archive ${{ steps.concat_file_path.outputs.Win_PACKAGE_DIR }} ${{ steps.concat_file_path.outputs.Win_ZIP_FULL_PATH }}
- name: Upload release asset
id: upload-release-asset-windows
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ${{ steps.concat_file_path.outputs.Win_ZIP_FULL_PATH }}
asset_name: ${{ steps.concat_file_path.outputs.ZIP_NAME }}
asset_content_type: application/zip
build_linux:
name: build_linux
runs-on: ${{ matrix.os }}
needs: create_release
strategy:
matrix:
os: ['ubuntu-20.04', 'ubuntu-22.04', 'macos-13', 'macos-12', 'macos-11']
steps:
- name: Pull latest code
uses: actions/checkout@v4
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: '3.7'
architecture: 'x64'
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install environments
run: |
pip3 install Pillow pyinstaller Flask>=2.1.0 rapidocr_onnxruntime>=1.2.8 get_pypi_latest_version
- name: Run pyinstaller
id: run_pyinstaller
shell: bash
run: |
cd ocrweb/rapidocr_web/
pyinstaller ocrweb.spec
cp -r static templates dist/${{ env.package_name }}
rm dist/${{ env.package_name }}/cv2/opencv_videoio_ffmpe*.dll || echo "未找到opencv_videoio_ffmpeg"
echo "VERSION=$(get_pypi_latest_version rapid_videocr)" >> $GITHUB_OUTPUT
- name: Concat file path
id: concat_file_path
env:
ZIP_NAME: ${{ env.package_name }}-${{ steps.run_pyinstaller.outputs.VERSION }}-${{ matrix.os }}-${{ runner.arch }}-no-installer.zip
Linux_DIST_DIR: ${{ github.workspace }}/ocrweb/rapidocr_web/dist
run: |
echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_OUTPUT
echo "Linux_PACKAGE_DIR=$Linux_DIST_DIR/${{ env.package_name }}" >> $GITHUB_OUTPUT
echo "Linux_ZIP_FULL_PATH=$Linux_DIST_DIR/$ZIP_NAME" >> $GITHUB_OUTPUT
echo "Linux_DIST_DIR=$Linux_DIST_DIR" >> $GITHUB_OUTPUT
- name: Zip package
run: |
cd ${{ steps.concat_file_path.outputs.Linux_DIST_DIR }}
zip -r ${{ steps.concat_file_path.outputs.ZIP_NAME }} ${{ env.package_name }}
- name: Upload release asset
id: upload-release-asset-linux-macOS
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ${{ steps.concat_file_path.outputs.Linux_ZIP_FULL_PATH }}
asset_name: ${{ steps.concat_file_path.outputs.ZIP_NAME }}
asset_content_type: application/zip