Skip to content

Commit 3cdd4ed

Browse files
committed
Add workflow for building and publishing wheels
1 parent a3cfc96 commit 3cdd4ed

File tree

3 files changed

+280
-14
lines changed

3 files changed

+280
-14
lines changed

.github/reusable-build/action.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Reusable action which builds serving
2+
3+
inputs:
4+
python-version:
5+
description: 'Python version'
6+
required: true
7+
env:
8+
BAZEL_VERSION: '6.5.0'
9+
runs:
10+
using: 'composite'
11+
steps:
12+
# - name: Build the package for Python ${{ inputs.python-version }}
13+
# shell: bash
14+
# run: |
15+
# docker build -f tensorflow_serving/tools/docker/Dockerfile.devel
16+
17+
- name: Install runner dependencies
18+
run: |
19+
sudo apt update
20+
sudo apt install -y build-essential curl git swig unzip wget zip zlib1g-dev
21+
22+
- uses: bazel-contrib/[email protected]
23+
name: Set up Bazel
24+
with:
25+
# Avoid downloading Bazel every time.
26+
bazelisk-cache: true
27+
# Store build cache per workflow.
28+
disk-cache: ${{ github.workflow }}-${{ hashFiles('.github/workflows/wheels.yml') }}
29+
# Share repository cache between workflows.
30+
repository-cache: true
31+
32+
- name: Verify bazel installation
33+
run: |
34+
which bazel
35+
bazel info
36+
bazel version
37+
38+
- name: Build the package with bazel
39+
run: |
40+
bazel build --color=yes --curses=yes ${TF_SERVING_BAZEL_OPTIONS} --verbose_failures --output_filter=DONT_MATCH_ANYTHING ${TF_SERVING_BUILD_OPTIONS} --config=kokoro tensorflow_serving/model_servers:tensorflow_model_server
41+
# cp bazel-bin/tensorflow_serving/model_servers/tensorflow_model_server /usr/local/bin
42+
43+
# Build and install TensorFlow Serving API
44+
bazel build --color=yes --curses=yes ${TF_SERVING_BAZEL_OPTIONS} --verbose_failures --output_filter=DONT_MATCH_ANYTHING ${TF_SERVING_BUILD_OPTIONS} --config=kokoro tensorflow_serving/tools/pip_package:build_pip_package
45+
bazel-bin/tensorflow_serving/tools/pip_package/build_pip_package /tmp/pip
46+
cp /tmp/pip/tensorflow_serving_api-*.whl ./dist/
47+
# pip --no-cache-dir install --upgrade /tmp/pip/tensorflow_serving_api-*.whl
48+
49+
- name: Upload wheel artifact for Python ${{ inputs.python-version }}
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: ml-metadata-wheel-py${{ inputs.python-version }}
53+
path: dist/tensorflow_serving_api-*.whl

.github/workflows/wheels.yml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build serving wheels
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
release:
7+
types: [published]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.9", "3.10", "3.11"]
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Build package
21+
id: build-package
22+
uses: ./.github/reusable-build
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
31+
- name: List and check wheels
32+
shell: bash
33+
run: |
34+
# Pin transitive dependency on pkginfo until https://github.com/pypa/twine/issues/1070 is
35+
# fixed
36+
pip install twine pkginfo>=1.10.0
37+
${{ matrix.ls || 'ls -lh' }} wheels/
38+
twine check wheels/*
39+
40+
41+
upload_to_pypi:
42+
name: Upload to PyPI
43+
runs-on: ubuntu-latest
44+
if: (github.event_name == 'release' && startsWith(github.ref, 'refs/tags')) || (github.event_name == 'workflow_dispatch')
45+
needs: [build]
46+
environment:
47+
name: pypi
48+
url: https://pypi.org/p/tensorflow_serving/
49+
permissions:
50+
id-token: write
51+
steps:
52+
- name: Retrieve wheels
53+
uses: actions/download-artifact@v4
54+
with:
55+
merge-multiple: true
56+
path: wheels
57+
58+
- name: List the build artifacts
59+
run: |
60+
ls -lAs wheels/
61+
62+
- name: Upload to PyPI
63+
uses: pypa/gh-action-pypi-publish@release/v1
64+
with:
65+
packages_dir: wheels/

.gitignore

+162-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,162 @@
1-
node_modules
2-
/bazel-bin
3-
/bazel-ci_build-cache
4-
/bazel-genfiles
5-
/bazel-out
6-
/bazel-serving
7-
/bazel-tensorflow
8-
/bazel-tensorflow_serving
9-
/bazel-testlogs
10-
/bazel-tf
11-
/bazel-workspace
12-
/third_party/py/numpy/numpy_include
13-
/util/python/python_include
14-
/util/python/python_lib
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
#poetry.lock
103+
104+
# pdm
105+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106+
#pdm.lock
107+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108+
# in version control.
109+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
110+
.pdm.toml
111+
.pdm-python
112+
.pdm-build/
113+
114+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115+
__pypackages__/
116+
117+
# Celery stuff
118+
celerybeat-schedule
119+
celerybeat.pid
120+
121+
# SageMath parsed files
122+
*.sage.py
123+
124+
# Environments
125+
.env
126+
.venv
127+
env/
128+
venv/
129+
ENV/
130+
env.bak/
131+
venv.bak/
132+
133+
# Spyder project settings
134+
.spyderproject
135+
.spyproject
136+
137+
# Rope project settings
138+
.ropeproject
139+
140+
# mkdocs documentation
141+
/site
142+
143+
# mypy
144+
.mypy_cache/
145+
.dmypy.json
146+
dmypy.json
147+
148+
# Pyre type checker
149+
.pyre/
150+
151+
# pytype static type analyzer
152+
.pytype/
153+
154+
# Cython debug symbols
155+
cython_debug/
156+
157+
# PyCharm
158+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160+
# and can be added to the global gitignore or merged into this file. For a more nuclear
161+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162+
#.idea/

0 commit comments

Comments
 (0)