1
1
#! /bin/sh
2
- # Prepare sqleet.c sqleet.h amalgamation for a release.
2
+ # Prepare release archives .
3
3
4
4
set -e
5
5
6
6
die () {
7
- rm -f tmp-rekeyvacuum.c tmp-sqleet.c tmp-sqleet.h
7
+ [ ! -z " $RELEASE " ] && rm -rf " $RELEASE_DIR " " $RELEASE .zip " " $RELEASE .tar.gz "
8
8
[ " $# " -ne 0 ] && echo " [-] Error:" " $@ " >&2
9
9
exit 1
10
10
}
@@ -14,32 +14,33 @@ cd "$(git rev-parse --show-toplevel)"
14
14
git status --short | grep -vq ' ^[!?]' && die " dirty working tree (commit or stash your changes)"
15
15
VERSION=" $( sed -n ' s/^#define SQLITE_VERSION[^"]*"\([0-9]\+\.[0-9]\+\.[0-9]\+\)"$/\1/p' sqlite3.h) "
16
16
[ -z " $VERSION " ] && die " cannot find SQLite3 version"
17
+ SQLEET_VERSION=" $( echo " $VERSION " | sed ' s/^3/0/' ) "
18
+ RELEASE=" sqleet-v$SQLEET_VERSION "
19
+ RELEASE_DIR=" $RELEASE "
17
20
18
21
echo " [+] SQLite version $VERSION " >&2
19
22
20
- echo " [+] Generating rekeyvacuum.c" >&2
21
- ./script/rekeyvacuum.sh sqlite3.c > tmp-rekeyvacuum.c || die " generating rekeyvacuum.c failed"
23
+ echo " [+] Checking rekeyvacuum.c" >&2
24
+ ./script/rekeyvacuum.sh sqlite3.c | cmp -s - rekeyvacuum.c || die " rekeyvacuum.c outdated"
25
+
26
+ echo " [+] Creating release directory $RELEASE_DIR " >&2
27
+ mkdir -p " $RELEASE_DIR "
28
+ cp README.md " $RELEASE_DIR "
22
29
23
30
echo " [+] Generating sqleet.c amalgamation" >&2
24
- ./script/amalgamate.sh < sqleet.c > tmp- sqleet.c || die " sqleet.c amalgamation failed"
31
+ ./script/amalgamate.sh < sqleet.c > " $RELEASE_DIR / sqleet.c" || die " sqleet.c amalgamation failed"
25
32
26
33
echo " [+] Generating sqleet.h amalgamation" >&2
27
- ./script/amalgamate.sh < sqleet.h > tmp- sqleet.h || die " sqleet.h amalgamation failed"
34
+ ./script/amalgamate.sh < sqleet.h > " $RELEASE_DIR / sqleet.h" || die " sqleet.h amalgamation failed"
28
35
29
36
echo ' [+] Updating shell.c #include "sqlite3.h" -> "sqleet.h"' >&2
30
- sed -i ' s/^#include "sqlite3.h"$/#include "sqleet.h"/' shell.c
31
- grep -Fq ' #include "sqleet.h"' shell.c || die " failed to update shell.c include"
37
+ sed ' s/^#include "sqlite3.h"$/#include "sqleet.h"/' shell.c > " $RELEASE_DIR /shell.c "
38
+ grep -Fq ' #include "sqleet.h"' " $RELEASE_DIR / shell.c" || die " failed to update shell.c include"
32
39
33
- echo " [+] Moving files around a bit" >&2
34
- mv tmp-sqleet.h sqleet.h
35
- mv tmp-sqleet.c sqleet.c
36
- mv tmp-rekeyvacuum.c rekeyvacuum.c
37
- git add sqleet.c sqleet.h shell.c
38
- git ls-files | grep " .[ch]$\|^script/" | grep -v " sqleet.[ch]\|shell.c" | xargs git rm -fq
40
+ echo " [+] Creating release archives" >&2
41
+ zip -qr " $RELEASE -amalgamation.zip" " $RELEASE_DIR " || die " failed to create $RELEASE -amalgamation.zip"
42
+ tar -czf " $RELEASE -amalgamation.tar.gz" --owner=0 --group=0 " $RELEASE_DIR " || die " failed to create $RELEASE -amalgamation.tar.gz"
39
43
40
44
sync
41
- SQLEET_VERSION=" $( echo " $VERSION " | sed ' s/^3/0/' ) "
42
45
echo " [+] Success!" >&2
43
- echo " git checkout -b v$SQLEET_VERSION "
44
- echo " git commit -m \" Release v$SQLEET_VERSION \" "
45
- echo " git push -u origin v$SQLEET_VERSION "
46
+ echo " git tag v$SQLEET_VERSION && git push origin v$SQLEET_VERSION "
0 commit comments