publish #18
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: publish | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| target: | |
| description: "Publish target" | |
| required: true | |
| default: "all" | |
| type: choice | |
| options: [docs, package, all] | |
| permissions: | |
| contents: write | |
| issues: write | |
| pull-requests: write | |
| pages: write | |
| id-token: write # нужно для PyPI Trusted Publishing (OIDC) | |
| concurrency: | |
| group: publish-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| tests: | |
| name: Run tests (reusable) | |
| uses: ./.github/workflows/tests.yml | |
| with: | |
| python-version: "3.12" | |
| build-docs: | |
| if: ${{ github.event.inputs.target == 'docs' || github.event.inputs.target == 'all' }} | |
| name: Build docs | |
| needs: tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install deps (venv) | |
| run: | | |
| python -m venv venv | |
| venv/bin/python -m pip install --upgrade pip | |
| venv/bin/python -m pip install -r requirements.txt | |
| venv/bin/python -m pip install -r docs/requirements.txt | |
| PATH="$PWD/venv/bin:$PATH" make install-dev | |
| - name: Build docs (venv) | |
| run: | | |
| PATH="$PWD/venv/bin:$PATH" make docs | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: docs/_build/html | |
| deploy-docs: | |
| if: ${{ github.event.inputs.target == 'docs' || github.event.inputs.target == 'all' }} | |
| name: Deploy docs to GitHub Pages | |
| needs: build-docs | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| pypi: | |
| if: ${{ github.event.inputs.target == 'package' || github.event.inputs.target == 'all' }} | |
| name: Build & publish to PyPI (Trusted Publishing) | |
| needs: tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| cache: pip | |
| - name: Build artifacts (PEP 517) (venv) | |
| run: | | |
| python -m venv venv | |
| venv/bin/python -m pip install --upgrade pip | |
| venv/bin/python -m pip install build | |
| PATH="$PWD/venv/bin:$PATH" make build | |
| - name: Publish to PyPI via OIDC | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| verbose: true |