publish.yml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. name: Create Release
  4. on:
  5. push:
  6. tags:
  7. - v*
  8. # Needed to create release and upload assets
  9. permissions:
  10. contents: write
  11. jobs:
  12. release:
  13. # Retrieve tag and create release
  14. name: Create Release
  15. runs-on: ubuntu-latest
  16. outputs:
  17. upload_url: ${{ steps.create_release.outputs.upload_url }}
  18. steps:
  19. - name: Checkout
  20. uses: actions/checkout@v3
  21. - name: Extract branch info
  22. shell: bash
  23. run: |
  24. echo "release_tag=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
  25. - name: Create Release
  26. id: create_release
  27. uses: "actions/github-script@v6"
  28. env:
  29. RELEASE_TAG: ${{ env.release_tag }}
  30. with:
  31. github-token: "${{ secrets.GITHUB_TOKEN }}"
  32. script: |
  33. const script = require('.github/workflows/scripts/create_release.js')
  34. await script(github, context, core)
  35. wheel:
  36. name: Build Wheel
  37. runs-on: ${{ matrix.os }}
  38. needs: release
  39. strategy:
  40. fail-fast: false
  41. matrix:
  42. os: ['ubuntu-20.04']
  43. python-version: ['3.8', '3.9', '3.10', '3.11']
  44. pytorch-version: ['2.3.1'] # Must be the most recent version that meets requirements-cuda.txt.
  45. cuda-version: ['11.8', '12.1']
  46. steps:
  47. - name: Checkout
  48. uses: actions/checkout@v3
  49. - name: Set up Linux Env
  50. if: ${{ runner.os == 'Linux' }}
  51. run: |
  52. bash -x .github/workflows/scripts/env.sh
  53. - name: Set up Python
  54. uses: actions/setup-python@v4
  55. with:
  56. python-version: ${{ matrix.python-version }}
  57. - name: Install CUDA ${{ matrix.cuda-version }}
  58. run: |
  59. bash -x .github/workflows/scripts/cuda-install.sh ${{ matrix.cuda-version }} ${{ matrix.os }}
  60. - name: Install PyTorch ${{ matrix.pytorch-version }} with CUDA ${{ matrix.cuda-version }}
  61. run: |
  62. bash -x .github/workflows/scripts/pytorch-install.sh ${{ matrix.python-version }} ${{ matrix.pytorch-version }} ${{ matrix.cuda-version }}
  63. - name: Build wheel
  64. shell: bash
  65. env:
  66. CMAKE_BUILD_TYPE: Release
  67. run: |
  68. bash -x .github/workflows/scripts/build.sh ${{ matrix.python-version }} ${{ matrix.cuda-version }}
  69. wheel_name=$(ls dist/*whl | xargs -n 1 basename)
  70. asset_name=${wheel_name//"linux"/"manylinux1"}
  71. echo "wheel_name=${wheel_name}" >> $GITHUB_ENV
  72. echo "asset_name=${asset_name}" >> $GITHUB_ENV
  73. - name: Upload Release Asset
  74. uses: actions/upload-release-asset@v1
  75. env:
  76. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  77. with:
  78. upload_url: ${{ needs.release.outputs.upload_url }}
  79. asset_path: ./dist/${{ env.wheel_name }}
  80. asset_name: ${{ env.asset_name }}
  81. asset_content_type: application/*