Skip to content

Commit 312f14b

Browse files
xingyousongcopybara-github
authored andcommitted
Create a dev pypi push variant.
PiperOrigin-RevId: 623978390
1 parent 1398f75 commit 312f14b

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This workflow will upload a dev Python Package to TestPyPI using Twine when a main branch commit
2+
# is pushed. For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
# NOTE: User will need to add a extra url to `requirements.txt`: https://stackoverflow.com/questions/29281587/format-a-requirements-txt-file-for-pip-where-one-or-more-packages-have-a-differe
4+
5+
name: pypi-dev
6+
7+
# PyPI push triggers whenever we push a commit to main.
8+
on:
9+
push:
10+
branches:
11+
- main
12+
13+
jobs:
14+
deploy:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: '3.10' # 3.11 breaks grpcio-tools.
22+
- name: Install dependencies
23+
run: |
24+
sudo apt-get install -y libprotobuf-dev
25+
python -m pip install --upgrade pip
26+
pip install setuptools wheel twine grpcio-tools==1.48.2
27+
- name: Build and publish
28+
env:
29+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
30+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
31+
run: |
32+
python setup.py --dev sdist bdist_wheel
33+
twine upload --repository testpypi dist/*

setup.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
from __future__ import annotations
1616

1717
"""Setup for pip package."""
18+
19+
import datetime
1820
import itertools
1921
import os
2022
import sys
@@ -68,6 +70,12 @@ def run(self):
6870

6971

7072
_VERSION = _get_version()
73+
_NAME = 'google-vizier'
74+
75+
if '--dev' in sys.argv:
76+
sys.argv.remove('--dev')
77+
_VERSION += '.dev' + datetime.datetime.now().strftime('%Y%m%d-%H%M%S')
78+
_NAME += '-dev'
7179

7280
extras_require = {
7381
'jax': _parse_requirements('requirements-jax.txt'),
@@ -82,7 +90,7 @@ def run(self):
8290
)
8391

8492
setup(
85-
name='google-vizier',
93+
name=_NAME,
8694
version=_VERSION,
8795
url='https://github.com/google/vizier',
8896
license='Apache License 2.0',

0 commit comments

Comments
 (0)