Skip to content
This repository was archived by the owner on Feb 21, 2024. It is now read-only.

Commit 13f53b5

Browse files
author
Sam Briesemeister
committed
Release tag automation redux
1 parent 155ac09 commit 13f53b5

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.pyc
2-
RELEASE_VERSION
2+
release-tag
3+
commit-tag
34
dist/
45
build/
56
scratch/

Makefile

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11

2-
.PHONY: install clean remove build upload test RELEASE_VERSION release-tag
2+
.PHONY: install clean remove build upload test release-tag commit-tag git-status-clean push-release release-checkout
33

44
GIT_COMMIT = $(shell git log -1 "--pretty=format:%H")
55
GIT_BRANCH = $(shell git describe --contains --all HEAD)
66
GIT_STATUS = $(shell git status -sb --untracked=no | wc -l | awk '{ if($$1 == 1){ print "clean" } else { print "pending" } }')
77

8+
VERSION_PATTERN = "^[0-9]+\.[0-9]+\.[0-9]+$$"
9+
10+
811
install:
912
python setup.py install
1013

@@ -15,16 +18,34 @@ clean:
1518
build: test
1619
python setup.py build
1720

18-
upload: build test RELEASE_VERSION
21+
upload: git-status-clean test commit-tag
1922
python setup.py sdist upload
2023

21-
release-tag: RELEASE_VERSION
22-
test "${GIT_STATUS}" == "clean" || echo "GIT STATUS NOT CLEAN" >&2
23-
git tag `tail -n 1 RELEASE_VERSION`
24+
25+
push-release: release upload
26+
27+
28+
git-status-clean:
29+
test "${GIT_STATUS}" == "clean" || (echo "GIT STATUS NOT CLEAN"; exit 1) >&2
30+
31+
32+
release: release-tag
33+
echo "## Tagging release " `cat release-tag`
34+
git tag `cat release-tag`
35+
36+
release-checkout:
37+
git checkout release
38+
39+
40+
release-tag: git-status-clean release-checkout test
41+
(echo "0.0.0"; git tag --list) | egrep "${VERSION_PATTERN}" | \
42+
sort -n | tail -n 1 | \
43+
awk -F '.' '{ printf("%d.%d.%d\n", ($$1), ($$2), ($$3) + 1 ) }' > $@
2444

2545

26-
RELEASE_VERSION:
27-
(echo "0.0.0"; git tag --list) | sort -n | egrep "^[0-9]+\.[0-9]+\.[0-9]+$$" | awk -F '.' '{ printf("%d.%d.%d\n", ($$1), ($$2), ($$3) + 1 ) }' > $@
46+
commit-tag: git-status-clean
47+
git tag --list --points-at=${GIT_COMMIT} | egrep "${VERSION_PATTERN}" | \
48+
sort -n | tail -n 1 > $@
2849

2950

3051
test:

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from setuptools import setup
2+
import sys
3+
4+
VERSION=open('commit-tag').read().strip()
5+
print >>sys.stderr, "Preparing version {0}\n".format(VERSION or "NOTFOUND")
26

3-
VERSION=open('RELEASE_VERSION').read().strip().split('\n')[-1]
47

58
try:
69
long_description=open('DESCRIPTION.rst', 'rt').read()

0 commit comments

Comments
 (0)