Release Pipeline #23
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: Release Pipeline | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| action: | |
| description: 'Choose what to execute' | |
| required: true | |
| default: 'all' | |
| type: choice | |
| options: | |
| - 'all' | |
| - 'pypi-publish' | |
| - 'docs-build-publish' | |
| # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
| concurrency: | |
| group: "release" | |
| cancel-in-progress: false | |
| jobs: | |
| # Step 1: Run tests and linting | |
| test: | |
| if: ${{ github.event_name == 'release' || github.event.inputs.action == 'all' || github.event.inputs.action == 'pypi-publish' || github.event.inputs.action == 'docs-build-publish' }} | |
| uses: ./.github/workflows/reusable-test.yml | |
| with: | |
| upload-coverage: true | |
| # Step 2: Build and deploy documentation | |
| build-and-deploy-docs: | |
| if: ${{ github.event_name == 'release' || github.event.inputs.action == 'all' || github.event.inputs.action == 'docs-build-publish' }} | |
| runs-on: ubuntu-latest | |
| needs: test | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Python 3.12 + deps | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| cache: 'pip' | |
| cache-dependency-path: | | |
| **/pyproject.toml | |
| **/requirements*.txt | |
| - name: Install dev / docs dependencies | |
| run: | | |
| make install-dev | |
| - name: Download coverage artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: coverage-reports | |
| path: ./ | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Build Documentation | |
| uses: ./.github/actions/build-docs | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: './_site' | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| # Step 3: Publish to PyPI | |
| publish: | |
| if: ${{ github.event_name == 'release' || github.event.inputs.action == 'all' || github.event.inputs.action == 'pypi-publish' }} | |
| runs-on: ubuntu-latest | |
| needs: test | |
| environment: release | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Python 3.12 + deps | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| cache: 'pip' | |
| cache-dependency-path: | | |
| **/pyproject.toml | |
| **/requirements*.txt | |
| - name: Install dev / docs dependencies | |
| run: | | |
| make install-dev | |
| - name: Install build dependencies | |
| run: | | |
| pip install build twine | |
| - name: Build package | |
| run: | | |
| python -m build | |
| - name: Check package | |
| run: | | |
| twine check dist/* | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| verify-metadata: false |