diff options
author | Mark Pulford <mark@kyne.com.au> | 2011-12-15 19:04:55 +1030 |
---|---|---|
committer | Mark Pulford <mark@kyne.com.au> | 2011-12-15 19:04:55 +1030 |
commit | 1d8eba4368aa53ad5e534b68873d24b3ee69cc51 (patch) | |
tree | b89337163d96a0f48e0eda487ef36aa48e1cc1cd | |
parent | 353784724505b23539aa693bd2aed3932493ed62 (diff) | |
download | lua-cjson-1d8eba4368aa53ad5e534b68873d24b3ee69cc51.tar.gz lua-cjson-1d8eba4368aa53ad5e534b68873d24b3ee69cc51.tar.bz2 lua-cjson-1d8eba4368aa53ad5e534b68873d24b3ee69cc51.zip |
Automate package releases with build-packages.sh
build-packages.sh has several advantages:
- Automatically bumps version numbers
- Builds HTML documentation on the fly
-rw-r--r-- | .gitattributes | 2 | ||||
-rw-r--r-- | Makefile | 7 | ||||
-rwxr-xr-x | build-packages.sh | 46 | ||||
-rw-r--r-- | lua-cjson-1.0devel-1.rockspec (renamed from lua-cjson-1.0.4-1.rockspec) | 4 | ||||
-rw-r--r-- | lua-cjson.spec | 4 | ||||
-rw-r--r-- | lua_cjson.c | 2 | ||||
-rw-r--r-- | manual.txt | 9 | ||||
-rwxr-xr-x | runtests.sh | 37 |
8 files changed, 82 insertions, 29 deletions
diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..07f243a --- /dev/null +++ b/.gitattributes | |||
@@ -0,0 +1,2 @@ | |||
1 | .gitattributes export-ignore | ||
2 | build-packages.sh export-ignore | ||
@@ -1,4 +1,3 @@ | |||
1 | CJSON_VERSION = 1.0.4 | ||
2 | LUA_VERSION = 5.1 | 1 | LUA_VERSION = 5.1 |
3 | 2 | ||
4 | ## Available Lua CJSON specific workarounds | 3 | ## Available Lua CJSON specific workarounds |
@@ -69,9 +68,3 @@ manual.html: manual.txt | |||
69 | 68 | ||
70 | clean: | 69 | clean: |
71 | rm -f *.o *.so | 70 | rm -f *.o *.so |
72 | |||
73 | package: | ||
74 | git archive --prefix="lua-cjson-$(CJSON_VERSION)/" master | \ | ||
75 | gzip -9 > "lua-cjson-$(CJSON_VERSION).tar.gz" | ||
76 | git archive --prefix="lua-cjson-$(CJSON_VERSION)/" \ | ||
77 | -o "lua-cjson-$(CJSON_VERSION).zip" master | ||
diff --git a/build-packages.sh b/build-packages.sh new file mode 100755 index 0000000..858ad0d --- /dev/null +++ b/build-packages.sh | |||
@@ -0,0 +1,46 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # build-packages.sh [ VERSION [ BRANCH ] ] | ||
4 | |||
5 | # No args: Build current 1.0devel packages | ||
6 | # 1 args: Build release package for VERSION (>= 1.0.5) | ||
7 | # 2 args: Build release package for VERSION from BRANCH | ||
8 | |||
9 | # Files requiring a version bump | ||
10 | VERSION_FILES="lua-cjson-1.0devel-1.rockspec lua-cjson.spec lua_cjson.c manual.txt runtests.sh" | ||
11 | |||
12 | if [ "$1" ] | ||
13 | then | ||
14 | VERSION="$1" | ||
15 | BRANCH="cjson-$VERSION" | ||
16 | VER_BUMP=1 | ||
17 | else | ||
18 | VERSION=1.0devel | ||
19 | BRANCH=master | ||
20 | fi | ||
21 | |||
22 | [ "$2" ] && BRANCH="$2" | ||
23 | |||
24 | PREFIX="lua-cjson-$VERSION" | ||
25 | |||
26 | set -x | ||
27 | set -e | ||
28 | |||
29 | DESTDIR="`pwd`/packages" | ||
30 | mkdir -p "$DESTDIR" | ||
31 | BUILDROOT="`mktemp -d`" | ||
32 | trap "rm -rf '$BUILDROOT'" 0 | ||
33 | |||
34 | git archive --prefix="$PREFIX/" "$BRANCH" | tar xf - -C "$BUILDROOT" | ||
35 | cd "$BUILDROOT" | ||
36 | |||
37 | if [ "$VER_BUMP" ]; then | ||
38 | ( cd "$PREFIX" | ||
39 | rename 1.0devel "$VERSION" $VERSION_FILES | ||
40 | perl -pi -e "s/\\b1.0devel\\b/$VERSION/g" ${VERSION_FILES/1.0devel/$VERSION}; ) | ||
41 | fi | ||
42 | make -C "$PREFIX" doc | ||
43 | tar cf - "$PREFIX" | gzip -9 > "$DESTDIR/$PREFIX.tar.gz" | ||
44 | zip -9rq "$DESTDIR/$PREFIX.zip" "$PREFIX" | ||
45 | |||
46 | # vi:ai et sw=4 ts=4: | ||
diff --git a/lua-cjson-1.0.4-1.rockspec b/lua-cjson-1.0devel-1.rockspec index ee287b5..8df0658 100644 --- a/lua-cjson-1.0.4-1.rockspec +++ b/lua-cjson-1.0devel-1.rockspec | |||
@@ -1,8 +1,8 @@ | |||
1 | package = "lua-cjson" | 1 | package = "lua-cjson" |
2 | version = "1.0.4-1" | 2 | version = "1.0devel-1" |
3 | 3 | ||
4 | source = { | 4 | source = { |
5 | url = "http://www.kyne.com.au/~mark/software/lua-cjson-1.0.4.zip", | 5 | url = "http://www.kyne.com.au/~mark/software/lua-cjson-1.0devel.zip", |
6 | } | 6 | } |
7 | 7 | ||
8 | description = { | 8 | description = { |
diff --git a/lua-cjson.spec b/lua-cjson.spec index c446bfb..0f7fe9a 100644 --- a/lua-cjson.spec +++ b/lua-cjson.spec | |||
@@ -2,7 +2,7 @@ | |||
2 | %define lualibdir %{_libdir}/lua/%{luaver} | 2 | %define lualibdir %{_libdir}/lua/%{luaver} |
3 | 3 | ||
4 | Name: lua-cjson | 4 | Name: lua-cjson |
5 | Version: 1.0.4 | 5 | Version: 1.0devel |
6 | Release: 1%{?dist} | 6 | Release: 1%{?dist} |
7 | Summary: JSON support for the Lua language | 7 | Summary: JSON support for the Lua language |
8 | 8 | ||
@@ -39,7 +39,7 @@ rm -rf "$RPM_BUILD_ROOT" | |||
39 | 39 | ||
40 | %files | 40 | %files |
41 | %defattr(-,root,root,-) | 41 | %defattr(-,root,root,-) |
42 | %doc LICENSE NEWS performance.txt manual.txt rfc4627.txt tests THANKS TODO | 42 | %doc LICENSE NEWS performance.txt manual.html manual.txt rfc4627.txt tests THANKS TODO |
43 | %{lualibdir}/* | 43 | %{lualibdir}/* |
44 | 44 | ||
45 | 45 | ||
diff --git a/lua_cjson.c b/lua_cjson.c index 24fb13d..b3c816d 100644 --- a/lua_cjson.c +++ b/lua_cjson.c | |||
@@ -45,7 +45,7 @@ | |||
45 | #include "strbuf.h" | 45 | #include "strbuf.h" |
46 | 46 | ||
47 | #ifndef CJSON_VERSION | 47 | #ifndef CJSON_VERSION |
48 | #define CJSON_VERSION "1.0.4" | 48 | #define CJSON_VERSION "1.0devel" |
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | /* Support to reset locale to POSIX for strtod() / sprintf(). | 51 | /* Support to reset locale to POSIX for strtod() / sprintf(). |
@@ -1,7 +1,6 @@ | |||
1 | Lua CJSON Manual | 1 | = Lua CJSON 1.0devel Manual = |
2 | ================ | ||
3 | Mark Pulford <mark@kyne.com.au> | 2 | Mark Pulford <mark@kyne.com.au> |
4 | v1.0.4, November 30 2011 | 3 | :revdate: 30th November 2011 |
5 | 4 | ||
6 | Overview | 5 | Overview |
7 | -------- | 6 | -------- |
@@ -96,7 +95,7 @@ similar) then: | |||
96 | 95 | ||
97 | [source,sh] | 96 | [source,sh] |
98 | ----------- | 97 | ----------- |
99 | rpmbuild -tb lua-cjson-1.0.4.tar.gz | 98 | rpmbuild -tb lua-cjson-1.0devel.tar.gz |
100 | rpm -Uvh $newly_built_lua_cjson_rpm | 99 | rpm -Uvh $newly_built_lua_cjson_rpm |
101 | ----------- | 100 | ----------- |
102 | 101 | ||
@@ -111,7 +110,7 @@ Extract the Lua CJSON source package into a directory and run: | |||
111 | 110 | ||
112 | [source,sh] | 111 | [source,sh] |
113 | ----------- | 112 | ----------- |
114 | cd lua-cjson-1.0.4 | 113 | cd lua-cjson-1.0devel |
115 | luarocks make | 114 | luarocks make |
116 | ----------- | 115 | ----------- |
117 | 116 | ||
diff --git a/runtests.sh b/runtests.sh index c520be0..d313db3 100755 --- a/runtests.sh +++ b/runtests.sh | |||
@@ -1,13 +1,14 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | PLATFORM="`uname -s`" | 3 | PLATFORM="`uname -s`" |
4 | [ "$1" ] && VERSION="$1" || VERSION="1.0devel" | ||
4 | 5 | ||
5 | set -e | 6 | set -e |
6 | 7 | ||
7 | # Portable "ggrep -A" replacement | 8 | # Portable "ggrep -A" replacement |
8 | # contextgrep PATTERN POST_MATCH_LINES | 9 | # contextgrep PATTERN POST_MATCH_LINES |
9 | contextgrep() { | 10 | contextgrep() { |
10 | awk "/$1/ { count = ($2 + 1) } count { count--; print }" | 11 | awk "/$1/ { count = ($2 + 1) } count { count--; print }" |
11 | } | 12 | } |
12 | 13 | ||
13 | do_tests() { | 14 | do_tests() { |
@@ -33,11 +34,11 @@ echo "===== Verifying cjson.so is not installed =====" | |||
33 | cd tests | 34 | cd tests |
34 | if lua -e 'require "cjson"' 2>/dev/null | 35 | if lua -e 'require "cjson"' 2>/dev/null |
35 | then | 36 | then |
36 | cat <<EOT | 37 | cat <<EOT |
37 | Please ensure you do not have the Lua CJSON module installed before | 38 | Please ensure you do not have the Lua CJSON module installed before |
38 | running these tests. | 39 | running these tests. |
39 | EOT | 40 | EOT |
40 | exit | 41 | exit |
41 | fi | 42 | fi |
42 | cd .. | 43 | cd .. |
43 | 44 | ||
@@ -66,13 +67,25 @@ rm -rf build tests/cjson.so | |||
66 | 67 | ||
67 | if [ "$PLATFORM" = "Linux" ] | 68 | if [ "$PLATFORM" = "Linux" ] |
68 | then | 69 | then |
69 | echo "===== Testing RPM build =====" | 70 | echo "===== Testing RPM build =====" |
70 | make package | 71 | SRCTGZ="" |
71 | LOG=/tmp/build.$$ | 72 | TGZ=lua-cjson-$VERSION.tar.gz |
72 | rpmbuild -tb lua-cjson-1.0.4.tar.gz | tee "$LOG" | 73 | for D in .. packages . |
73 | RPM="`awk '/^Wrote: / && ! /debuginfo/ { print $2}' < "$LOG"`" | 74 | do |
74 | sudo -- rpm -Uvh \"$RPM\" | 75 | [ -r "$D/$TGZ" ] && SRCTGZ="$D/$TGZ" |
75 | do_tests | 76 | done |
76 | sudo -- rpm -e lua-cjson | 77 | if [ "$SRCTGZ" ] |
77 | rm -f "$LOG" | 78 | then |
79 | LOG=/tmp/build.$$ | ||
80 | rpmbuild -tb "$SRCTGZ" > "$LOG" | ||
81 | RPM="`awk '/^Wrote: / && ! /debuginfo/ { print $2}' < "$LOG"`" | ||
82 | sudo -- rpm -Uvh \"$RPM\" | ||
83 | do_tests | ||
84 | sudo -- rpm -e lua-cjson | ||
85 | rm -f "$LOG" | ||
86 | else | ||
87 | echo "==> skipping, $TGZ not found" | ||
88 | fi | ||
78 | fi | 89 | fi |
90 | |||
91 | # vi:ai et sw=4 ts=4: | ||