Skip to content

Commit 0a47115

Browse files
committed
feat: improved building against tags, removed unused Dockerfile deps
1 parent f0553ab commit 0a47115

4 files changed

Lines changed: 57 additions & 11 deletions

File tree

Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@ RUN apt-get update \
1818
npm \
1919
zip \
2020
unzip \
21-
curl \
22-
wabt \
2321
&& rm -rf /var/lib/apt/lists/*
2422

2523
# create useful dirs
2624
RUN mkdir -p /build /out /src/bin /work
2725

2826
# copy helper script
29-
COPY scripts/build-sqlite3-wasm.sh /usr/local/bin/build-sqlite3-wasm.sh
30-
RUN chmod +x /usr/local/bin/build-sqlite3-wasm.sh
27+
COPY --chmod=755 scripts/build-sqlite3-wasm.sh /usr/local/bin/build-sqlite3-wasm.sh
3128

3229
WORKDIR /work
3330

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sqlite.org/sqlite-wasm",
3-
"version": "3.51.2-build8",
3+
"version": "3.51.3-build1",
44
"description": "SQLite Wasm conveniently wrapped as an ES Module.",
55
"type": "module",
66
"repository": {

scripts/build-sqlite3-wasm.sh

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,74 @@ log "Ref: $SQLITE_REF"
5959
log "Out: $OUT_DIR"
6060
log "Src dir: $SRC_DIR"
6161

62+
resolve_and_fetch_ref() {
63+
local repo_dir="$1"
64+
local ref="$2"
65+
66+
# Try as provided (works for explicit refs and SHAs)
67+
if git -C "$repo_dir" fetch --depth 1 origin "$ref"; then
68+
return 0
69+
fi
70+
71+
# Try as branch name
72+
if git -C "$repo_dir" fetch --depth 1 origin "refs/heads/$ref"; then
73+
return 0
74+
fi
75+
76+
# Try as tag name
77+
if git -C "$repo_dir" fetch --depth 1 origin "refs/tags/$ref"; then
78+
return 0
79+
fi
80+
81+
# SQLite release tags are commonly prefixed with version-
82+
if git -C "$repo_dir" fetch --depth 1 origin "refs/tags/version-$ref"; then
83+
return 0
84+
fi
85+
86+
# Last attempt without shallow for commit SHAs and uncommon refs
87+
if git -C "$repo_dir" fetch origin "$ref"; then
88+
return 0
89+
fi
90+
91+
if git -C "$repo_dir" fetch origin "refs/heads/$ref"; then
92+
return 0
93+
fi
94+
95+
if git -C "$repo_dir" fetch origin "refs/tags/$ref"; then
96+
return 0
97+
fi
98+
99+
if git -C "$repo_dir" fetch origin "refs/tags/version-$ref"; then
100+
return 0
101+
fi
102+
103+
return 1
104+
}
105+
62106
# prepare source dir: clone shallow or fetch+reset if exists
63107
if [ -d "$SRC_DIR/.git" ]; then
64108
log "Repository already exists, fetching updates..."
65-
git -C "$SRC_DIR" fetch --depth 1 origin "$SQLITE_REF" || git -C "$SRC_DIR" fetch --unshallow || true
66-
git -C "$SRC_DIR" checkout --detach FETCH_HEAD || git -C "$SRC_DIR" checkout "$SQLITE_REF" || git -C "$SRC_DIR" reset --hard origin/"$SQLITE_REF"
109+
if resolve_and_fetch_ref "$SRC_DIR" "$SQLITE_REF"; then
110+
git -C "$SRC_DIR" checkout --detach FETCH_HEAD
111+
else
112+
log "Failed to fetch ref from existing repository, attempting full fetch..."
113+
git -C "$SRC_DIR" fetch --all --tags
114+
git -C "$SRC_DIR" checkout --detach "$SQLITE_REF" || git -C "$SRC_DIR" checkout --detach "refs/tags/$SQLITE_REF" || git -C "$SRC_DIR" checkout --detach "refs/tags/version-$SQLITE_REF" || git -C "$SRC_DIR" checkout --detach "origin/$SQLITE_REF"
115+
fi
67116
else
68117
log "Cloning repository..."
69118
rm -rf "$SRC_DIR"
70119
mkdir -p "$SRC_DIR"
71120
git -C "$SRC_DIR" init
72121
git -C "$SRC_DIR" remote add origin "$SQLITE_REPO"
73122
log "Fetching ref: $SQLITE_REF"
74-
if git -C "$SRC_DIR" fetch --depth 1 origin "$SQLITE_REF"; then
123+
if resolve_and_fetch_ref "$SRC_DIR" "$SQLITE_REF"; then
75124
git -C "$SRC_DIR" checkout --detach FETCH_HEAD
76125
else
77126
log "Failed to fetch shallow ref, trying full clone..."
78127
rm -rf "$SRC_DIR"
79128
git clone "$SQLITE_REPO" "$SRC_DIR"
80-
git -C "$SRC_DIR" checkout "$SQLITE_REF"
129+
git -C "$SRC_DIR" checkout --detach "$SQLITE_REF" || git -C "$SRC_DIR" checkout --detach "refs/tags/$SQLITE_REF" || git -C "$SRC_DIR" checkout --detach "refs/tags/version-$SQLITE_REF" || git -C "$SRC_DIR" checkout --detach "origin/$SQLITE_REF"
81130
fi
82131
fi
83132

0 commit comments

Comments
 (0)