Skip to content

Commit

Permalink
Update pyproject Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
mnot committed Oct 15, 2023
1 parent a991b28 commit 14af6de
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions Makefile.pyproject
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
# Run mypy on $PROJECT
# bump-calver
# Bump the __version__ in $PROJECT/__init__.py using calver (https://calver.org/)
# bump-semver-[major,minor,micro]
# bump-semver[-major,-minor,-micro]
# Bump the __version__ in $PROJECT/__init__.py using semver (https://semver.org/)
# version <<< COMMITS TO GIT
# Bump the version according to $VERSIONING (default: semver-micro).
# build
# Build the project
# release
# release <<< TAGS AND PUSHES TO GITHUB
# Release the project on Pypi and Github releases (requires /.github/workflows/release.yml)
#
# See also Makefile.venv.
Expand All @@ -37,6 +39,7 @@
# - validate-pyproject

PY?=python
VERSIONING?=semver-micro
YEAR=`date +%Y`
MONTH=`date +%m`

Expand All @@ -60,10 +63,10 @@ lint_py: venv
typecheck_py: venv
PYTHONPATH=$(VENV) $(VENV)/python -m mypy $(PROJECT)

## Distribution
## Release

.PHONY: version_py
version_py: venv
.PHONY: py_version
py_version: venv
$(eval VERSION=$(shell $(VENV)/python -c "import $(PROJECT); print($(PROJECT).__version__)"))
$(eval VER_MAJOR=$(shell echo $(VERSION) | cut -d. -f1))
$(eval VER_MINOR=$(shell echo $(VERSION) | cut -d. -f2))
Expand All @@ -88,29 +91,33 @@ version_py: venv
))

.PHONY: bump-calver
bump-calver: version_py
bump-calver: py_version
sed -i "" -e "s/$(VERSION)/$(YEAR).$(MONTH).$(NEXT_CALMICRO)/" $(PROJECT)/__init__.py

.PHONY: bump-semver-micro
bump-semver-micro: version_py
bump-semver-micro: py_version
sed -i "" -e "s/$(VERSION)/$(VER_MAJOR).$(VER_MINOR).$(NEXT_SEMMICRO)/" $(PROJECT)/__init__.py

.PHONY: bump-semver-minor
bump-semver-minor: version_py
bump-semver-minor: py_version
sed -i "" -e "s/$(VERSION)/$(VER_MAJOR).$(NEXT_SEMMINOR).0/" $(PROJECT)/__init__.py

.PHONY: bump-semver-major
bump-semver-major: version_py
bump-semver-major: py_version
sed -i "" -e "s/$(VERSION)/$(NEXT_SEMMAJOR).0.0/" $(PROJECT)/__init__.py

.PHONY: version
version: typecheck lint test bump-$(VERSIONING)
git add $(PROJECT)/__init__.py
git commit -m 'bump version'

.PHONY: build
build: clean venv
$(VENV)/python -m build

# requires /.github/workflows/release.yml
.PHONY: release
release: typecheck_py lint_py test version_py
release: py_version
git tag -a "v$(VERSION)" -m "v$(VERSION)"
git push
git push --tags origin # github action will push to pypi and create a release
Expand Down

0 comments on commit 14af6de

Please sign in to comment.