Upload Python Package #37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow will upload a Python Package to PyPI | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries | |
| # This workflow uses actions that are not certified by GitHub. | |
| # They are provided by a third-party and are governed by | |
| # separate terms of service, privacy policy, and support | |
| # documentation. | |
| name: Upload Python Package | |
| on: | |
| workflow_dispatch: | |
| # release: | |
| # types: [published] | |
| permissions: | |
| contents: read | |
| jobs: | |
| release-build-sdist: | |
| name: Package source | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Build source distribution | |
| run: | | |
| python -m ensurepip --upgrade | |
| python -m pip install setuptools numpy cython | |
| python setup.py sdist | |
| - name: Upload distributions | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist-source | |
| path: dist | |
| release-build-wheels: | |
| name: Build wheels on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-13, macos-14] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build binary distribution | |
| uses: pypa/[email protected] | |
| with: | |
| output-dir: dist | |
| - name: Upload distributions | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist-wheels-${{ matrix.os }}-${{ strategy.job-index }} | |
| path: dist/*.whl | |
| pypi-publish: | |
| name: Publish to PyPI | |
| runs-on: ubuntu-latest | |
| needs: | |
| - release-build-sdist | |
| - release-build-wheels | |
| permissions: | |
| # IMPORTANT: this permission is mandatory for trusted publishing | |
| id-token: write | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/compiled-knowledge | |
| steps: | |
| - name: Retrieve release distributions | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: dist-* | |
| path: dist/ | |
| merge-multiple: true | |
| - name: Publish release distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist/ | |
| testpypi-publish: | |
| name: Publish to Test PyPI | |
| runs-on: ubuntu-latest | |
| needs: | |
| - release-build-sdist | |
| - release-build-wheels | |
| permissions: | |
| # IMPORTANT: this permission is mandatory for trusted publishing | |
| id-token: write | |
| environment: | |
| name: testpypi | |
| url: https://test.pypi.org/p/compiled-knowledge | |
| steps: | |
| - name: Retrieve release distributions | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: dist-* | |
| path: dist/ | |
| merge-multiple: true | |
| - name: Publish release distributions to TestPyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| packages-dir: dist/ |