Skip to content

Commit 5904eb8

Browse files
committed
Build SQLCipher from configured version
1 parent aa96814 commit 5904eb8

7 files changed

Lines changed: 51 additions & 23 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ jobs:
1717
ANDROID_NDK_VERSION: 26.3.11579264
1818
ANDROID_NDK_HOME: ${{ github.workspace }}/android-sdk/ndk/26.3.11579264
1919
ANDROID_HOME: ${{ github.workspace }}/android-sdk
20-
USE_GITHUB_TAG_AS_SQLCIPHER_REF: "1"
2120
steps:
2221
- uses: actions/checkout@v4
2322

@@ -44,4 +43,4 @@ jobs:
4443
env:
4544
GH_TOKEN: ${{ github.token }}
4645
run: |
47-
gh release create "${GITHUB_REF_NAME}" dist/* --title "${GITHUB_REF_NAME}" --notes "SQLCipher Android CLI build from sqlcipher/sqlcipher@${GITHUB_REF_NAME}."
46+
gh release create "${GITHUB_REF_NAME}" dist/* --title "${GITHUB_REF_NAME}" --notes "SQLCipher Android CLI build from the SQLCipher version configured in config/versions.env."

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,30 +80,30 @@ SELECT * FROM t;
8080

8181
## Version Policy
8282

83-
Edit `config/versions.env` to change upstream refs:
83+
Edit `config/versions.env` to change the upstream SQLCipher version:
8484

8585
```text
86-
SQLCIPHER_REF=refs/heads/master
86+
SQLCIPHER_REPO=sqlcipher/sqlcipher
87+
SQLCIPHER_VERSION=4.16.0
88+
SQLCIPHER_REF=
8789
LIBTOMCRYPT_REF=refs/tags/v1.18.2
8890
LIBTOMMATH_REF=refs/tags/v1.3.0
8991
```
9092

91-
For reproducible local builds, pin `SQLCIPHER_REF` to an upstream tag or commit ref instead of `refs/heads/master`.
93+
By default, `SQLCIPHER_VERSION=4.16.0` downloads:
9294

93-
Release tags in this repository should match official SQLCipher tags. For example:
94-
95-
```bash
96-
git tag v4.6.1
97-
git push origin v4.6.1
95+
```text
96+
sqlcipher/sqlcipher@refs/tags/v4.16.0
9897
```
9998

100-
When GitHub Actions runs from a tag, it ignores the default `SQLCIPHER_REF` value and downloads:
99+
Use `SQLCIPHER_REF` only for non-standard builds, such as a branch or a specific commit archive ref.
101100

102-
```text
103-
sqlcipher/sqlcipher@refs/tags/<tag>
104-
```
101+
Release tags in this repository should normally match `SQLCIPHER_VERSION`. For example, when `SQLCIPHER_VERSION=4.16.0`:
105102

106-
If the matching upstream SQLCipher tag does not exist, the release build fails instead of publishing a mismatched binary.
103+
```bash
104+
git tag v4.16.0
105+
git push origin v4.16.0
106+
```
107107

108108
## Compatibility Notes
109109

config/versions.env

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
# Official source refs. Use full refs so GitHub codeload resolves branches/tags consistently.
1+
# Official SQLCipher version. This maps to the upstream tag v${SQLCIPHER_VERSION}.
22
SQLCIPHER_REPO=sqlcipher/sqlcipher
3-
SQLCIPHER_REF=refs/heads/master
3+
SQLCIPHER_VERSION=4.16.0
4+
5+
# Optional override for non-release builds. Leave empty to use SQLCIPHER_VERSION.
6+
SQLCIPHER_REF=
47

58
# SQLCipher crypto provider used by this builder.
69
# LibTomCrypt is one of the providers supported by upstream SQLCipher and keeps

scripts/build.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ SQLCIPHER_SRC="$SRC_DIR/sqlcipher"
2828
AMALGAMATION_DIR="$BUILD_DIR/amalgamation"
2929

3030
prepare_sqlcipher_amalgamation() {
31+
local marker="$AMALGAMATION_DIR/.builder-source"
32+
local expected="${SQLCIPHER_REPO:-sqlcipher/sqlcipher}@$SQLCIPHER_REF"
33+
34+
if [[ -d "$AMALGAMATION_DIR" ]]; then
35+
if [[ ! -f "$marker" || "$(cat "$marker")" != "$expected" ]]; then
36+
rm -rf "$AMALGAMATION_DIR"
37+
fi
38+
fi
39+
3140
if [[ -s "$AMALGAMATION_DIR/sqlite3.c" && -s "$AMALGAMATION_DIR/shell.c" ]]; then
3241
return
3342
fi
@@ -36,6 +45,7 @@ prepare_sqlcipher_amalgamation() {
3645
rm -rf "$AMALGAMATION_DIR"
3746
mkdir -p "$AMALGAMATION_DIR"
3847
cp -R "$SQLCIPHER_SRC/." "$AMALGAMATION_DIR/"
48+
printf '%s\n' "$expected" > "$marker"
3949
(
4050
cd "$AMALGAMATION_DIR"
4151
./configure --with-tempstore=yes \
@@ -134,4 +144,3 @@ done
134144

135145
echo "Build outputs:"
136146
find "$BUILD_DIR/out" -type f -name sqlcipher -print
137-

scripts/common.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,16 @@ if [[ -f "$CONFIG_FILE" ]]; then
99
source "$CONFIG_FILE"
1010
fi
1111

12-
if [[ "${USE_GITHUB_TAG_AS_SQLCIPHER_REF:-0}" == "1" && "${GITHUB_REF_TYPE:-}" == "tag" && -n "${GITHUB_REF_NAME:-}" ]]; then
13-
SQLCIPHER_REF="refs/tags/$GITHUB_REF_NAME"
12+
if [[ -z "${SQLCIPHER_REF:-}" ]]; then
13+
if [[ -n "${SQLCIPHER_VERSION:-}" ]]; then
14+
if [[ "$SQLCIPHER_VERSION" == v* ]]; then
15+
SQLCIPHER_REF="refs/tags/$SQLCIPHER_VERSION"
16+
else
17+
SQLCIPHER_REF="refs/tags/v$SQLCIPHER_VERSION"
18+
fi
19+
else
20+
SQLCIPHER_REF="refs/heads/master"
21+
fi
1422
fi
1523

1624
BUILD_DIR="${BUILD_DIR:-$ROOT_DIR/build}"

scripts/fetch.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,21 @@ download_archive() {
1010
local repo="$1"
1111
local ref="$2"
1212
local name="$3"
13-
local archive="$DOWNLOAD_DIR/$name.tar.gz"
13+
local safe_ref="${ref//\//_}"
14+
local archive="$DOWNLOAD_DIR/$name-$safe_ref.tar.gz"
1415
local target="$SRC_DIR/$name"
1516
local tmp="$SRC_DIR/.extract-$name"
17+
local marker="$target/.builder-source"
18+
local expected="$repo@$ref"
1619

1720
mkdir -p "$DOWNLOAD_DIR" "$SRC_DIR"
1821

22+
if [[ -d "$target" ]]; then
23+
if [[ ! -f "$marker" || "$(cat "$marker")" != "$expected" ]]; then
24+
rm -rf "$target"
25+
fi
26+
fi
27+
1928
if [[ ! -s "$archive" ]]; then
2029
echo "Downloading $repo@$ref"
2130
curl -L --fail --retry 3 --connect-timeout 30 \
@@ -34,6 +43,7 @@ download_archive() {
3443
exit 1
3544
fi
3645
mv "$extracted" "$target"
46+
printf '%s\n' "$expected" > "$marker"
3747
rm -rf "$tmp"
3848
fi
3949
}
@@ -43,4 +53,3 @@ download_archive "${LIBTOMCRYPT_REPO:-libtom/libtomcrypt}" "${LIBTOMCRYPT_REF:-r
4353
download_archive "${LIBTOMMATH_REPO:-libtom/libtommath}" "${LIBTOMMATH_REF:-refs/tags/v1.3.0}" libtommath
4454

4555
echo "Sources are ready under $SRC_DIR"
46-

scripts/package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require_cmd shasum
88

99
mkdir -p "$DIST_DIR"
1010

11-
version="${GITHUB_REF_NAME:-}"
11+
version=""
1212
if [[ -z "$version" && -f "$BUILD_DIR/amalgamation/sqlite3.c" ]]; then
1313
version="$(sed -n 's/^#define CIPHER_VERSION_NUMBER[[:space:]]\{1,\}\([0-9][0-9.]*\)$/v\1/p' "$BUILD_DIR/amalgamation/sqlite3.c" | head -1)"
1414
fi

0 commit comments

Comments
 (0)