Skip to content

Commit 402551c

Browse files
authored
Add xcframework and musl builds, sign and notarize Apple builds (#9)
* bump version to 1.1.7 * Refactor Makefile and Workflow file * Add 'extension' target to Makefile for improved build process * Add module map and header files for xcframework generation * Enhance release workflow with keychain management and codesigning for xcframework * Rename main workflow file for building, testing, and releasing sqlite-js
1 parent 3cb4996 commit 402551c

File tree

4 files changed

+351
-219
lines changed

4 files changed

+351
-219
lines changed

.github/workflows/main.yml

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
name: build, test and release sqlite-js
2+
on:
3+
push:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ matrix.os }}
12+
container: ${{ matrix.container && matrix.container || '' }}
13+
name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build${{ matrix.arch != 'arm64-v8a' && matrix.name != 'ios-sim' && matrix.name != 'ios' && matrix.name != 'apple-xcframework' && ' + test' || ''}}
14+
timeout-minutes: 20
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- os: ubuntu-22.04
20+
arch: x86_64
21+
name: linux
22+
- os: ubuntu-22.04-arm
23+
arch: arm64
24+
name: linux
25+
- os: ubuntu-22.04
26+
arch: x86_64
27+
name: linux-musl
28+
container: alpine:latest
29+
- os: ubuntu-22.04-arm
30+
arch: arm64
31+
name: linux-musl
32+
- os: macos-15
33+
name: macos
34+
- os: windows-2022
35+
arch: x86_64
36+
name: windows
37+
- os: ubuntu-22.04
38+
arch: arm64-v8a
39+
name: android
40+
make: PLATFORM=android ARCH=arm64-v8a
41+
- os: ubuntu-22.04
42+
arch: x86_64
43+
name: android
44+
make: PLATFORM=android ARCH=x86_64
45+
sqlite-amalgamation-zip: https://sqlite.org/2025/sqlite-amalgamation-3490100.zip
46+
- os: macos-15
47+
name: ios
48+
make: PLATFORM=ios
49+
- os: macos-15
50+
name: ios-sim
51+
make: PLATFORM=ios-sim
52+
- os: macos-15
53+
name: apple-xcframework
54+
make: xcframework
55+
56+
defaults:
57+
run:
58+
shell: ${{ matrix.container && 'sh' || 'bash' }}
59+
60+
steps:
61+
62+
- uses: actions/[email protected]
63+
64+
- name: windows install dependencies
65+
if: matrix.name == 'windows'
66+
run: choco install sqlite -y
67+
68+
- name: macos install dependencies
69+
if: matrix.name == 'macos'
70+
run: brew link sqlite --force
71+
72+
- name: linux-musl x86_64 install dependencies
73+
if: matrix.name == 'linux-musl' && matrix.arch == 'x86_64'
74+
run: apk update && apk add --no-cache gcc make sqlite musl-dev linux-headers
75+
76+
- name: linux-musl arm64 setup container
77+
if: matrix.name == 'linux-musl' && matrix.arch == 'arm64'
78+
run: |
79+
docker run -d --name alpine \
80+
--platform linux/arm64 \
81+
-v ${{ github.workspace }}:/workspace \
82+
-w /workspace \
83+
alpine:latest \
84+
tail -f /dev/null
85+
docker exec alpine sh -c "apk update && apk add --no-cache gcc make sqlite musl-dev linux-headers"
86+
87+
- name: build sqlite-js
88+
run: ${{ matrix.name == 'linux-musl' && matrix.arch == 'arm64' && 'docker exec alpine' || '' }} make extension ${{ matrix.make && matrix.make || ''}}
89+
90+
- name: create keychain for codesign
91+
if: matrix.os == 'macos-15'
92+
run: |
93+
echo "${{ secrets.APPLE_CERTIFICATE }}" | base64 --decode > certificate.p12
94+
security create-keychain -p "${{ secrets.KEYCHAIN_PASSWORD }}" build.keychain
95+
security default-keychain -s build.keychain
96+
security unlock-keychain -p "${{ secrets.KEYCHAIN_PASSWORD }}" build.keychain
97+
security import certificate.p12 -k build.keychain -P "${{ secrets.CERTIFICATE_PASSWORD }}" -T /usr/bin/codesign
98+
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "${{ secrets.KEYCHAIN_PASSWORD }}" build.keychain
99+
100+
- name: codesign dylib
101+
if: matrix.os == 'macos-15' && matrix.name != 'apple-xcframework'
102+
run: codesign --sign "${{ secrets.APPLE_TEAM_ID }}" --timestamp --options runtime dist/js.dylib
103+
104+
- name: codesign and notarize xcframework
105+
if: matrix.name == 'apple-xcframework'
106+
run: |
107+
find dist/js.xcframework -name "*.framework" -exec echo "Signing: {}" \; -exec codesign --sign "${{ secrets.APPLE_TEAM_ID }}" --timestamp --options runtime {} \; # Sign each individual framework FIRST
108+
codesign --sign "${{ secrets.APPLE_TEAM_ID }}" --timestamp --options runtime dist/js.xcframework # Then sign the xcframework wrapper
109+
ditto -c -k --keepParent dist/js.xcframework dist/js.xcframework.zip
110+
xcrun notarytool submit dist/js.xcframework.zip --apple-id "${{ secrets.APPLE_ID }}" --password "${{ secrets.APPLE_PASSWORD }}" --team-id "${{ secrets.APPLE_TEAM_ID }}" --wait
111+
rm dist/js.xcframework.zip
112+
113+
- name: cleanup keychain for codesign
114+
if: matrix.os == 'macos-15'
115+
run: |
116+
rm certificate.p12
117+
security delete-keychain build.keychain
118+
119+
- name: android setup test environment
120+
if: matrix.name == 'android' && matrix.arch != 'arm64-v8a'
121+
run: |
122+
123+
echo "::group::enable kvm group perms"
124+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
125+
sudo udevadm control --reload-rules
126+
sudo udevadm trigger --name-match=kvm
127+
echo "::endgroup::"
128+
129+
echo "::group::download and build sqlite3 without SQLITE_OMIT_LOAD_EXTENSION"
130+
curl -O ${{ matrix.sqlite-amalgamation-zip }}
131+
unzip sqlite-amalgamation-*.zip
132+
export ${{ matrix.make }}
133+
$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/${{ matrix.arch }}-linux-android26-clang sqlite-amalgamation-*/shell.c sqlite-amalgamation-*/sqlite3.c -o sqlite3 -ldl
134+
# remove unused folders to save up space
135+
rm -rf sqlite-amalgamation-*.zip sqlite-amalgamation-*
136+
echo "::endgroup::"
137+
138+
echo "::group::prepare the test script"
139+
make test PLATFORM=$PLATFORM ARCH=$ARCH || echo "It should fail. Running remaining commands in the emulator"
140+
cat > commands.sh << EOF
141+
mv -f /data/local/tmp/sqlite3 /system/xbin
142+
cd /data/local/tmp
143+
$(make test PLATFORM=$PLATFORM ARCH=$ARCH -n)
144+
EOF
145+
echo "::endgroup::"
146+
147+
- name: android test sqlite-js
148+
if: matrix.name == 'android' && matrix.arch != 'arm64-v8a'
149+
uses: reactivecircus/[email protected]
150+
with:
151+
api-level: 26
152+
arch: ${{ matrix.arch }}
153+
script: |
154+
adb root
155+
adb remount
156+
adb push ${{ github.workspace }}/. /data/local/tmp/
157+
adb shell "sh /data/local/tmp/commands.sh"
158+
159+
- name: test sqlite-js
160+
if: contains(matrix.name, 'linux') || matrix.name == 'windows' || matrix.name == 'macos'
161+
run: ${{ matrix.name == 'linux-musl' && matrix.arch == 'arm64' && 'docker exec alpine' || '' }} make test ${{ matrix.make && matrix.make || ''}}
162+
163+
- uses: actions/[email protected]
164+
if: always()
165+
with:
166+
name: js-${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }}
167+
path: dist/js.*
168+
if-no-files-found: error
169+
170+
release:
171+
runs-on: ubuntu-22.04
172+
name: release
173+
needs: build
174+
if: github.ref == 'refs/heads/main'
175+
176+
env:
177+
GH_TOKEN: ${{ github.token }}
178+
179+
steps:
180+
181+
- uses: actions/[email protected]
182+
183+
- uses: actions/[email protected]
184+
with:
185+
path: artifacts
186+
187+
- name: release tag version from sqlitejs.h
188+
id: tag
189+
run: |
190+
VERSION=$(make version)
191+
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
192+
LATEST=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.name')
193+
if [[ "$VERSION" != "$LATEST" || "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
194+
echo "version=$VERSION" >> $GITHUB_OUTPUT
195+
else
196+
echo "::warning file=src/sqlitejs.h::To release a new version, please update the SQLITE_JS_VERSION in src/sqlitejs.h to be different than the latest $LATEST"
197+
fi
198+
exit 0
199+
fi
200+
echo "❌ SQLITE_JS_VERSION not found in sqlitejs.h"
201+
exit 1
202+
203+
- name: zip artifacts
204+
run: |
205+
for folder in "artifacts"/*; do
206+
if [ -d "$folder" ]; then
207+
name=$(basename "$folder")
208+
if [[ "$name" != "js-apple-xcframework" ]]; then
209+
tar -czf "${name}-${{ steps.tag.outputs.version }}.tar.gz" -C "$folder" .
210+
fi
211+
(cd "$folder" && zip -rq "../../${name}-${{ steps.tag.outputs.version }}.zip" .)
212+
fi
213+
done
214+
215+
- uses: softprops/[email protected]
216+
if: steps.tag.outputs.version != ''
217+
with:
218+
generate_release_notes: true
219+
tag_name: ${{ steps.tag.outputs.version }}
220+
files: |
221+
js-*-${{ steps.tag.outputs.version }}.zip
222+
js-*-${{ steps.tag.outputs.version }}.tar.gz
223+
make_latest: true

.github/workflows/release.yml

Lines changed: 0 additions & 172 deletions
This file was deleted.

0 commit comments

Comments
 (0)