Fix error-handling, improve README/CI (#1) #96
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, release | |
| on: | |
| pull_request: | |
| branches: [main] | |
| push: | |
| branches: [main] | |
| tags: ["v*.*.*"] | |
| workflow_dispatch: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v7 | |
| - run: uv python install ${{ matrix.python-version }} | |
| - name: Install mdcmd globally via uv tool | |
| run: uv tool install --python python${{ matrix.python-version }} . | |
| - name: Verify bash functions work | |
| run: | | |
| wcl() { wc -l "$@"; } | |
| export -f wcl | |
| export SHELL | |
| bmdf seq 10 '|' wcl | |
| - name: Verify README examples and TOC are up to date | |
| run: | | |
| mdcmd | |
| git diff --exit-code | |
| - name: Install test dependencies | |
| run: uv sync --python ${{ matrix.python-version }} --extra test | |
| - name: Run tests | |
| run: uv run pytest test | |
| publish: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Fetch tag annotation | |
| run: git fetch origin tag ${{ github.ref_name }} --force | |
| - uses: astral-sh/setup-uv@v4 | |
| - run: uv python install 3.12 | |
| - name: Install mdcmd for README processing | |
| run: uv tool install . | |
| - name: Process README with absolute URLs | |
| run: README_ABSOLUTE_URLS=1 mdcmd | |
| - name: Build package | |
| run: uvx --from build pyproject-build --outdir dist | |
| - name: Publish to PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
| run: | | |
| uvx twine upload dist/* | |
| - name: Get tag message | |
| id: tag | |
| run: | | |
| TAG_MSG=$(git tag -l --format='%(contents:body)' ${{ github.ref_name }}) | |
| echo "message<<EOF" >> $GITHUB_OUTPUT | |
| echo "$TAG_MSG" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: dist/* | |
| body: | | |
| ${{ steps.tag.outputs.message }} | |
| generate_release_notes: true |