Skip to content

Commit

Permalink
Adds a pypi release action for the gradio python client (#3743)
Browse files Browse the repository at this point in the history
* release action

* fixes

* name

* Update version.txt

* Update version.txt

* update

* fixes

* version

* rename

* action

* fix token

* custom dir

* fixes

* change password

* revert back to token

* scripts

* remove twine
  • Loading branch information
abidlabs authored and dawoodkhan82 committed Apr 5, 2023
1 parent 8e93f8a commit b41335a
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 12 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/deploy-client-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will upload a Python Package when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Gradio Client Python Package

on:
workflow_dispatch:
pull_request:
types: closed
branches:
- main
paths:
- 'client/python/gradio_client/version.txt'

jobs:
deploy:
if: github.event.pull_request.merged == true || github.event.action == ''
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Check new pypi version
run: python client/python/scripts/check_pypi.py
- name: Build pypi package
run: |
client/python/scripts/build_pypi.sh
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: aabid93
password: ${{ secrets.PYPI_GRADIO_CLIENT_TOKEN }}
packages_dir: client/python/dist
2 changes: 1 addition & 1 deletion client/python/gradio_client/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.7
0.0.6b10
9 changes: 9 additions & 0 deletions client/python/scripts/build_pypi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e

cd "$(dirname ${0})/.."

python3 -m pip install build
rm -rf dist/*
rm -rf build/*
python3 -m build
16 changes: 16 additions & 0 deletions client/python/scripts/check_pypi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import json
import sys
import urllib.request
from pathlib import Path

version_file = Path(__file__).parent.parent / "gradio_client" / "version.txt"
version = version_file.read_text(encoding="utf8").strip()

with urllib.request.urlopen("https://pypi.org/pypi/gradio_client/json") as url:
releases = json.load(url)["releases"]

if version in releases:
print(f"Version {version} already exists on PyPI")
sys.exit(1)
else:
print(f"Version {version} does not exist on PyPI")
6 changes: 3 additions & 3 deletions client/python/scripts/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
cd "$(dirname ${0})/.."

echo "Formatting the client library.. Our style follows the Black code style."
ruff --fix test gradio_client
black test gradio_client
ruff --fix .
black .

echo "Type checking the client library with pyright"
pyright gradio_client/*.py
pyright gradio_client/*.py
8 changes: 0 additions & 8 deletions client/python/scripts/upload_pypi.sh

This file was deleted.

0 comments on commit b41335a

Please sign in to comment.