Add github action for releasing to pypi if git tag is added. (#727)

* Add github action for releasing to pypi if git tag is added.

* Checkout code and fix typos.

* Replace end with fi

* Strictly numeric version for testing.

* Remove obsolete Make commands for publishing

* Also create GitHub release

* Update pdfminer/__init__.py

Co-authored-by: Jake Stockwin <jstockwin@gmail.com>

* Remove test pypi release

* Use maintained github action for releasing

* Change tag format for versions

* Undo commenting pypi publishing

* Remove develop branch, since that will be removed in favor off adding tags for releases.

* Change version regex

Co-authored-by: Jake Stockwin <jstockwin@gmail.com>
pull/730/head
Pieter Marsman 2022-03-19 20:46:00 +01:00 committed by GitHub
parent 43c8fc8557
commit d89cc357ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 53 additions and 51 deletions

View File

@ -1,14 +1,14 @@
name: Continuous integration name: Continuous integration
on: on:
push: # run when commits are added to master or develop push: # run when commits are added to master
branches: branches:
- master - master
- develop tags:
pull_request: # run on pr's against master or develop - [ 0-9 ]{ 8 } # match version tags with format like 20220319
pull_request: # run on pr's against master
branches: branches:
- master - master
- develop
env: env:
default-python: "3.10" default-python: "3.10"
@ -107,4 +107,49 @@ jobs:
python -m pip install nox python -m pip install nox
- name: Build docs - name: Build docs
run: | run: |
nox --error-on-missing-interpreters --non-interactive --session docs 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

View File

@ -27,8 +27,8 @@ Any contribution is appreciated! You might want to:
## Guideline for creating pull request ## Guideline for creating pull request
* A pull request should close an existing issue. * 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. * 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 * 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. of features, this will show that your code works correctly.
* Code should work for Python 3.6+. * Code should work for Python 3.6+.
* Code should be formatted with [black](https://github.com/psf/black). * Code should be formatted with [black](https://github.com/psf/black).

View File

@ -1,37 +1,11 @@
## Makefile (for maintenance purpose) ## Makefile (for maintenance purpose)
## ##
PACKAGE=pdfminer
PYTHON=python PYTHON=python
GIT=git
RM=rm -f RM=rm -f
CP=cp -f CP=cp -f
MKDIR=mkdir 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 CONV_CMAP=$(PYTHON) tools/conv_cmap.py
CMAPSRC=cmaprsrc CMAPSRC=cmaprsrc
CMAPDST=pdfminer/cmap CMAPDST=pdfminer/cmap

View File

@ -1,9 +0,0 @@
# Makefile for pdfminer
RM=rm -f
all:
clean:
-$(RM) *.pyc *.pyo
cd cmap && make clean

View File

@ -1,4 +1,4 @@
__version__ = "20211012" __version__ = "__VERSION__" # auto replaced with tag in github actions
if __name__ == "__main__": if __name__ == "__main__":
print(__version__) print(__version__)

View File

@ -1,8 +0,0 @@
# Makefile for tools
RM=rm -f
all:
clean:
-$(RM) *.pyc *.pyo *.cgic *.cgio