Skip to content

Commit bca0f85

Browse files
authored
Add build workflow via docker (#259)
* Add build workflow via docker * rename docker-compose to docker compose * add twine check and upload to PyPi * add workflow_dispatch * install twine before twine check
1 parent 3a64d24 commit bca0f85

File tree

2 files changed

+80
-4
lines changed

2 files changed

+80
-4
lines changed

.github/workflows/build.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
python-version: ["3.9", "3.10", "3.11"]
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Upgrade pip
29+
run: |
30+
python -m pip install --upgrade pip
31+
32+
- name: Build the manylinux2010 image
33+
run: docker compose build manylinux2010
34+
35+
- name: Build the package for Python ${{ matrix.python-version }}
36+
run: |
37+
version="${{ matrix.python-version }}"
38+
docker compose run -e PYTHON_VERSION=$(echo "$version" | sed 's/\.//') manylinux2010
39+
40+
- name: Upload wheel artifact for Python ${{ matrix.python-version }}
41+
uses: actions/upload-artifact@v3
42+
with:
43+
name: data-validation-wheel-py${{ matrix.python-version }}
44+
path: dist/*.whl
45+
46+
- name: Install built wheel
47+
run: |
48+
pip install twine
49+
twine check dist/*
50+
pip install dist/*.whl
51+
52+
upload_to_pypi:
53+
name: Upload to PyPI
54+
runs-on: ubuntu-latest
55+
if: (github.event_name == 'release' && startsWith(github.ref, 'refs/tags')) || (github.event_name == 'workflow_dispatch')
56+
needs: [build]
57+
environment:
58+
name: pypi
59+
url: https://pypi.org/p/tensorflow-data-validation/
60+
permissions:
61+
id-token: write
62+
steps:
63+
- name: Retrieve wheels
64+
uses: actions/download-artifact@v4.1.8
65+
with:
66+
merge-multiple: true
67+
path: wheels
68+
69+
- name: List the build artifacts
70+
run: |
71+
ls -lAs wheels/
72+
73+
- name: Upload to PyPI
74+
uses: pypa/gh-action-pypi-publish@release/v1.9
75+
with:
76+
packages_dir: wheels/

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ tested at Google.
6666

6767
### 1. Install Docker
6868

69-
Please first install `docker` and `docker-compose` by following the directions:
69+
Please first install `docker` and `docker compose` by following the directions:
7070
[docker](https://docs.docker.com/install/);
71-
[docker-compose](https://docs.docker.com/compose/install/).
71+
[docker compose](https://docs.docker.com/compose/install/).
7272

7373
### 2. Clone the TFDV repository
7474

@@ -86,8 +86,8 @@ branch), pass `-b <branchname>` to the `git clone` command.
8686
Then, run the following at the project root:
8787

8888
```bash
89-
sudo docker-compose build manylinux2010
90-
sudo docker-compose run -e PYTHON_VERSION=${PYTHON_VERSION} manylinux2010
89+
sudo docker compose build manylinux2010
90+
sudo docker compose run -e PYTHON_VERSION=${PYTHON_VERSION} manylinux2010
9191
```
9292
where `PYTHON_VERSION` is one of `{39, 310, 311}`.
9393

0 commit comments

Comments
 (0)