diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 41452b6..1d4804f 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -1,14 +1,14 @@ name: Continuous integration on: - push: # run when commits are added to master or develop + push: # run when commits are added to master branches: - master - - develop - pull_request: # run on pr's against master or develop + tags: + - [ 0-9 ]{ 8 } # match version tags with format like 20220319 + pull_request: # run on pr's against master branches: - master - - develop env: default-python: "3.10" @@ -107,4 +107,49 @@ jobs: python -m pip install nox - name: Build docs run: | - nox --error-on-missing-interpreters --non-interactive --session docs \ No newline at end of file + 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 \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6455696..be55249 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,8 +27,8 @@ Any contribution is appreciated! You might want to: ## Guideline for creating pull request * A pull request should close an existing issue. -* Pull requests should be merged to develop, not master. This ensures that master always equals the released version. -* Include unit tests when possible. In case of bugs, this will help to prevent the same mistake in the future. In case +* Pull requests should be merged to master. Version tags are used indicate the releases. +* Include unit tests when possible. In case of bugs, this will help to prevent the same mistake in the future. In case of features, this will show that your code works correctly. * Code should work for Python 3.6+. * Code should be formatted with [black](https://github.com/psf/black). diff --git a/Makefile b/Makefile index a4da1af..a25670f 100644 --- a/Makefile +++ b/Makefile @@ -1,37 +1,11 @@ ## Makefile (for maintenance purpose) ## -PACKAGE=pdfminer - PYTHON=python -GIT=git RM=rm -f CP=cp -f MKDIR=mkdir -all: - -install: - $(PYTHON) setup.py install --home=$(HOME) - -clean: - -$(PYTHON) setup.py clean - -$(RM) -r build dist MANIFEST - -cd $(PACKAGE) && $(MAKE) clean - -cd tools && $(MAKE) clean - -cd samples && $(MAKE) clean - -distclean: clean cmap_clean - -sdist: distclean MANIFEST.in - $(PYTHON) setup.py sdist -register: distclean MANIFEST.in - $(PYTHON) setup.py sdist upload register - -WEBDIR=../euske.github.io/$(PACKAGE) -publish: - $(CP) docs/*.html docs/*.png docs/*.css $(WEBDIR) - CONV_CMAP=$(PYTHON) tools/conv_cmap.py CMAPSRC=cmaprsrc CMAPDST=pdfminer/cmap diff --git a/pdfminer/Makefile b/pdfminer/Makefile deleted file mode 100644 index 1d1661b..0000000 --- a/pdfminer/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# Makefile for pdfminer - -RM=rm -f - -all: - -clean: - -$(RM) *.pyc *.pyo - cd cmap && make clean diff --git a/pdfminer/__init__.py b/pdfminer/__init__.py index 5df9646..e8e5221 100644 --- a/pdfminer/__init__.py +++ b/pdfminer/__init__.py @@ -1,4 +1,4 @@ -__version__ = "20211012" +__version__ = "__VERSION__" # auto replaced with tag in github actions if __name__ == "__main__": print(__version__) diff --git a/tools/Makefile b/tools/Makefile deleted file mode 100644 index ed51702..0000000 --- a/tools/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# Makefile for tools - -RM=rm -f - -all: - -clean: - -$(RM) *.pyc *.pyo *.cgic *.cgio