diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml deleted file mode 100644 index 8368bbe..0000000 --- a/.github/workflows/cibuildwheel.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Build and upload to PyPI - -on: - # push: - # branches: - # - main - # pull_request: - # branches: - # - main - release: - types: - - published - workflow_dispatch: - -jobs: - build_wheels: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - - steps: - - uses: actions/checkout@v4 - - - name: Build wheels - uses: pypa/cibuildwheel@v2.21.2 - env: - CIBW_BUILD: 'cp*' - - - uses: actions/upload-artifact@v4 - with: - path: ./wheelhouse/*.whl - - build_sdist: - name: Build source distribution - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Build sdist - run: pipx run build --sdist - - - uses: actions/upload-artifact@v4 - with: - path: dist/*.tar.gz - - upload_pypi: - name: Upload to PyPI - needs: [build_wheels, build_sdist] - runs-on: ubuntu-latest - if: github.event_name == 'release' && github.event.action == 'published' - steps: - - uses: actions/download-artifact@v4 - with: - name: artifact - path: dist - - - uses: pypa/gh-action-pypi-publish@v1.10.3 - with: - user: __token__ - password: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..c5a4380 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,90 @@ +name: Build and upload to PyPI + +on: + # push: + # branches: + # - main + # pull_request: + # branches: + # - main + release: + types: + - published + workflow_dispatch: + inputs: + ref: + description: Build ref + required: true + type: string + build: + description: CIBW_BUILD + type: string + skip: + description: CIBW_SKIP + type: string + sdist: + description: Build sdist + type: boolean + upload: + description: Upload to PyPI + type: boolean + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-13, macos-14] + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref || '' }} + + - name: Build wheels + uses: pypa/cibuildwheel@v2.21.3 + env: + CIBW_BUILD: ${{ inputs.build || 'cp*' }} + CIBW_SKIP: ${{ inputs.skip || '' }} + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + if: github.event_name == 'release' || inputs.sdist + steps: + - uses: actions/checkout@v4 + + - name: Build sdist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v4 + with: + name: cibw-sdist + path: dist/*.tar.gz + + upload_pypi: + name: Upload to PyPI + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + if: | + always() + && (needs.build_wheels.result == 'success' || needs.build_wheels.result == 'skipped') + && (needs.build_sdist.result == 'success' || needs.build_sdist.result == 'skipped') + && (github.event_name == 'release' && github.event.action == 'published' || inputs.upload) + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v4 + with: + pattern: cibw-* + path: dist + merge-multiple: true + + - uses: pypa/gh-action-pypi-publish@release/v1