Skip to content

Commit 122d2b8

Browse files
committed
Added prebuilt Linux ARM64 binaries to CI
refs #1362 - the referenced PR added Linux ARM64 and ARMv7 prebuilds to CI so we can get prebuilt binaries upon releasing - CI has recently been reworked so I've rebased the PR and fixed it up - unfortunately, `node-pre-gyp` seems to ignore the difference between armv6 and armv7, and treats them both as `arm` so I've had to disable prebuilds for them for now - building via QEMU is INCREDIBLY slow so I've configured it to only run during a release or upon manual execution - full credit to @n1ru4l for the original PR
1 parent 290d34f commit 122d2b8

File tree

3 files changed

+82
-1
lines changed

3 files changed

+82
-1
lines changed

Diff for: .github/workflows/ci.yml

+50
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,53 @@ jobs:
7979
if: matrix.node == 16 && startsWith(github.ref, 'refs/tags/')
8080
env:
8181
NODE_PRE_GYP_GITHUB_TOKEN: ${{ github.token }}
82+
build-qemu:
83+
runs-on: ubuntu-latest
84+
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
85+
strategy:
86+
fail-fast: false
87+
matrix:
88+
node:
89+
- 16
90+
architecture:
91+
- linux/arm64
92+
variant:
93+
- bullseye
94+
- alpine
95+
name: ${{ matrix.variant }} ${{ matrix.architecture }} - Node ${{ matrix.node }}
96+
steps:
97+
- uses: actions/checkout@v3
98+
99+
- name: Set up QEMU
100+
uses: docker/setup-qemu-action@v1
101+
102+
- name: Setup Docker Buildx
103+
uses: docker/setup-buildx-action@v1
104+
105+
- name: Build binaries and test
106+
run: |
107+
docker buildx build \
108+
--file ./tools/BinaryBuilder.Dockerfile \
109+
--load \
110+
--tag sqlite-builder \
111+
--platform ${{ matrix.architecture }} \
112+
--no-cache \
113+
--build-arg VARIANT=${{ matrix.variant }} \
114+
--build-arg NODE_VERSION=${{ matrix.node }} \
115+
.
116+
CONTAINER_ID=$(docker create -it sqlite-builder)
117+
docker cp $CONTAINER_ID:/usr/src/build/build/ ./build
118+
119+
- name: Upload binaries to commit artifacts
120+
uses: actions/upload-artifact@v3
121+
if: matrix.node == 16
122+
with:
123+
name: prebuilt-binaries
124+
path: build/stage/*/*
125+
retention-days: 7
126+
127+
- name: Upload binaries to GitHub Release
128+
run: yarn node-pre-gyp-github publish
129+
if: matrix.node == 16 && startsWith(github.ref, 'refs/tags/')
130+
env:
131+
NODE_PRE_GYP_GITHUB_TOKEN: ${{ github.token }}

Diff for: README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,27 @@ The module uses [node-pre-gyp](https://github.com/mapbox/node-pre-gyp) to downlo
4040
Format: `napi-v{napi_build_version}-{platform}-{libc}-{arch}`
4141

4242
* `napi-v3-darwin-unknown-x64`
43+
* `napi-v3-linux-glibc-arm64`
4344
* `napi-v3-linux-glibc-x64`
45+
* `napi-v3-linux-musl-arm64`
4446
* `napi-v3-win32-unknown-ia32`
4547
* `napi-v3-win32-unknown-x64`
4648
* `napi-v6-darwin-unknown-x64`
49+
* `napi-v6-linux-glibc-arm64`
4750
* `napi-v6-linux-glibc-x64`
51+
* `napi-v6-linux-musl-arm64`
4852
* `napi-v6-win32-unknown-ia32`
4953
* `napi-v6-win32-unknown-x64`
5054

55+
Unfortunately, [node-pre-gyp](https://github.com/mapbox/node-pre-gyp) cannot differentiate between `armv6` and `armv7`, and instead uses `arm` as the `{arch}`. Until that is fixed, you will still need to install `sqlite3` from [source](#source-install).
56+
5157
Support for other platforms and architectures may be added in the future if CI supports building on them.
5258

5359
If your environment isn't supported, it'll use `node-gyp` to build SQLite but you will need to install a C++ compiler and linker.
5460

5561
### Other ways to install
5662

57-
It is also possible to make your own build of `sqlite3` from its source instead of its npm package ([See below.](#building-from-the-source)).
63+
It is also possible to make your own build of `sqlite3` from its source instead of its npm package ([See below.](#source-install)).
5864

5965
The `sqlite3` module also works with [node-webkit](https://github.com/rogerwang/node-webkit) if node-webkit contains a supported version of Node.js engine. [(See below.)](#building-for-node-webkit)
6066

Diff for: tools/BinaryBuilder.Dockerfile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
ARG NODE_VERSION=16
2+
ARG VARIANT=bullseye
3+
4+
FROM node:$NODE_VERSION-$VARIANT
5+
6+
ARG VARIANT
7+
8+
RUN if [ "$VARIANT" = "alpine" ] ; then apk add build-base python3 --update-cache ; fi
9+
10+
WORKDIR /usr/src/build
11+
12+
COPY . .
13+
RUN npm install --ignore-scripts
14+
15+
# Workaround for https://github.com/mapbox/node-pre-gyp/issues/644
16+
RUN cd node_modules/\@mapbox/node-pre-gyp \
17+
&& npm install [email protected] \
18+
&& sed -i -e s/\'fs/\'fs-extra/ -e s/fs\.renameSync/fs.moveSync/ ./lib/util/napi.js
19+
20+
RUN npx node-pre-gyp configure
21+
RUN npx node-pre-gyp build
22+
RUN npm run test
23+
RUN npx node-pre-gyp package
24+
25+
CMD ["sh"]

0 commit comments

Comments
 (0)