Build documentation when pushing to gh-pages and push only from tag #205
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: Workflow Push | |
| on: [push] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v3 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Upgrade pip | |
| run: python -m pip install --upgrade pip | |
| - name: Install Tox | |
| run: pip install tox | |
| - name: Run lint | |
| run: tox -e lint | |
| - name: Run test | |
| run: tox -e test | |
| - name: Run build | |
| run: tox -e build | |
| - name: Build doc | |
| run: tox -e doc | |
| - name: Store the distribution packages | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: build-artifacts-${{ matrix.python-version }} | |
| path: | | |
| dist/ | |
| deploy-docs: | |
| name: Deploy documentation π to GitHub Pages | |
| if: ${{ github.event_name == 'push' && github.ref == 'refs/tags' }} | |
| needs: | |
| - build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| permissions: | |
| contents: write | |
| pages: write | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v3 | |
| with: | |
| python-version: 3.12 | |
| - name: Upgrade pip | |
| run: python -m pip install --upgrade pip | |
| - name: Install Tox | |
| run: pip install tox | |
| - name: Run Doc | |
| run: tox -e doc | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| publish_branch: gh-pages | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: docs/_build/html | |
| force_orphan: true | |
| publish-to-testpypi: | |
| name: Publish Python π distribution π¦ to TestPyPI | |
| if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | |
| needs: | |
| - build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: testpypi | |
| url: https://test.pypi.org/p/nasdaq-protocols | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: build-artifacts-3.12 | |
| path: ./ | |
| - name: list all files | |
| run: ls -lR | |
| - name: Publish distribution π¦ to TestPyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| publish-to-pypi: | |
| name: >- | |
| Publish Python π distribution π¦ to PyPI | |
| if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | |
| needs: | |
| - publish-to-testpypi # only publish to PyPI after TestPyPI publishing | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/nasdaq-protocols | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: build-artifacts-3.12 | |
| path: ./ | |
| - name: list all files | |
| run: ls -lR | |
| - name: Publish distribution π¦ to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |