Skip to content

Commit 94d94a1

Browse files
committed
build: release automation
1 parent a4ba4bb commit 94d94a1

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

Makefile

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Makefile for cog work.
22

3+
# A command to get the current version from cogapp.py
4+
VERSION := $$(python -c "import cogapp.cogapp; print(cogapp.cogapp.__version__)")
5+
36
.PHONY: help clean sterile test
47

58
help: ## Show this help.
@@ -49,7 +52,7 @@ dochtml: ## Build local docs.
4952

5053
# Release
5154

52-
.PHONY: dist pypi testpypi check_release _check_manifest
55+
.PHONY: dist pypi testpypi tag release check_release _check_credentials _check_manifest _check_tree _check_version
5356

5457
dist: ## Build distribution artifacts.
5558
python -m build
@@ -61,8 +64,33 @@ pypi: ## Upload distributions to PyPI.
6164
testpypi: ## Upload distributions to test PyPI
6265
twine upload --verbose --repository testpypi --password $$TWINE_TEST_PASSWORD dist/*
6366

64-
check_release: _check_manifest ## Check that we are ready for a release
67+
tag: ## Make a git tag with the version number
68+
git tag -s -m "Version $(VERSION)" v$(VERSION)
69+
git push --all
70+
71+
release: _check_credentials clean check_release dist pypi tag ## Do all the steps for a release
72+
@echo "Release $(VERSION) complete!"
73+
74+
check_release: _check_manifest _check_tree _check_version ## Check that we are ready for a release
6575
@echo "Release checks passed"
6676

77+
_check_credentials:
78+
@if [[ -z "$$TWINE_PASSWORD" ]]; then \
79+
echo 'Missing TWINE_PASSWORD'; \
80+
exit 1; \
81+
fi
82+
6783
_check_manifest:
6884
python -m check_manifest
85+
86+
_check_tree:
87+
@if [[ -n $$(git status --porcelain) ]]; then \
88+
echo 'There are modified files! Did you forget to check them in?'; \
89+
exit 1; \
90+
fi
91+
92+
_check_version:
93+
@if git tag | grep -q -w v$(VERSION); then \
94+
echo 'A git tag for this version exists! Did you forget to bump the version?'; \
95+
exit 1; \
96+
fi

0 commit comments

Comments
 (0)