Skip to content

Commit b485abe

Browse files
committed
tes publication with prebuilt extension
1 parent 15b5ade commit b485abe

4 files changed

Lines changed: 26 additions & 22 deletions

File tree

.github/workflows/build.yml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Build & Publish
22

3-
on: workflow_dispatch
3+
on:
4+
push:
5+
tags: ['v*'] # publish when you push a tag like v1.2.3
6+
workflow_dispatch: {}
47

58
jobs:
69
build:
@@ -88,18 +91,6 @@ jobs:
8891
echo "Listing all files recursively from workspace root:"
8992
find . -type f -print | sort
9093
91-
# Move downloaded folders under sqlite-ext/keep_last/
92-
# - name: Layout compiled libraries
93-
# run: ls -la
94-
#
95-
# # Ensure the tag matches package.json version to prevent accidental publishes
96-
# - name: Verify version matches tag
97-
# run: |
98-
# PKG_VERSION=$(node -p "require('./package.json').version")
99-
# TAG=${GITHUB_REF_NAME#v}
100-
# echo "package.json: $PKG_VERSION, tag: $TAG"
101-
# [ "$PKG_VERSION" = "$TAG" ] || { echo "Version mismatch"; exit 1; }
102-
#
10394
- name: Setup Node (for publish)
10495
uses: actions/setup-node@v4
10596
with:
@@ -109,8 +100,8 @@ jobs:
109100
- name: Preview npm tarball
110101
run: npm pack --dry-run
111102

112-
# - name: Publish to npm
113-
# if: startsWith(github.ref, 'refs/tags/v')
114-
# env:
115-
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
116-
# run: npm publish --access public
103+
- name: Publish to npm
104+
if: startsWith(github.ref, 'refs/tags/v')
105+
env:
106+
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
107+
run: npm publish --access public

lib/index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const SQLiteOnSteroid = (db, myPeerId = null, options) => {
3939
if (!db) {
4040
throw new Error('Database instance is required');
4141
}
42-
db.loadExtension(path.resolve(__dirname, '../build/Release/keep_last'));
42+
db.loadExtension(findPreBuiltExtensionPath());
4343
hlc._reset();
4444

4545
const eventEmitter = new EventEmitter();
@@ -932,5 +932,15 @@ const SQLiteOnSteroid = (db, myPeerId = null, options) => {
932932
};
933933
};
934934

935+
function findPreBuiltExtensionPath () {
936+
if (process.platform === 'win32') {
937+
throw new Error('Windows is not supported for database replication');
938+
}
939+
if (fs.existsSync(path.join(__dirname, '../build/Release'))) {
940+
return path.join(__dirname, '../build/Release/keep_last'); // load extension built by npm install
941+
}
942+
return path.join(__dirname, `../build/keep_last-${process.platform}-${process.arch}`); // load extension packed in published module
943+
}
944+
935945

936946
module.exports = SQLiteOnSteroid;

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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
{
22
"name": "replic-sqlite",
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"description": "Simple, Fast, Multi-writer, Convergent, Replicated SQLite with 800 LOC only",
55
"main": "lib/index.js",
66
"directories": {
77
"lib": "lib",
88
"test": "test"
99
},
10+
"files": [
11+
"build/keep_last-*"
12+
],
1013
"scripts": {
1114
"test": "./node_modules/.bin/mocha test --timeout 10000 --exit",
1215
"test:watch": "./node_modules/.bin/mocha -u bdd -t 10000 -w -b --reporter-option maxDiffSize=64632",

0 commit comments

Comments
 (0)