|
| 1 | +name: Build wheels |
| 2 | + |
| 3 | +# By default this action does not push to test or production PyPI. The wheels |
| 4 | +# are available as an artifact that can be downloaded and tested locally. |
| 5 | +on: |
| 6 | + # allow to run manually: https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/manually-running-a-workflow |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + project_ref: |
| 10 | + description: "Project git ref to checkout" |
| 11 | + default: "polars" |
| 12 | + type: string |
| 13 | + test_pypi_publish: |
| 14 | + description: "Publish to Test PyPi" |
| 15 | + default: false |
| 16 | + type: boolean |
| 17 | + pypi_publish: |
| 18 | + description: "Publish to PyPi" |
| 19 | + default: false |
| 20 | + type: boolean |
| 21 | + workflow_call: |
| 22 | + inputs: |
| 23 | + project_ref: |
| 24 | + description: "Project git ref to checkout" |
| 25 | + default: "polars" |
| 26 | + type: string |
| 27 | + test_pypi_publish: |
| 28 | + description: "Publish to Test PyPi" |
| 29 | + default: false |
| 30 | + type: boolean |
| 31 | + pypi_publish: |
| 32 | + description: "Publish to PyPi" |
| 33 | + default: false |
| 34 | + type: boolean |
| 35 | + |
| 36 | +jobs: |
| 37 | + build: |
| 38 | + name: Build wheels and source distributions |
| 39 | + runs-on: ubuntu-latest |
| 40 | + steps: |
| 41 | + - name: Checkout project |
| 42 | + uses: actions/checkout@v4 |
| 43 | + with: |
| 44 | + ref: ${{ github.event.inputs.project_ref }} |
| 45 | + - name: Upgrade pip and setuptools |
| 46 | + run: python -m pip install setuptools pip build --upgrade |
| 47 | + - name: Build sdist and wheel |
| 48 | + run: python -m build . |
| 49 | + - uses: actions/upload-artifact@v4 |
| 50 | + with: |
| 51 | + path: dist/* |
| 52 | + |
| 53 | + upload_test_pypi: |
| 54 | + name: Upload to test PyPI (optional) |
| 55 | + if: ${{ github.event.inputs.test_pypi_publish == 'true' }} |
| 56 | + needs: [build] |
| 57 | + runs-on: ubuntu-latest |
| 58 | + environment: |
| 59 | + name: testpypi |
| 60 | + url: https://test.pypi.org/p/damast |
| 61 | + permissions: |
| 62 | + id-token: write |
| 63 | + |
| 64 | + steps: |
| 65 | + - uses: actions/download-artifact@v4 |
| 66 | + with: |
| 67 | + name: artifact |
| 68 | + path: dist |
| 69 | + |
| 70 | + - name: Push to test PyPI |
| 71 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 72 | + with: |
| 73 | + repository-url: https://test.pypi.org/legacy/ |
| 74 | + |
| 75 | + upload_pypi: |
| 76 | + name: Upload to PyPI (optional) |
| 77 | + if: ${{ github.event.inputs.pypi_publish == 'true' }} |
| 78 | + needs: [build] |
| 79 | + runs-on: ubuntu-latest |
| 80 | + environment: |
| 81 | + name: pypi |
| 82 | + url: https://pypi.org/p/damast |
| 83 | + permissions: |
| 84 | + id-token: write |
| 85 | + |
| 86 | + steps: |
| 87 | + - uses: actions/download-artifact@v4 |
| 88 | + with: |
| 89 | + name: artifact |
| 90 | + path: dist |
| 91 | + |
| 92 | + - name: Push to PyPI |
| 93 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments