2023-01-04 03:24:01 +08:00
|
|
|
name: Build PR Artifacts
|
2022-08-17 00:07:20 +08:00
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
|
|
|
|
jobs:
|
2023-01-04 03:24:01 +08:00
|
|
|
build_pr:
|
2022-08-17 00:07:20 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Install Python
|
2023-06-22 02:15:52 +08:00
|
|
|
uses: actions/setup-python@v4
|
2022-08-17 00:07:20 +08:00
|
|
|
with:
|
|
|
|
python-version: '3.9'
|
|
|
|
- name: Install pnpm
|
2023-06-02 16:00:00 +08:00
|
|
|
uses: pnpm/action-setup@v2
|
2022-08-17 00:07:20 +08:00
|
|
|
with:
|
2023-06-02 16:13:58 +08:00
|
|
|
version: 8
|
2022-12-03 01:53:42 +08:00
|
|
|
- uses: actions/setup-node@v3
|
|
|
|
with:
|
2023-06-02 16:00:00 +08:00
|
|
|
node-version: 18
|
2022-12-03 01:53:42 +08:00
|
|
|
cache: pnpm
|
2023-03-28 07:12:58 +08:00
|
|
|
cache-dependency-path: pnpm-lock.yaml
|
2022-08-17 00:07:20 +08:00
|
|
|
- name: Install pip
|
2022-09-15 05:39:46 +08:00
|
|
|
run: python -m pip install build requests
|
2022-08-17 00:07:20 +08:00
|
|
|
- name: Get PR Number
|
|
|
|
run: |
|
|
|
|
python -c "import os;print(os.environ['GITHUB_REF'].split('/')[2])" > pr_number.txt
|
|
|
|
echo "PR_NUMBER=$(cat pr_number.txt)" >> $GITHUB_ENV
|
|
|
|
echo "GRADIO_VERSION=$(python -c 'import requests;print(requests.get("https://pypi.org/pypi/gradio/json").json()["info"]["version"])')" >> $GITHUB_ENV
|
2023-01-04 03:24:01 +08:00
|
|
|
- name: Build pr package
|
2022-09-15 05:39:46 +08:00
|
|
|
run: |
|
2022-08-17 00:07:20 +08:00
|
|
|
echo ${{ env.GRADIO_VERSION }} > gradio/version.txt
|
2022-12-03 01:53:42 +08:00
|
|
|
pnpm i --frozen-lockfile
|
2022-08-17 00:07:20 +08:00
|
|
|
pnpm build
|
2022-09-15 05:39:46 +08:00
|
|
|
python3 -m build -w
|
2022-12-03 01:53:42 +08:00
|
|
|
env:
|
|
|
|
NODE_OPTIONS: --max_old_space_size=8192
|
2023-01-04 03:24:01 +08:00
|
|
|
- name: Upload wheel
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: gradio-${{ env.GRADIO_VERSION }}-py3-none-any.whl
|
|
|
|
path: dist/gradio-${{ env.GRADIO_VERSION }}-py3-none-any.whl
|
2022-08-17 00:07:20 +08:00
|
|
|
- name: Set up Demos
|
|
|
|
run: python scripts/copy_demos.py https://gradio-builds.s3.amazonaws.com/${{ github.sha }}/gradio-${{ env.GRADIO_VERSION }}-py3-none-any.whl
|
2023-01-04 03:24:01 +08:00
|
|
|
- name: Upload all_demos
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: all_demos
|
|
|
|
path: demo/all_demos
|
|
|
|
- name: Create metadata artifact
|
2022-08-17 00:07:20 +08:00
|
|
|
run: |
|
2023-01-04 03:24:01 +08:00
|
|
|
python -c "import json; json.dump({'gh_sha': '${{ github.sha }}', 'pr_number': ${{ env.PR_NUMBER }}, 'version': '${{ env.GRADIO_VERSION }}', 'wheel': 'gradio-${{ env.GRADIO_VERSION }}-py3-none-any.whl'}, open('metadata.json', 'w'))"
|
|
|
|
- name: Upload metadata
|
|
|
|
uses: actions/upload-artifact@v3
|
2022-08-17 00:07:20 +08:00
|
|
|
with:
|
2023-01-04 03:24:01 +08:00
|
|
|
name: metadata.json
|
|
|
|
path: metadata.json
|