diff --git a/.github/workflows/wheels.yml b/.github/workflows/pypi-deploy.yml similarity index 51% rename from .github/workflows/wheels.yml rename to .github/workflows/pypi-deploy.yml index 061dd1e..346243e 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/pypi-deploy.yml @@ -2,11 +2,10 @@ name: Build Python Wheels on: push: - branches: - - master + branches: [master] jobs: build_wheels: - name: Build wheels on ${{ matrix.os }} + name: Build binary wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: @@ -21,12 +20,21 @@ jobs: - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse - upload_wheels: + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build sdist + run: python setup.py sdist + + upload_pypi: name: Upload binary wheels to PyPI - needs: [build_wheels] + runs-on: ubuntu-20.04 + needs: [build_wheels, build_sdist] steps: - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.IMCTERMITE_GITHUB_WORKFLOW_PYPI_API_TOKEN }} + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.IMCTERMITE_GITHUB_WORKFLOW_PYPI_API_TOKEN }} diff --git a/.gitignore b/.gitignore index 3409c74..3eec9b6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ eatraw eatdev imctermite +IMCtermite nohup.out diff --git a/README.md b/README.md index 6425ade..9f6f8b8 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/RecordEvolution/IMCtermite.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/RecordEvolution/IMCtermite/context:python) [![LICENSE](https://img.shields.io/github/license/RecordEvolution/IMCtermite)](https://img.shields.io/github/license/RecordEvolution/IMCtermite) [![STARS](https://img.shields.io/github/stars/RecordEvolution/IMCtermite)](https://img.shields.io/github/stars/RecordEvolution/IMCtermite) +![Build Python Wheels](https://github.com/RecordEvolution/IMCtermite/actions/workflows/pypi-deploy.yml/badge.svg) # IMCtermite diff --git a/makefile b/makefile index 62d0296..5539bd9 100644 --- a/makefile +++ b/makefile @@ -3,12 +3,11 @@ SHELL := /bin/bash # name of executable and CLI tool -EXE = imctermite +EXE = IMCtermite # directory names SRC = src/ LIB = lib/ -CYT = cython/ PYT = python/ # list headers @@ -16,14 +15,14 @@ HPP = $(wildcard $(LIB)/*.hpp) # choose compiler and its options CC = g++ -std=c++17 -#OPT = -O3 -Wall -mavx -mno-tbm -mf16c -mno-f16c OPT = -O3 -Wall -Wconversion -Wpedantic -Werror -Wunused-variable -Wsign-compare # determine git version/commit and release tag GTAG := $(shell git tag -l --sort=version:refname | tail -n1) GHSH := $(shell git rev-parse HEAD | head -c8) -RTAG := v$(shell cat pip/setup.py | grep version | grep -oP "([0-9]\.){2}[0-9]{1,2}") -CTAG := v$(shell cat cython/setup.py | grep version | grep -oP "([0-9]\.){2}[0-9]{1,2}") + +# current timestamp +TMS = $(shell date +%Y%m%dT%H%M%S) # define install location INST := /usr/local/bin @@ -32,7 +31,7 @@ INST := /usr/local/bin # C++ and CLI tool # build exectuable -$(EXE) : check-vtag $(RTAG) main.o +$(EXE) : main.o $(CC) $(OPT) main.o -o $@ # build main.cpp and include git version/commit tag @@ -40,6 +39,7 @@ main.o : src/main.cpp $(HPP) @cp $< $<.cpp @sed -i 's/TAGSTRING/$(GTAG)/g' $<.cpp @sed -i 's/HASHSTRING/$(GHSH)/g' $<.cpp + @sed -i 's/TIMESTAMPSTRING/$(TMS)/g' $<.cpp $(CC) -c $(OPT) -I $(LIB) $<.cpp -o $@ @rm $<.cpp @@ -54,23 +54,11 @@ cpp-clean : rm -vf *.o #-----------------------------------------------------------------------------# -# linter and code check +# C++ linter check-code: cppcheck --enable=all -I lib/ src/main.cpp -#-----------------------------------------------------------------------------# -# check version consistency of git tags and version string in package.json - -$(GTAG) : - @echo "consistent versions check successful: building $(GTAG)" - -check-vtag: - @echo "git tag version: "$(GTAG) - @echo "git commit hash: "$(GHSH) - @echo "release version: "$(RTAG) - @echo "module version: "$(CTAG) - #-----------------------------------------------------------------------------# # Docker @@ -83,28 +71,26 @@ docker-run: #-----------------------------------------------------------------------------# # python -cython-build : check-vtag $(CTAG) $(CYT)setup.py $(CYT)imc_termite.pxd $(CYT)py_imc_termite.pyx $(HPP) - python3 $(CYT)setup.py build_ext --inplace - cp -v imc_termite.cpython-*.so $(PYT) +python-build: + make -C python/ build-inplace + cp python/IMCtermite*.so ./ -v -cython-install : check-vtag $(CTAG) $(CYT)setup.py $(CYT)imc_termite.pxd $(CYT)py_imc_termite.pyx $(HPP) - python3 $(CYT)setup.py install --record files_imctermite.txt - -cython-clean : - rm -vf imc_termite.cpython-*.so - rm -vf $(PYT)imc_termite.cpython-*.so - rm -rvf build/ - -#-----------------------------------------------------------------------------# -# pip - -pip-release: check-vtag $(RTAG) cython-build - cd ./pip/ && make publish-source +python-clean: + make -C python/ clean + rm -vf IMCtermite*.so #-----------------------------------------------------------------------------# # clean -clean: cpp-clean cython-clean - cd ./pip/ && make clean +clean: cpp-clean python-clean + +#-----------------------------------------------------------------------------# +# github actions + +github-action-lint: .github/workflows/pypi-deploy.yml + actionlint $< + +# for reference, see: +# https://github.com/rhysd/actionlint #-----------------------------------------------------------------------------# diff --git a/src/main.cpp b/src/main.cpp index 566345f..b19e0c7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,6 +12,7 @@ const std::string gittag("TAGSTRING"); const std::string githash("HASHSTRING"); +const std::string timestamp("TIMESTAMPSTRING"); //---------------------------------------------------------------------------// @@ -127,13 +128,13 @@ optkeys parse_args(int argc, char* argv[], bool list_args = false) void show_version() { - std::cout<<"imctermite ["<