-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
37 lines (31 loc) · 1.28 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
CHANGELOG := CHANGELOG.md
SOURCES := mergeconf/*.py
VERSION := $(shell git describe --tags | sed -e 's/^v//' -e 's/-/+/' -e 's/-/./g')
PACKAGES := dist/mergeconf-$(VERSION)-py3-none-any.whl dist/mergeconf-$(VERSION).tar.gz
all: $(PACKAGES)
.PHONY: release
release:
@sed -i '' -e 's/\(version =\) .*/\1 '$(VERSION)'/' setup.cfg
@printf "# Changelog\n\n" > $(CHANGELOG)
@format='## %(tag) (%(*committerdate:format:%Y-%m-%d)) %(subject)%0a%0a%(body)' ; \
tags=`git for-each-ref refs/tags \
--format='%(objecttype) %(refname:lstrip=2)' \
| awk '$$1 == "tag" { print $2 }'`; \
git tag --list --sort=-\*committerdate \
--format="$$format" $$tags \
>> $(CHANGELOG)
# fails if version doesn't match specific pattern, so as not to publish
# development version.
.PHONY: checkversion
checkversion:
@echo "Checking that $(VERSION) is a release version"
@[[ $(VERSION) =~ ^([0-9]+\.)*[0-9]+$$ ]]
@echo "Checking that $(VERSION) is in setup.cfg"
@grep -qw "$(VERSION)" setup.cfg
$(PACKAGES): $(SOURCES)
@echo Version: $(VERSION)
@python3 -m build
publish-test: $(PACKAGES) checkversion
@python3 -m twine upload --repository testpypi $(PACKAGES)
publish: $(PACKAGES) checkversion
@python3 -m twine upload --repository pypi $(PACKAGES)