gradio/.github/workflows/deploy-pypi.yml

94 lines
3.1 KiB
YAML
Raw Normal View History

# This workflow will upload a Python Package using Twine 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 Python Package
on:
pull_request:
types: closed
branches:
- main
- release**
paths:
- 'gradio/version.txt'
jobs:
deploy:
2022-06-10 15:36:14 +08:00
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
2022-06-10 15:50:41 +08:00
- name: Install Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
2022-06-10 15:50:41 +08:00
- name: Install pnpm
2022-06-10 15:54:36 +08:00
uses: pnpm/action-setup@v2.2.2
with:
version: 7
2022-06-10 15:50:41 +08:00
- name: Install pip
2022-06-10 16:05:43 +08:00
run: python -m pip install pip wheel
2022-06-10 15:50:41 +08:00
- name: Build pypi package
2022-06-14 04:34:42 +08:00
run: |
export AWS_ACCESS_KEY_ID=${{ secrets.AWSACCESSKEYID }}
export AWS_SECRET_ACCESS_KEY=${{ secrets.AWSSECRETKEY }}
2022-06-14 04:39:18 +08:00
export AWS_DEFAULT_REGION=us-west-2
2022-06-14 04:34:42 +08:00
scripts/gh_action_pypi.sh
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
gh-release:
needs: deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set release name
run: echo "INPUT_NAME=v$(cat gradio/version.txt)" >> $GITHUB_ENV
- name: Release
uses: softprops/action-gh-release@v1
with:
name: ${{ env.INPUT_NAME }}
tag_name: ${{ env.INPUT_NAME }}
spaces-test-release:
runs-on: ubuntu-latest
needs: deploy
steps:
- uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v3
with:
python-version: '3.9'
- name: Install Hub Client Library
run: pip install huggingface-hub==0.8.1
- name: get release name
run: echo "GRADIO_VERSION=$(cat gradio/version.txt)" >> $GITHUB_ENV
- name: Upload kitchen sink to spaces
run: |
python scripts/upload_demo_to_space.py kitchen_sink \
gradio-test-deploys/${{ env.GRADIO_VERSION }}_kitchen_sink \
${{ secrets.SPACES_DEPLOY_TOKEN }} \
--gradio-version ${{ env.GRADIO_VERSION }} > url.txt
echo "SPACE_URL=$(cat url.txt)" >> $GITHUB_ENV
- name: Comment On Release PR
uses: thollander/actions-comment-pull-request@v1
with:
message: |
Deployed a demo with this version at ${{ env.SPACE_URL }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Comment on Slack
uses: slackapi/slack-github-action@v1.21.0
with:
payload: |
{
"text": "@here Checkout out the deploy for ${{ env.GRADIO_VERSION }} at ${{ env.SPACE_URL }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}