aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Pulford <mark@kyne.com.au>2011-12-15 19:04:55 +1030
committerMark Pulford <mark@kyne.com.au>2011-12-15 19:04:55 +1030
commit1d8eba4368aa53ad5e534b68873d24b3ee69cc51 (patch)
treeb89337163d96a0f48e0eda487ef36aa48e1cc1cd
parent353784724505b23539aa693bd2aed3932493ed62 (diff)
downloadlua-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--.gitattributes2
-rw-r--r--Makefile7
-rwxr-xr-xbuild-packages.sh46
-rw-r--r--lua-cjson-1.0devel-1.rockspec (renamed from lua-cjson-1.0.4-1.rockspec)4
-rw-r--r--lua-cjson.spec4
-rw-r--r--lua_cjson.c2
-rw-r--r--manual.txt9
-rwxr-xr-xruntests.sh37
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
2build-packages.sh export-ignore
diff --git a/Makefile b/Makefile
index 3e179e8..9b1b649 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,3 @@
1CJSON_VERSION = 1.0.4
2LUA_VERSION = 5.1 1LUA_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
70clean: 69clean:
71 rm -f *.o *.so 70 rm -f *.o *.so
72
73package:
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
10VERSION_FILES="lua-cjson-1.0devel-1.rockspec lua-cjson.spec lua_cjson.c manual.txt runtests.sh"
11
12if [ "$1" ]
13then
14 VERSION="$1"
15 BRANCH="cjson-$VERSION"
16 VER_BUMP=1
17else
18 VERSION=1.0devel
19 BRANCH=master
20fi
21
22[ "$2" ] && BRANCH="$2"
23
24PREFIX="lua-cjson-$VERSION"
25
26set -x
27set -e
28
29DESTDIR="`pwd`/packages"
30mkdir -p "$DESTDIR"
31BUILDROOT="`mktemp -d`"
32trap "rm -rf '$BUILDROOT'" 0
33
34git archive --prefix="$PREFIX/" "$BRANCH" | tar xf - -C "$BUILDROOT"
35cd "$BUILDROOT"
36
37if [ "$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}; )
41fi
42make -C "$PREFIX" doc
43tar cf - "$PREFIX" | gzip -9 > "$DESTDIR/$PREFIX.tar.gz"
44zip -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 @@
1package = "lua-cjson" 1package = "lua-cjson"
2version = "1.0.4-1" 2version = "1.0devel-1"
3 3
4source = { 4source = {
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
8description = { 8description = {
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
4Name: lua-cjson 4Name: lua-cjson
5Version: 1.0.4 5Version: 1.0devel
6Release: 1%{?dist} 6Release: 1%{?dist}
7Summary: JSON support for the Lua language 7Summary: 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().
diff --git a/manual.txt b/manual.txt
index ab08377..4229b51 100644
--- a/manual.txt
+++ b/manual.txt
@@ -1,7 +1,6 @@
1Lua CJSON Manual 1= Lua CJSON 1.0devel Manual =
2================
3Mark Pulford <mark@kyne.com.au> 2Mark Pulford <mark@kyne.com.au>
4v1.0.4, November 30 2011 3:revdate: 30th November 2011
5 4
6Overview 5Overview
7-------- 6--------
@@ -96,7 +95,7 @@ similar) then:
96 95
97[source,sh] 96[source,sh]
98----------- 97-----------
99rpmbuild -tb lua-cjson-1.0.4.tar.gz 98rpmbuild -tb lua-cjson-1.0devel.tar.gz
100rpm -Uvh $newly_built_lua_cjson_rpm 99rpm -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-----------
114cd lua-cjson-1.0.4 113cd lua-cjson-1.0devel
115luarocks make 114luarocks 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
3PLATFORM="`uname -s`" 3PLATFORM="`uname -s`"
4[ "$1" ] && VERSION="$1" || VERSION="1.0devel"
4 5
5set -e 6set -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
9contextgrep() { 10contextgrep() {
10 awk "/$1/ { count = ($2 + 1) } count { count--; print }" 11 awk "/$1/ { count = ($2 + 1) } count { count--; print }"
11} 12}
12 13
13do_tests() { 14do_tests() {
@@ -33,11 +34,11 @@ echo "===== Verifying cjson.so is not installed ====="
33cd tests 34cd tests
34if lua -e 'require "cjson"' 2>/dev/null 35if lua -e 'require "cjson"' 2>/dev/null
35then 36then
36 cat <<EOT 37 cat <<EOT
37Please ensure you do not have the Lua CJSON module installed before 38Please ensure you do not have the Lua CJSON module installed before
38running these tests. 39running these tests.
39EOT 40EOT
40 exit 41 exit
41fi 42fi
42cd .. 43cd ..
43 44
@@ -66,13 +67,25 @@ rm -rf build tests/cjson.so
66 67
67if [ "$PLATFORM" = "Linux" ] 68if [ "$PLATFORM" = "Linux" ]
68then 69then
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
78fi 89fi
90
91# vi:ai et sw=4 ts=4: