[build] Refactor Makefile

This commit is contained in:
Davis Schirmer
2021-10-29 23:29:42 -04:00
parent a89cc2d6f9
commit 2bfb38c1f3

View File

@@ -1,31 +1,48 @@
NAME=asciinema
VERSION=`python3 -c "import asciinema; print(asciinema.__version__)"`
NAME := asciinema
VERSION := $(shell python3 -c "import asciinema; print(asciinema.__version__)")
test: test-unit test-integration
.PHONY: test
test: test.unit test.integration
test-unit:
.PHONY: test.unit
test.unit:
nosetests
test-integration:
.PHONY: test.integration
test.integration:
tests/integration.sh
.PHONY: release
release: test tag push
release-test: test push-test
.PHONY: release.test
release.test: test push.test
tag:
git tag | grep "v$(VERSION)" && echo "Tag v$(VERSION) exists" && exit 1 || true
.PHONY: .tag.exists
.tag.exists:
@git tag \
| grep -q "v$(VERSION)" \
&& echo "Tag v$(VERSION) exists" \
&& exit 1
.PHONY: tag
tag: .tag.exists
git tag -s -m "Releasing $(VERSION)" v$(VERSION)
git push origin v$(VERSION)
push:
python3 -m pip install --user --upgrade --quiet twine
python3 setup.py sdist bdist_wheel
.PHONY: .pip
.pip:
python3 -m pip install --user --upgrade --quiet build twine
build:
python3 -m build .
.PHONY: push
push: .pip build
python3 -m twine upload dist/*
push-test:
python3 -m pip install --user --upgrade --quiet twine
python3 setup.py sdist bdist_wheel
.PHONY: push.test
push.test: .pip build
python3 -m twine upload --repository testpypi dist/*
.PHONY: test test-unit test-integration release release-test tag push push-test