Skip to content

Commit

Permalink
fix build/release process to use pyproject.toml more
Browse files Browse the repository at this point in the history
  • Loading branch information
pjz committed Jul 12, 2023
1 parent c7ce470 commit a298ffa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
26 changes: 10 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# This Makefile assumes it's being run someplace with pip available

PROJ=$(shell grep ^name pyproject.toml | cut -d\" -f2)
VERSION=$(shell grep ^version pyproject.toml | cut -d\" -f2)

.PHONY: default
default::
Expand Down Expand Up @@ -91,46 +92,39 @@ not-dirty:
SIGN=

.PHONY: git-release
git-release: wheel .version not-dirty
git-release: wheel not-dirty
@if [ `git rev-parse --abbrev-ref HEAD` != main ]; then \
echo "You can only do a release from the main branch.";\
exit 1;\
fi
@if git tag | grep -q `cat .version` ; then \
@if git tag | grep -q ^$(VERSION) ; then \
echo "Already released this version.";\
echo "Update the version number and try again.";\
exit 1;\
fi
VER=`cat .version` &&\
git push &&\
git tag $(SIGN) $$VER -m "Release v$$VER" &&\
git tag $(SIGN) $(VERSION) -m "Release v$(VERSION)" &&\
git push --tags &&\
git checkout release &&\
git merge $$VER &&\
git merge $(VERSION) &&\
git push && git checkout main
@echo "Released! Note you're now on the 'main' branch."

.PHONY: pypi-release
pypi-release: wheel
python -m build
twine upload


# contort a bit to get the version number
.version: setup.py
python setup.py --version >$@
twine upload dist/$(PROJ)-$(VERSION)*

.PHONY: docs
docs: .version
docs:
$(MAKE) -C docs html

docs-release: docs
@if [ `git rev-parse --abbrev-ref HEAD` != main ]; then \
echo "You can only do a release from the main branch.";\
exit 1;\
fi
@VER=`cat .version` &&\
DOCTAR=docs-$$VER.tgz &&\
@DOCTAR=docs-$(VERSION).tgz &&\
cd docs/_build &&\
tar czf ../../$$DOCTAR html &&\
cd ../.. &&\
Expand All @@ -141,15 +135,15 @@ docs-release: docs
mv html docs &&\
touch docs/.nojekyll &&\
git add -A docs &&\
git commit -m "release docs $$VER" &&\
git commit -m "release docs $(VERSION)" &&\
git push && git checkout main
@echo "Docs released!"



.PHONY: clean
clean:
rm -rf build dist *.egg-info shippable .version *.whl $(DEV_ENV)
rm -rf build dist *.egg-info shippable *.whl $(DEV_ENV)
find . -name __pycache__ | xargs rm -rf
find . -name \*.pyc | xargs rm -f

Expand Down
8 changes: 5 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------

project = 'MinCfg'
copyright = '2021, Paul Jimenez'
author = 'Paul Jimenez'

with open('../.version') as f:
version = f.readline().strip()
with open('../pyproject.toml') as f:
for line in f.readlines():
if line.startswith('version'):
version = line.split('"')[1]
break

# The full version, including alpha/beta/rc tags
release = version
Expand Down

0 comments on commit a298ffa

Please sign in to comment.