forked from meta-pytorch/data
-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (107 loc) · 3.69 KB
/
_build_test_upload.yml
File metadata and controls
113 lines (107 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Build, Test and Upload Wheel
on:
workflow_call:
inputs:
branch:
required: true
type: string
pre_dev_release:
required: true
type: boolean
pytorch_version:
required: true
type: string
permissions:
id-token: write
contents: write
jobs:
get_release_type:
runs-on: ubuntu-latest
outputs:
type: ${{ steps.get_release_type.outputs.type }}
steps:
- name: Get Release Type
run: |
if [[ "${{ inputs.branch }}" == v* ]] && [[ ${{ inputs.pre_dev_release }} == false ]]; then
RELEASE_TYPE=official
elif [[ "${{ inputs.branch }}" == release/* ]] && [[ ${{ inputs.pre_dev_release }} == true ]]; then
RELEASE_TYPE=test
else
if [[ "${{ github.base_ref }}" == release/* ]]; then
RELEASE_TYPE=test
else
RELEASE_TYPE=nightly
fi
fi
echo "Release Type: $RELEASE_TYPE"
echo "type=$RELEASE_TYPE" >> $GITHUB_OUTPUT
id: get_release_type
build_docs:
if: always() && inputs.branch != ''
needs: get_release_type
runs-on: ubuntu-latest
steps:
- name: Setup Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
submodules: recursive
- name: Install Dependencies
run: |
echo `python3 --version`
python3 -m pip install --upgrade pip
python3 -m pip install setuptools
python3 -m pip install matplotlib
sudo apt-get install -y yarn
- name: Install PyTorch & TorchData
run: |
pip3 install numpy
# Add version requirement to PyTorch except nightly release
if [[ -z "${{ inputs.pytorch_version }}" ]]; then
PYTORCH_VERSION=torch
else
PYTORCH_VERSION=torch==${{ inputs.pytorch_version }}
fi
PIP_CHANNEL=${{ needs.get_release_type.outputs.type }}
if [[ $PIP_CHANNEL == 'official' ]]; then
pip3 install "$PYTORCH_VERSION" -f https://download.pytorch.org/whl/torch_stable.html
else
pip3 install --pre "$PYTORCH_VERSION" --index-url "https://download.pytorch.org/whl/$PIP_CHANNEL/cpu"
fi
pip3 install -r requirements.txt
pip3 install .
- name: Check env
run: echo `which spinx-build`
- name: Build the docset
run: |
cd ./docs
sudo apt-get install -y graphviz
pip3 install -r requirements.txt
make html
cd ..
- name: Export Target Folder
run: |
TARGET_FOLDER=${{ inputs.branch }}
if [[ $TARGET_FOLDER == release/* ]]; then
TARGET_FOLDER=${TARGET_FOLDER:8}
elif [[ $TARGET_FOLDER == tags/* ]]; then
TARGET_FOLDER=${TARGET_FOLDER:5}
elif [[ $TARGET_FOLDER == v* ]] && [[ ${{ inputs.pre_dev_release }} == false ]]; then
if [[ $TARGET_FOLDER == v*.*.* ]]; then
TARGET_FOLDER=${TARGET_FOLDER%.*}
fi
TARGET_FOLDER=${TARGET_FOLDER:1}
fi
echo "value=$TARGET_FOLDER" >> $GITHUB_OUTPUT
id: target_folder
- name: Deploy
uses: JamesIves/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages # The branch the action should deploy to.
folder: docs/build/html # The folder the action should deploy.
target-folder: ${{ steps.target_folder.outputs.value }} # The destination folder the action should deploy to.