Skip to content

Commit 9d3a853

Browse files
v1.0.0
0 parents  commit 9d3a853

50 files changed

Lines changed: 287127 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/publish.yaml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# Copyright 2025 Signal Messenger, LLC
2+
# SPDX-License-Identifier: AGPL-3.0-only
3+
4+
name: Publish
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
dry_run:
9+
description: "Just build, don't publish"
10+
default: false
11+
required: false
12+
type: boolean
13+
npm_tag:
14+
description: 'NPM tag'
15+
required: true
16+
default: 'latest'
17+
18+
jobs:
19+
prebuild:
20+
strategy:
21+
matrix:
22+
os: [windows-latest, macos-latest]
23+
include:
24+
- os: macos-latest
25+
target: arm64
26+
cross-target: x64
27+
rust-cross-target: x86_64-apple-darwin
28+
- os: windows-latest
29+
target: x64
30+
cross-target: arm64
31+
rust-cross-target: aarch64-pc-windows-msvc
32+
33+
runs-on: ${{ matrix.os }}
34+
timeout-minutes: 30
35+
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
39+
- name: Setup pnpm
40+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
41+
with:
42+
version: 10.3.0
43+
44+
- name: Get Node version from .nvmrc
45+
id: get-nvm-version
46+
shell: bash
47+
run: echo "node-version=$(cat .nvmrc)" >> $GITHUB_OUTPUT
48+
49+
- name: Setup node.js
50+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
51+
with:
52+
node-version-file: '.nvmrc'
53+
54+
- name: Install node_modules
55+
run: pnpm install --frozen-lockfile
56+
57+
- run: rustup toolchain install $(cat rust-toolchain) --profile minimal --target ${{ matrix.rust-cross-target }}
58+
59+
- name: Install dump_syms
60+
run: cargo install dump_syms --no-default-features --features cli
61+
62+
- name: Prebuild ${{ matrix.target }}
63+
run: |
64+
pnpm prebuildify --target '${{ steps.get-nvm-version.outputs.node-version }}' --arch ${{ matrix.target }}
65+
- name: Prebuild ${{ matrix.cross-target }}
66+
run: pnpm prebuildify --target '${{ steps.get-nvm-version.outputs.node-version }}' --arch ${{ matrix.cross-target }}
67+
68+
- name: Upload artifacts
69+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
70+
with:
71+
name: sqlcipher-${{matrix.os}}
72+
path: prebuilds/*
73+
74+
prebuild_linux:
75+
runs-on: ubuntu-latest
76+
timeout-minutes: 30
77+
78+
steps:
79+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
80+
- name: Build in docker container
81+
run: ./docker-prebuildify.sh
82+
83+
- name: Upload artifacts
84+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
85+
with:
86+
name: sqlcipher-linux-latest
87+
path: prebuilds/*
88+
89+
publish:
90+
name: Publish
91+
92+
permissions:
93+
# Needed for ncipollo/release-action.
94+
contents: 'write'
95+
96+
runs-on: ubuntu-latest
97+
98+
needs: [prebuild, prebuild_linux]
99+
100+
timeout-minutes: 45
101+
102+
steps:
103+
- name: Checkout
104+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
105+
106+
- name: Setup pnpm
107+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
108+
with:
109+
version: 10.3.0
110+
- name: Setup node.js
111+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
112+
with:
113+
node-version-file: '.nvmrc'
114+
registry-url: 'https://registry.npmjs.org/'
115+
116+
- name: Download built libraries
117+
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.19.1
118+
with:
119+
pattern: sqlcipher-*
120+
path: prebuilds
121+
merge-multiple: true
122+
123+
- name: Install node_modules
124+
run: pnpm install --frozen-lockfile
125+
126+
- name: Build
127+
run: pnpm build
128+
129+
- name: Lint
130+
run: pnpm lint
131+
132+
- run: pnpm test
133+
env:
134+
PREBUILDS_ONLY: 1
135+
136+
- name: Publish
137+
run: pnpm publish --tag '${{ github.event.inputs.npm_tag }}' --access public --no-git-checks ${{ inputs.dry_run && '--dry-run' || ''}}
138+
env:
139+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
140+
141+
- name: Rename symbols
142+
run: |
143+
mv prebuilds/darwin-arm64/node_sqlcipher.sym prebuilds/node_sqlcipher_darwin_arm64.sym
144+
mv prebuilds/darwin-x64/node_sqlcipher.sym prebuilds/node_sqlcipher_darwin_x64.sym
145+
mv prebuilds/linux-arm64/node_sqlcipher.sym prebuilds/node_sqlcipher_linux_arm64.sym
146+
mv prebuilds/linux-x64/node_sqlcipher.sym prebuilds/node_sqlcipher_linux_x64.sym
147+
mv prebuilds/win32-arm64/node_sqlcipher.sym prebuilds/node_sqlcipher_win32_arm64.sym
148+
mv prebuilds/win32-x64/node_sqlcipher.sym prebuilds/node_sqlcipher_win32_x64.sym
149+
150+
# This step is expected to fail if not run on a tag.
151+
- name: Upload debug info to release
152+
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0
153+
if: ${{ !inputs.dry_run }}
154+
with:
155+
allowUpdates: true
156+
artifactErrorsFailBuild: true
157+
artifacts: prebuilds/node_sqlcipher_*.sym

.github/workflows/test.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Copyright 2025 Signal Messenger, LLC
2+
# SPDX-License-Identifier: AGPL-3.0-only
3+
4+
name: Test
5+
on:
6+
push:
7+
branches:
8+
- main
9+
pull_request:
10+
11+
jobs:
12+
test:
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, windows-latest, macos-latest]
16+
include:
17+
- os: macos-latest
18+
cc: clang
19+
cxx: clang++
20+
- os: ubuntu-latest
21+
cc: gcc
22+
cxx: g++
23+
24+
runs-on: ${{ matrix.os }}
25+
timeout-minutes: 30
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
30+
- name: Setup pnpm
31+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
32+
with:
33+
version: 10.3.0
34+
- name: Setup node.js
35+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
36+
with:
37+
node-version-file: '.nvmrc'
38+
cache: 'pnpm'
39+
cache-dependency-path: 'pnpm-lock.yaml'
40+
41+
- name: Setup sccache
42+
uses: mozilla-actions/sccache-action@65101d47ea8028ed0c98a1cdea8dd9182e9b5133 # v0.0.8
43+
- name: Restore sccache
44+
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
45+
with:
46+
path: ${{ env.SCCACHE_PATH }}
47+
key: sccache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml', 'patches/**', 'deps/extension/Cargo.lock') }}
48+
49+
- name: Restore cargo cache
50+
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
51+
with:
52+
path: ~/.cargo/registry
53+
key: cargo-${{ runner.os }}-${{ hashFiles('deps/extension/Cargo.lock') }}
54+
55+
- name: Install node_modules (unixes)
56+
if: ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' }}
57+
run: pnpm install
58+
env:
59+
CC: sccache ${{ matrix.cc }}
60+
CXX: sccache ${{ matrix.cxx }}
61+
RUSTC_WRAPPER: sccache
62+
SCCACHE_GHA_ENABLED: 'true'
63+
64+
- name: Install node_modules (windows)
65+
if: ${{ matrix.os == 'windows-latest' }}
66+
run: pnpm install
67+
env:
68+
RUSTC_WRAPPER: sccache
69+
70+
- name: Run lint
71+
if: matrix.os != 'windows-latest'
72+
run: pnpm lint
73+
74+
- name: Run tests
75+
run: pnpm test

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
build/
2+
dist/
3+
node_modules/
4+
coverage/
5+
prebuilds/
6+
docs/
7+
.tmp/
8+
.eslintcache
9+
todo.md

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.18.2

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
build/
2+
deps/sqlcipher/*
3+
dist/
4+
deps/extension/target
5+
pnpm-lock.yaml

.prettierrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all"
4+
}

Dockerfile

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Copyright 2022 Signal Messenger, LLC.
2+
# SPDX-License-Identifier: AGPL-3.0-only
3+
#
4+
5+
FROM ubuntu:focal-20240530@sha256:fa17826afb526a9fc7250e0fbcbfd18d03fe7a54849472f86879d8bf562c629e
6+
7+
# Avoid getting prompted to configure things during installation.
8+
ENV DEBIAN_FRONTEND=noninteractive
9+
10+
# APT source files
11+
COPY docker/ docker/
12+
COPY docker/apt.conf docker/sources.list /etc/apt/
13+
14+
# Ubuntu needs the ca-certificates package before it'll trust our mirror.
15+
# But we can't install it because it doesn't trust our mirror!
16+
# Temporarily disables APT's certificate signature checking
17+
# to download the certificates.
18+
RUN apt-get update -oAcquire::https::Verify-Peer=false \
19+
&& apt-get install -oAcquire::https::Verify-Peer=false -y ca-certificates
20+
# Back to normal, verification back on
21+
22+
# Install only what's needed to set up Rust and Node.
23+
# We'll install additional tools at the end to take advantage of Docker's caching of earlier steps.
24+
RUN apt-get update && apt-get install -y apt-transport-https xz-utils unzip
25+
26+
# User-specific setup!
27+
28+
ARG UID
29+
ARG GID
30+
31+
# Create a user to map the host user to.
32+
RUN groupadd -o -g "${GID}" sqlcipher \
33+
&& useradd -m -o -u "${UID}" -g "${GID}" -s /bin/bash sqlcipher
34+
35+
USER sqlcipher
36+
ENV HOME=/home/sqlcipher
37+
ENV USER=sqlcipher
38+
ENV SHELL=/bin/bash
39+
ENV CI=on
40+
41+
WORKDIR /home/sqlcipher
42+
43+
# Rust setup
44+
COPY rust-toolchain rust-toolchain
45+
ENV PATH="/home/sqlcipher/.cargo/bin:${PATH}"
46+
ARG RUSTUP_SHA=ad1f8b5199b3b9e231472ed7aa08d2e5d1d539198a15c5b1e53c746aad81d27b
47+
48+
ADD --chown=sqlcipher --chmod=755 --checksum=sha256:${RUSTUP_SHA} \
49+
https://static.rust-lang.org/rustup/archive/1.21.1/x86_64-unknown-linux-gnu/rustup-init /tmp/rustup-init
50+
51+
RUN /tmp/rustup-init -y --profile minimal --default-toolchain "$(cat rust-toolchain)" \
52+
&& rm -rf /tmp/rustup-init
53+
54+
RUN rustup target add aarch64-unknown-linux-gnu
55+
56+
# Node setup
57+
58+
ARG NODE_VERSION
59+
60+
ADD --chown=sqlcipher https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz node.tar.xz
61+
62+
RUN tar -xf node.tar.xz \
63+
&& mv node-v* node \
64+
&& rm -f node.tar.xz
65+
66+
ENV PATH="/home/sqlcipher/node/bin:${PATH}"
67+
68+
# And finally any bonus packages we're going to need
69+
# Note that we jump back to root for this.
70+
USER root
71+
RUN apt-get install -y g++ gcc crossbuild-essential-arm64 git python3 binutils
72+
USER sqlcipher
73+
74+
RUN cargo install dump_syms --no-default-features --features cli
75+
76+
CMD [ "/bin/bash" ]

0 commit comments

Comments
 (0)