Version 0.1.1 #13
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: CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.11"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache pip dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| - name: Run tests | |
| run: pytest | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.11" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| - name: Run Black formatter | |
| run: black --check --diff . | |
| - name: Run isort | |
| run: isort --check-only --diff . | |
| - name: Run mypy | |
| run: mypy . | |
| tag: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| needs: [test, lint] | |
| if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'pull_request' && github.base_ref == 'main') | |
| concurrency: | |
| group: "md-python/tag" | |
| cancel-in-progress: false | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Tag package | |
| run: | | |
| set -e | |
| # Get build number from GitHub run number | |
| BUILD_NUMBER=${{ github.run_number }} | |
| # Extract version from pyproject.toml | |
| version=$(grep -m1 'version =' pyproject.toml | sed -E 's/version = "([^"]+)"/\1/') | |
| tag=${version}-${BUILD_NUMBER} | |
| # Create and push git tag | |
| git_tag="v${tag}" | |
| echo "Git tag ${git_tag}" | |
| git tag "${git_tag}" | |
| git push origin "${git_tag}" | |
| echo "+++ Git tag: ${git_tag}" |