1+ # This workflow will upload a Python Package to Release asset
2+ # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
5+ name : Python Package
6+
7+ on :
8+ # create:
9+ # tags:
10+ # - '**'
11+ push :
12+ branch :
13+ publish
14+
15+ jobs :
16+ release :
17+ name : Create Release
18+ runs-on : ubuntu-latest
19+ steps :
20+ - name : Get the tag version
21+ id : extract_branch
22+ run : echo ::set-output name=branch::${GITHUB_REF#refs/tags/}
23+ shell : bash
24+
25+ - name : Create Release
26+ id : create_release
27+ uses : actions/create-release@v1
28+ env :
29+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
30+ with :
31+ tag_name : ${{ steps.extract_branch.outputs.branch }}
32+ release_name : ${{ steps.extract_branch.outputs.branch }}
33+
34+ wheel :
35+ name : Build Wheel
36+ runs-on : ${{ matrix.os }}
37+ needs : release
38+
39+ strategy :
40+ fail-fast : false
41+ matrix :
42+ # os: [ubuntu-20.04]
43+ os : [ubuntu-18.04]
44+ python-version : ['3.7', '3.8', '3.9', '3.10']
45+ torch-version : [1.11.0, 1.12.0, 1.12.1]
46+ cuda-version : ['113', '116']
47+ exclude :
48+ - torch-version : 1.11.0
49+ cuda-version : ' 116'
50+
51+ steps :
52+ - name : Checkout
53+ uses : actions/checkout@v3
54+
55+ - name : Set up Python
56+ uses : actions/setup-python@v3
57+ with :
58+ python-version : ${{ matrix.python-version }}
59+
60+ - name : Set up Linux Env
61+ if : ${{ runner.os == 'Linux' }}
62+ run : |
63+ sudo rm -rf /usr/share/dotnet
64+ bash .github/workflows/env.sh
65+ echo ${{ needs.create_release.outputs.upload_url }}
66+ echo ${{ needs.steps.extract_branch.outputs.upload_url }}
67+ shell :
68+ bash
69+
70+ - name : Install CUDA ${{ matrix.cuda-version }}
71+ if : ${{ matrix.cuda-version != 'cpu' }}
72+ run : |
73+ bash .github/workflows/cuda/cu${{ matrix.cuda-version }}-${{ runner.os }}.sh
74+ shell :
75+ bash
76+
77+ - name : Check GPU Env
78+ if : ${{ matrix.cuda-version != 'cpu' }}
79+ run : |
80+ source .github/workflows/cuda/cu${{ matrix.cuda-version }}-${{ runner.os }}-env.sh
81+ nvcc --version
82+ shell :
83+ bash
84+
85+ - name : Install PyTorch ${{ matrix.torch-version }}+cu${{ matrix.cuda-version }}
86+ run : |
87+ pip install numpy pyyaml scipy ipython mkl mkl-include ninja cython typing pandas typing-extensions dataclasses && conda clean -ya
88+ pip install --no-index --no-cache-dir torch==${{ matrix.torch-version }} -f https://download.pytorch.org/whl/cu${{ matrix.cuda-version }}/torch_stable.html
89+ python --version
90+ python -c "import torch; print('PyTorch:', torch.__version__)"
91+ python -c "import torch; print('CUDA:', torch.version.cuda)"
92+ python -c "from torch.utils import cpp_extension; print (cpp_extension.CUDA_HOME)"
93+ shell :
94+ bash
95+
96+ - name : Get the tag version
97+ id : extract_branch
98+ run : echo ::set-output name=branch::${GITHUB_REF#refs/tags/}
99+
100+ - name : Get Release with tag
101+ id : get_current_release
102+ uses : joutvhu/get-release@v1
103+ with :
104+ tag_name : ${{ steps.extract_branch.outputs.branch }}
105+ env :
106+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
107+
108+ - name : Build wheel
109+ run : |
110+ export FORCE_CUDA="1"
111+ export PATH=/usr/local/nvidia/bin:/usr/local/nvidia/lib64:$PATH
112+ export LD_LIBRARY_PATH=/usr/local/nvidia/lib64:/usr/local/cuda/lib64:$LD_LIBRARY_PATH
113+ export CUDA_INSTALL_DIR=/usr/local/cuda-11.3$CUDA_INSTALL_DIR
114+ pip install wheel
115+ python setup.py bdist_wheel --dist-dir=dist
116+ tmpname=cu${{ matrix.cuda-version }}torch${{ matrix.torch-version }}
117+ wheel_name=$(ls dist/*whl | xargs -n 1 basename | sed "s/-/+$tmpname-/2")
118+ ls dist/*whl |xargs -I {} mv {} ${wheel_name}
119+ echo "wheel_name=${wheel_name}" >> $GITHUB_ENV
120+
121+ - name : Upload Release Asset
122+ id : upload_release_asset
123+ uses : actions/upload-release-asset@v1
124+ env :
125+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
126+ with :
127+ upload_url : ${{ steps.get_current_release.outputs.upload_url }}
128+ asset_path : ./${{env.wheel_name}}
129+ asset_name : ${{env.wheel_name}}
130+ asset_content_type : application/*
0 commit comments