11#! /bin/sh
2- # Prepare sqleet.c sqleet.h amalgamation for a release.
2+ # Prepare release archives .
33
44set -e
55
66die () {
7- rm -f tmp-rekeyvacuum.c tmp-sqleet.c tmp-sqleet.h
7+ [ ! -z " $RELEASE " ] && rm -rf " $RELEASE_DIR " " $RELEASE .zip " " $RELEASE .tar.gz "
88 [ " $# " -ne 0 ] && echo " [-] Error:" " $@ " >&2
99 exit 1
1010}
@@ -14,32 +14,33 @@ cd "$(git rev-parse --show-toplevel)"
1414git status --short | grep -vq ' ^[!?]' && die " dirty working tree (commit or stash your changes)"
1515VERSION=" $( sed -n ' s/^#define SQLITE_VERSION[^"]*"\([0-9]\+\.[0-9]\+\.[0-9]\+\)"$/\1/p' sqlite3.h) "
1616[ -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 "
1720
1821echo " [+] SQLite version $VERSION " >&2
1922
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 "
2229
2330echo " [+] 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"
2532
2633echo " [+] 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"
2835
2936echo ' [+] 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"
3239
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"
3943
4044sync
41- SQLEET_VERSION=" $( echo " $VERSION " | sed ' s/^3/0/' ) "
4245echo " [+] 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