|
| 1 | +on: |
| 2 | + workflow_call: |
| 3 | + inputs: |
| 4 | + build_type: |
| 5 | + required: true |
| 6 | + type: string |
| 7 | + platform: |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + |
| 14 | + name: Build ${{ inputs.platform }} ${{ inputs.build_type }} distribution 📦 |
| 15 | + runs-on: ${{ inputs.platform }} |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + |
| 20 | + ## runner will run out of space if we don't clear some up by removing some unused tools |
| 21 | + - name: Clear space |
| 22 | + run: >- |
| 23 | + sudo rm -rf /usr/share/dotnet |
| 24 | + sudo rm -rf /opt/ghc |
| 25 | + sudo rm -rf "/usr/local/share/boost" |
| 26 | + sudo rm -rf "$AGENT_TOOLSDIRECTORY" |
| 27 | + |
| 28 | + #- name: cuda-toolkit |
| 29 | + # if: ${{ startsWith( inputs.build_type, 'cuda' ) }} |
| 30 | + # uses: Jimver/cuda-toolkit@v0.2.17 |
| 31 | + |
| 32 | + #- name: Set up Python |
| 33 | + # uses: actions/setup-python@v5 |
| 34 | + # with: |
| 35 | + # python-version: "3.11" |
| 36 | + |
| 37 | + #- name: Install Protoc |
| 38 | + # run: sudo apt install protobuf-compiler |
| 39 | + |
| 40 | + #- name: Install Python dependencies |
| 41 | + # uses: py-actions/py-dependency-install@v4 |
| 42 | + # with: |
| 43 | + # path: "PyTorch_requirements.txt" |
| 44 | + |
| 45 | + #- name: Install cibuildwheel |
| 46 | + # run: python -m pip install cibuildwheel==2.21.1 |
| 47 | + |
| 48 | + - uses: yezz123/setup-uv@v4 |
| 49 | + |
| 50 | + - uses: pypa/cibuildwheel@v2.21 |
| 51 | + if: runner.os == 'Linux' |
| 52 | + env: |
| 53 | + CIBW_BUILD_VERBOSITY: 1 |
| 54 | + CIBW_ARCHS_LINUX: "x86_64" |
| 55 | + CIBW_SKIP: "*musl*" |
| 56 | + CIBW_BEFORE_ALL: > |
| 57 | + yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo && |
| 58 | + yum clean all && |
| 59 | + yum -y install cuda-toolkit && |
| 60 | + ls -al /usr/local && |
| 61 | + nvcc --version && |
| 62 | + echo nvcc location: && |
| 63 | + which nvcc && |
| 64 | + export CUDACXX="$(which nvcc)" && |
| 65 | + echo $CUDACXX && |
| 66 | + echo gcc version: && |
| 67 | + gcc --version && |
| 68 | + export BUILD_WITH_CUDA=1 && |
| 69 | + export TORCH_CUDA_ARCH_LIST="8.0 8.6 8.9 9.0" |
| 70 | + CIBW_ENVIRONMENT: > |
| 71 | + PATH=$PATH:/usr/local/cuda/bin LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(python -c 'import sys; print(sys.prefix + "/lib/python" + sys.version[:3] + "/site-packages")')/torch/lib/ |
| 72 | + CIBW_BEFORE_BUILD: > |
| 73 | + python -m site && |
| 74 | + python -c 'import sys; print(sys.prefix + "/lib/python" + sys.version[:3] + "/site-packages")' && |
| 75 | + echo $LD_LIBRARY_PATH && |
| 76 | + ls $(python -c 'import sys; print(sys.prefix + "/lib/python" + sys.version[:3] + "/site-packages")') |
| 77 | + |
| 78 | + |
| 79 | + #- name: Build wheels |
| 80 | + # run: python -m cibuildwheel --output-dir dist |
| 81 | + # env: |
| 82 | + # CIBW_BEFORE_BUILD: pip install scikit-build-core |
| 83 | + |
| 84 | + - name: Store the distribution packages |
| 85 | + uses: actions/upload-artifact@v4 |
| 86 | + with: |
| 87 | + name: python-package-distributions |
| 88 | + path: dist/ |
| 89 | + |
| 90 | + |
| 91 | + publish-to-testpypi: |
| 92 | + name: Publish Python 🐍 distribution 📦 to TestPyPI |
| 93 | + needs: |
| 94 | + - build |
| 95 | + runs-on: ${{ inputs.platform }} |
| 96 | + |
| 97 | + environment: |
| 98 | + name: testPyPi-distribution |
| 99 | + url: https://test.pypi.org/p/nuTens |
| 100 | + |
| 101 | + permissions: |
| 102 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 103 | + |
| 104 | + steps: |
| 105 | + - name: Download all the dists |
| 106 | + uses: actions/download-artifact@v4 |
| 107 | + with: |
| 108 | + name: python-package-distributions |
| 109 | + path: dist/ |
| 110 | + - name: Publish distribution 📦 to TestPyPI |
| 111 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 112 | + with: |
| 113 | + repository-url: https://test.pypi.org/legacy/ |
| 114 | + |
| 115 | + publish-to-pypi: |
| 116 | + name: >- |
| 117 | + Publish Python 🐍 distribution 📦 to PyPI |
| 118 | + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes |
| 119 | + needs: |
| 120 | + - build |
| 121 | + runs-on: ${{ inputs.platform }} |
| 122 | + environment: |
| 123 | + name: PyPi-distribution |
| 124 | + url: https://pypi.org/p/nuTens # Replace <package-name> with your PyPI project name |
| 125 | + permissions: |
| 126 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 127 | + |
| 128 | + steps: |
| 129 | + - name: Download all the dists |
| 130 | + uses: actions/download-artifact@v4 |
| 131 | + with: |
| 132 | + name: python-package-distributions |
| 133 | + path: dist/ |
| 134 | + - name: Publish distribution 📦 to PyPI |
| 135 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 136 | + |
| 137 | + github-release: |
| 138 | + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes |
| 139 | + name: >- |
| 140 | + Sign the Python 🐍 distribution 📦 with Sigstore |
| 141 | + and upload them to GitHub Release |
| 142 | + needs: |
| 143 | + - publish-to-pypi |
| 144 | + runs-on: ${{ inputs.platform }} |
| 145 | + |
| 146 | + permissions: |
| 147 | + contents: write # IMPORTANT: mandatory for making GitHub Releases |
| 148 | + id-token: write # IMPORTANT: mandatory for sigstore |
| 149 | + |
| 150 | + steps: |
| 151 | + - name: Download all the dists |
| 152 | + uses: actions/download-artifact@v4 |
| 153 | + with: |
| 154 | + name: python-package-distributions |
| 155 | + path: dist/ |
| 156 | + - name: Sign the dists with Sigstore |
| 157 | + uses: sigstore/gh-action-sigstore-python@v2.1.1 |
| 158 | + with: |
| 159 | + inputs: >- |
| 160 | + ./dist/*.tar.gz |
| 161 | + ./dist/*.whl |
| 162 | + - name: Create GitHub Release |
| 163 | + env: |
| 164 | + GITHUB_TOKEN: ${{ github.token }} |
| 165 | + run: >- |
| 166 | + gh release create |
| 167 | + '${{ github.ref_name }}' |
| 168 | + --repo '${{ github.repository }}' |
| 169 | + --notes "" |
| 170 | + - name: Upload artifact signatures to GitHub Release |
| 171 | + env: |
| 172 | + GITHUB_TOKEN: ${{ github.token }} |
| 173 | + # Upload to GitHub Release using the `gh` CLI. |
| 174 | + # `dist/` contains the built packages, and the |
| 175 | + # sigstore-produced signatures and certificates. |
| 176 | + run: >- |
| 177 | + gh release upload |
| 178 | + '${{ github.ref_name }}' dist/** |
| 179 | + --repo '${{ github.repository }}' |
0 commit comments