[pre-commit.ci] pre-commit autoupdate #122
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 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| # Runs main tests for the package. | |
| # | |
| # Runs on all events except when closing a pull request. | |
| test: | |
| name: Test package | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - ubuntu-latest | |
| type: | |
| - test | |
| include: | |
| - os: ubuntu-latest | |
| type: code style | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout source | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install UV | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Install dependencies | |
| run: | | |
| uv tool install poethepoet | |
| # Tests | |
| - name: Test package | |
| if: ${{ matrix.type == 'test' }} | |
| run: | | |
| poe ci | |
| # Lint | |
| - name: Check code style | |
| if: ${{ matrix.type == 'code style' }} | |
| run: | | |
| poe lint --color always | |
| # Builds python packages. | |
| # | |
| # Only runs on tag pushes. | |
| build: | |
| name: Build package | |
| if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') }} | |
| runs-on: ubuntu-latest | |
| outputs: | |
| link: ${{ steps.metadata.outputs.link }} | |
| is-pre-release: ${{ steps.changelog.outputs.is-pre-release }} | |
| is-unreleased: ${{ steps.changelog.outputs.is-unreleased }} | |
| changelog-text: ${{ steps.changelog.outputs.text }} | |
| steps: | |
| - name: Checkout source | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Generate release metadata | |
| id: metadata | |
| run: | | |
| ref="${{ github.ref }}"; | |
| version=${ref#refs/tags/v}; | |
| link="https://pypi.org/p/sphinx-syntax/${version}/"; | |
| echo "link=${link}" >> $GITHUB_OUTPUT | |
| - name: Parse Changelog | |
| id: changelog | |
| uses: taminomara/cl-keeper@v1 | |
| with: | |
| version: ${{ github.ref }} | |
| - name: Install UV | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Build project | |
| run: | | |
| uv build | |
| - name: Upload the build artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| # Publishes python packages. | |
| # | |
| # Only runs on tag pushes. | |
| publish_to_pypi: | |
| name: Publish package to PyPi | |
| needs: | |
| - test | |
| - build | |
| if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') }} | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/sphinx-syntax | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Download build artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish to pypi | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| attestations: false | |
| - name: Create GitHub release | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| prerelease: ${{ fromJSON(needs.build.outputs.is-pre-release) }} | |
| draft: ${{ fromJSON(needs.build.outputs.is-unreleased) }} | |
| body: | | |
| ## Changelog | |
| ${{ needs.build.outputs.changelog-text }} | |
| [See release on PyPi](${{ needs.build.outputs.link }}) |