-
Notifications
You must be signed in to change notification settings - Fork 23
193 lines (161 loc) · 6.46 KB
/
prerelease.yml
File metadata and controls
193 lines (161 loc) · 6.46 KB
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Pre-release Tesseract
on:
push:
branches:
- main
permissions:
contents: read
jobs:
create_version:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v5
with:
python-version: '3.10'
- name: Create version
run: |
mkdir version
echo "$(python _version.py).dev$(date '+%Y%m%d%H%M%S')" > version/version.txt
cat version/version.txt
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: version-file
path: version
build_wheels:
runs-on: ${{ matrix.os }}
needs: [create_version]
strategy:
fail-fast: true
matrix:
os: [ubuntu-22.04, ubuntu-24.04, macos-14]
python-version: ['3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: version-file
path: version
- name: Set up Bazel
uses: bazel-contrib/setup-bazel@083175551ceeceebc757ebee2127fde78840ca77 # 0.18.0
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true
- name: Set Python Version
env:
TARGET_PYTHON: ${{ matrix.python-version }}
run: |
echo "set version to ${TARGET_PYTHON}"
python _update_bazel_py_version.py $TARGET_PYTHON
- name: Build package
env:
TARGET_PYTHON: ${{ matrix.python-version }}
run: |
glibc_version=$(ldd --version | awk '/ldd/{print $NF}')
export GLIBC_VERSION="${glibc_version//./_}"
echo $GLIBC_VERSION
sed "s/^MANYLINUX_VERSION.*/MANYLINUX_VERSION=\"manylinux_${GLIBC_VERSION}_x86_64.manylinux2014_x86_64\"/" BUILD -i || true
bazel build --define GLIBC_VERSION=$GLIBC_VERSION --define TARGET_VERSION="$(python -c "print(\"py${TARGET_PYTHON}\".replace(\".\", \"\"))")" --define VERSION="$(cat version/version.txt)" :tesseract_decoder_wheel
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: python-wheels-${{ matrix.os }}-${{ matrix.python-version }}
path: ./bazel-bin/*.whl
build_wheels_for_legacy_systems:
runs-on: ${{ matrix.os }}
needs: [create_version]
strategy:
fail-fast: true
matrix:
os: [ubuntu-22.04]
python-version: ['3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: version-file
path: version
- name: Set Python Version
env:
TARGET_PYTHON: ${{ matrix.python-version }}
run: |
echo "set version to ${TARGET_PYTHON}"
python _update_bazel_py_version.py $TARGET_PYTHON
- name: build custom C++ toolchain
env:
TARGET_PYTHON: ${{ matrix.python-version }}
run: |
. devtools/build_with_custom_toolchain.sh
- name: Set up Bazel
uses: bazel-contrib/setup-bazel@083175551ceeceebc757ebee2127fde78840ca77 # 0.18.0
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true
- name: Build package
env:
TARGET_PYTHON: ${{ matrix.python-version }}
run: |
export GLIBC_VERSION=2_28
echo $GLIBC_VERSION
sed "s/^MANYLINUX_VERSION.*/MANYLINUX_VERSION=\"manylinux_${GLIBC_VERSION}_x86_64.manylinux2014_x86_64\"/" BUILD -i || true
bazel build --define GLIBC_VERSION=$GLIBC_VERSION --define TARGET_VERSION="$(python -c "print(\"py${TARGET_PYTHON}\".replace(\".\", \"\"))")" --define VERSION="$(cat version/version.txt)" :tesseract_decoder_wheel
- name: Test
run: |
pip install pytest sinter auditwheel
auditwheel show $(ls bazel-bin/*.whl)
pip install bazel-bin/*.whl
mv src/py/ src/_lib # rename because `py` causes pytest issues.
rm src/_lib/stub_test.py # ignore this test because it uses os flags that are set by bazel
rm src/_lib/tesseract_sinter_compat_test.py # ignore this test because it mixes np.int64 and int which doesn't work with older python versions
PYTHONPATH=src/_lib/::$PYTHONPATH pytest src/_lib/
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: python-wheels-${{ matrix.os }}-${{ matrix.python-version }}-legacy
path: ./bazel-bin/*.whl
release-wheels:
name: Publish all wheels
needs: [build_wheels,build_wheels_for_legacy_systems]
runs-on: ubuntu-24.04
steps:
- name: Download build artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
pattern: python-wheels-*
merge-multiple: true
path: wheelhouse/
- name: Publish package to testpypi
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
with:
repository_url: https://test.pypi.org/legacy/
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
packages_dir: wheelhouse/
verbose: true
- name: Publish package to pypi
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
packages_dir: wheelhouse/