|
| 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 |
| 3 | + |
| 4 | +name: Create Release |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - v* |
| 10 | + |
| 11 | +# Needed to create release and upload assets |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + release: |
| 17 | + # Retrieve tag and create release |
| 18 | + name: Create Release |
| 19 | + runs-on: ubuntu-latest |
| 20 | + outputs: |
| 21 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 22 | + steps: |
| 23 | + - name: Checkout |
| 24 | + uses: actions/checkout@v3 |
| 25 | + |
| 26 | + - name: Extract branch info |
| 27 | + shell: bash |
| 28 | + run: | |
| 29 | + echo "release_tag=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV |
| 30 | +
|
| 31 | + - name: Create Release |
| 32 | + id: create_release |
| 33 | + uses: "actions/github-script@v6" |
| 34 | + env: |
| 35 | + RELEASE_TAG: ${{ env.release_tag }} |
| 36 | + with: |
| 37 | + github-token: "${{ secrets.GITHUB_TOKEN }}" |
| 38 | + script: | |
| 39 | + const script = require('.github/workflows/scripts/create_release.js') |
| 40 | + await script(github, context, core) |
| 41 | +
|
| 42 | + wheel: |
| 43 | + name: Build Wheel |
| 44 | + runs-on: ${{ matrix.os }} |
| 45 | + needs: release |
| 46 | + |
| 47 | + strategy: |
| 48 | + fail-fast: false |
| 49 | + matrix: |
| 50 | + os: ['ubuntu-20.04'] |
| 51 | + python-version: ['3.8', '3.9', '3.10', '3.11'] |
| 52 | + cuda-version: ['11.8'] # Github runner can't build anything older than 11.8 |
| 53 | + |
| 54 | + steps: |
| 55 | + - name: Checkout |
| 56 | + uses: actions/checkout@v3 |
| 57 | + |
| 58 | + - name: Set up Linux Env |
| 59 | + if: ${{ runner.os == 'Linux' }} |
| 60 | + run: | |
| 61 | + bash -x .github/workflows/scripts/env.sh |
| 62 | +
|
| 63 | + - name: Set up Python |
| 64 | + uses: actions/setup-python@v4 |
| 65 | + with: |
| 66 | + python-version: ${{ matrix.python-version }} |
| 67 | + |
| 68 | + - name: Install CUDA ${{ matrix.cuda-version }} |
| 69 | + run: | |
| 70 | + bash -x .github/workflows/scripts/cuda-install.sh ${{ matrix.cuda-version }} ${{ matrix.os }} |
| 71 | +
|
| 72 | + - name: Install PyTorch-cu${{ matrix.cuda-version }} |
| 73 | + run: | |
| 74 | + bash -x .github/workflows/scripts/pytorch-install.sh ${{ matrix.python-version }} ${{ matrix.cuda-version }} |
| 75 | +
|
| 76 | + - name: Build wheel |
| 77 | + shell: bash |
| 78 | + run: | |
| 79 | + bash -x .github/workflows/scripts/build.sh ${{ matrix.python-version }} ${{ matrix.cuda-version }} |
| 80 | + wheel_name=$(ls dist/*whl | xargs -n 1 basename) |
| 81 | + asset_name=${wheel_name//"linux"/"manylinux1"} |
| 82 | + echo "wheel_name=${wheel_name}" >> $GITHUB_ENV |
| 83 | + echo "asset_name=${asset_name}" >> $GITHUB_ENV |
| 84 | + |
| 85 | + - name: Upload Release Asset |
| 86 | + uses: actions/upload-release-asset@v1 |
| 87 | + env: |
| 88 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 89 | + with: |
| 90 | + upload_url: ${{ needs.release.outputs.upload_url }} |
| 91 | + asset_path: ./dist/${{ env.wheel_name }} |
| 92 | + asset_name: ${{ env.asset_name }} |
| 93 | + asset_content_type: application/* |
| 94 | + |
| 95 | + # (Danielkinz): This last step will publish the .whl to pypi. Warning: untested |
| 96 | + # - name: Publish package |
| 97 | + # uses: pypa/gh-action-pypi-publish@release/v1.8 |
| 98 | + # with: |
| 99 | + # repository-url: https://test.pypi.org/legacy/ |
| 100 | + # password: ${{ secrets.PYPI_API_TOKEN }} |
| 101 | + # skip-existing: true |
0 commit comments