name: Continuous integration on: push: # run when commits are added to master branches: - master tags: - [ 0-9 ]{ 8 } # match version tags with format like 20220319 pull_request: # run on pr's against master branches: - master env: default-python: "3.10" jobs: check-code-formatting: name: Check code formatting runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Check code formatting uses: psf/black@stable check-coding-style: name: Check coding style runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Set up Python ${{ env.default-python }} uses: actions/setup-python@v2 with: python-version: ${{ env.default-python }} - name: Upgrade pip, Install nox run: | python -m pip install --upgrade pip python -m pip install nox - name: Check coding style run: | nox --error-on-missing-interpreters --non-interactive --session lint check-static-types: name: Check static types runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Set up Python ${{ env.default-python }} uses: actions/setup-python@v2 with: python-version: ${{ env.default-python }} - name: Upgrade pip, Install nox run: | python -m pip install --upgrade pip python -m pip install nox - name: Check static types run: | nox --error-on-missing-interpreters --non-interactive --session types tests: name: Run tests runs-on: ${{ matrix.os }} strategy: matrix: os: [ ubuntu-latest ] python-version: [ "3.6", "3.7", "3.8", "3.9", "3.10" ] steps: - name: Checkout code uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Determine pip cache directory id: pip-cache run: | echo "::set-output name=dir::$(pip cache dir)" - name: Cache pip cache uses: actions/cache@v2 with: path: ${{ steps.pip-cache.outputs.dir }} key: ${{ runner.os }}-pip${{ matrix.python-version }} - name: Upgrade pip and install nox run: | python -m pip install --upgrade pip python -m pip install nox - name: Run tests run: | nox --non-interactive --session tests-${{ matrix.python-version }} build-docs: name: Test building docs runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Set up Python ${{ env.default-python }} uses: actions/setup-python@v2 with: python-version: ${{ env.default-python }} - name: Upgrade pip and install nox run: | python -m pip install --upgrade pip python -m pip install nox - name: Build docs run: | nox --error-on-missing-interpreters --non-interactive --session docs publish: name: Publish to PyPi runs-on: ubuntu-latest needs: - check-code-formatting - check-coding-style - check-static-types - tests - build-docs steps: - name: Checkout code uses: actions/checkout@v2 - name: Install dependencies run: python -m pip install wheel - name: Set version run: | if [[ "${{ github.ref }}" == "refs/tags/"* ]] then VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,' | sed -e 's/^v//') else VERSION=$(date +%Y%m%d).$(date +%H%M%S) fi echo ${VERSION} sed -i "s/__VERSION__/${VERSION}/g" pdfminer/__init__.py - name: Build package run: python setup.py sdist bdist_wheel - name: Generate changelog run: sed '1,/## \[/d;/## \[/Q' CHANGELOG.md > ${{ github.workspace }}-CHANGELOG.md - name: Publish package to PyPi if: startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} - name: Create GitHub release if: startsWith(github.ref, 'refs/tags') uses: softprops/action-gh-release@v1 id: create_release with: token: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token body_path: ${{ github.workspace }}-CHANGELOG.md files: | dist/*.tar.gz dist/*.whl