Add manual trigger to deploy to pypi (#2192)

* Create test.yml

* Update deploy-pypi.yml

* Update deploy-pypi.yml

* Delete test.yml

* fixes

* fixes

* check pypi

* check pypi

* version

* version
This commit is contained in:
Abubakar Abid 2022-09-06 13:49:49 -07:00 committed by GitHub
parent 9b4bf627f2
commit 3464673064
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 38 deletions

View File

@ -9,17 +9,17 @@
name: Upload Python Package
on:
workflow_dispatch:
pull_request:
types: closed
branches:
- main
- release**
paths:
- 'gradio/version.txt'
jobs:
deploy:
if: github.event.pull_request.merged == true
if: github.event.pull_request.merged == true || github.event.action == ''
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
@ -27,6 +27,8 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Check new pypi version
run: python scripts/check_pypi.py
- name: Install pnpm
uses: pnpm/action-setup@v2.2.2
with:

17
scripts/check_pypi.py Normal file
View File

@ -0,0 +1,17 @@
import urllib.request
import json
import sys
from pathlib import Path
root_directory = Path(__file__).parent.parent
version = (root_directory / "gradio" / "version.txt").read_text(
encoding='utf8').strip()
with urllib.request.urlopen("https://pypi.org/pypi/gradio/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")

View File

@ -6,8 +6,7 @@ source scripts/helpers.sh
pnpm_required
aws_required
# You should first run `upload_to_pypi.sh` to update the version number and
# pull the latest version of the code.
# You should update the version in version.txt before running this script
new_version="$(cat gradio/version.txt)"
GRADIO_VERSION=$new_version

View File

@ -1,34 +0,0 @@
#!/bin/bash
cd "$(dirname ${0})/.."
source scripts/helpers.sh
git_required
pnpm_required
aws_required
echo "Uploading to PyPI..."
set -e
git pull origin main
old_version="$(cat gradio/version.txt)"
read -p "Current version is ${old_version}. What is the new version? " new_version
echo "So you want to release version ${new_version}. Updating gradio/version.txt..."
echo "${new_version}" > gradio/version.txt
GRADIO_VERSION=$new_version
rm -rf gradio/templates/frontend
rm -rf gradio/templates/cdn
cd ui
pnpm i
pnpm build
GRADIO_VERSION=$new_version pnpm build:cdn
cd ..
aws s3 cp gradio/templates/cdn "s3://gradio/${new_version}/" --recursive # Contact maintainers for credentials
cp gradio/templates/cdn/index.html gradio/templates/frontend/share.html
rm -r dist/*
rm -r build/*
python3 setup.py sdist bdist_wheel
python3 -m twine upload dist/*
git add -A
git commit -m "Updated version to ${new_version}"