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-08-11 22:54:56 +08:00
|
|
|
comment-spaces-start:
|
|
|
|
uses: "./.github/workflows/comment-queue.yml"
|
|
|
|
secrets:
|
|
|
|
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
|
|
|
with:
|
|
|
|
pr_number: ${{ github.event.pull_request.number }}
|
|
|
|
message: spaces~pending~null
|
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
|
2023-08-11 22:54:56 +08:00
|
|
|
id: get_pr_number
|
2022-08-17 00:07:20 +08:00
|
|
|
run: |
|
|
|
|
python -c "import os;print(os.environ['GITHUB_REF'].split('/')[2])" > pr_number.txt
|
2023-08-11 22:54:56 +08:00
|
|
|
echo "PR_NUMBER=$(cat pr_number.txt)" >> $GITHUB_OUTPUT
|
|
|
|
echo "GRADIO_VERSION=$(python -c 'import requests;print(requests.get("https://pypi.org/pypi/gradio/json").json()["info"]["version"])')" >> $GITHUB_OUTPUT
|
2023-01-04 03:24:01 +08:00
|
|
|
- name: Build pr package
|
2022-09-15 05:39:46 +08:00
|
|
|
run: |
|
2023-08-11 22:54:56 +08:00
|
|
|
echo ${{ steps.get_pr_number.outputs.GRADIO_VERSION }} > gradio/version.txt
|
|
|
|
pnpm i --frozen-lockfile --ignore-scripts
|
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:
|
2023-08-11 22:54:56 +08:00
|
|
|
name: gradio-${{ steps.get_pr_number.outputs.GRADIO_VERSION }}-py3-none-any.whl
|
|
|
|
path: dist/gradio-${{ steps.get_pr_number.outputs.GRADIO_VERSION }}-py3-none-any.whl
|
2022-08-17 00:07:20 +08:00
|
|
|
- name: Set up Demos
|
2023-08-11 21:32:01 +08:00
|
|
|
run: |
|
2023-08-11 22:54:56 +08:00
|
|
|
python scripts/copy_demos.py https://gradio-builds.s3.amazonaws.com/${{ github.sha }}/gradio-${{ steps.get_pr_number.outputs.GRADIO_VERSION }}-py3-none-any.whl \
|
2023-08-11 21:32:01 +08:00
|
|
|
"gradio-client @ git+https://github.com/gradio-app/gradio@${{ github.sha }}#subdirectory=client/python"
|
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-08-11 22:54:56 +08:00
|
|
|
python -c "import json; json.dump({'gh_sha': '${{ github.sha }}', 'pr_number': ${{ steps.get_pr_number.outputs.pr_number }}, 'version': '${{ steps.get_pr_number.outputs.GRADIO_VERSION }}', 'wheel': 'gradio-${{ steps.get_pr_number.outputs.GRADIO_VERSION }}-py3-none-any.whl'}, open('metadata.json', 'w'))"
|
2023-01-04 03:24:01 +08:00
|
|
|
- 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
|