Test Distribution #36
Workflow file for this run
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
| name: Test Distribution | |
| on: | |
| push: | |
| branches: [ master ] | |
| workflow_dispatch: | |
| inputs: | |
| allow_deploy: | |
| description: 'Deploy with twine' | |
| required: true | |
| type: boolean | |
| allow_sphinx_deploy: | |
| description: 'Deploy Sphinx extension with twine' | |
| required: true | |
| type: boolean | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.11 | |
| - name: Build pydispatch dists | |
| run: uv build | |
| - name: Build pydispatch_sphinx dists | |
| run: uv build --out-dir $DISTDIR | |
| working-directory: ${{ github.workspace }}/sphinx-plugin | |
| env: | |
| DISTDIR: ${{ github.workspace }}/dist-sphinx | |
| - name: Export pydispatch lockfile | |
| run: uv export --frozen --no-emit-project --only-group test -o requirements.txt | |
| - name: Export pydispatch_sphinx lockfile | |
| run: uv export --frozen --no-emit-project --only-group test -o requirements.txt | |
| working-directory: ${{ github.workspace }}/sphinx-plugin | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: 'dists' | |
| path: 'dist/*' | |
| - name: Upload sphinx artifacts | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: 'dists-sphinx' | |
| path: 'dist-sphinx/*' | |
| - name: Upload lockfiles | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: 'lockfiles' | |
| path: | | |
| requirements.txt | |
| sphinx-plugin/requirements.txt | |
| test: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: [3.8, 3.9, "3.10", "3.11"] | |
| dist-type: [sdist, wheel] | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Download lockfiles | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: 'lockfiles' | |
| path: . | |
| - name: Install dependencies | |
| run: | | |
| pip install -r requirements.txt | |
| pip install -r sphinx-plugin/requirements.txt | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: 'dists' | |
| path: dist | |
| - name: Download sphinx artifacts | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: 'dists-sphinx' | |
| path: dist | |
| - name: Delete source directories | |
| run: | | |
| rm -Rf pydispatch | |
| rm -Rf sphinx-plugin/pydispatch_sphinx | |
| - name: Install wheel | |
| if: ${{ matrix.dist-type == 'wheel' }} | |
| run: pip install dist/*.whl | |
| - name: Install sdist | |
| if: ${{ matrix.dist-type == 'sdist' }} | |
| run: pip install dist/*.tar.gz | |
| - name: Test pydispatch distribution | |
| run: py.test tests/ | |
| - name: Test pydispatch_sphinx distribution | |
| run: py.test sphinx-plugin/tests/ | |
| deploy: | |
| needs: test | |
| if: ${{ success() && (github.event.inputs.allow_deploy == 'true' || github.event.inputs.allow_sphinx_deploy == 'true') }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.11 | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip setuptools wheel twine | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: 'dists' | |
| path: dist | |
| - name: Download sphinx artifacts | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: 'dists-sphinx' | |
| path: dist-sphinx | |
| - name: Publish to PyPI | |
| if: ${{ success() && github.event.inputs.allow_deploy == 'true' }} | |
| env: | |
| TWINE_REPOSITORY: ${{ secrets.TWINE_REPOSITORY }} | |
| TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
| TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
| run: twine upload dist/* | |
| - name: Publish Sphinx extension to PyPI | |
| if: ${{ success() && github.event.inputs.allow_sphinx_deploy == 'true' }} | |
| env: | |
| TWINE_REPOSITORY: ${{ secrets.TWINE_REPOSITORY }} | |
| TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
| TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
| run: twine upload dist-sphinx/* |