Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ jobs:
yarn dirty_sed
cat libsession-util/external/oxen-libquic/external/oxen-logging/CMakeLists.txt

- name: generate fake src/version.h so we can try to build
shell: bash
run: yarn update_version


- name: build libsession-util-nodejs
shell: bash
run: yarn install --frozen-lockfile
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
.yarn/
*.cjs
*.mjs
src/version.ts

/src/version.h
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
src/version.ts
/src/version.h
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"main": "index.js",
"name": "libsession_util_nodejs",
"description": "Wrappers for the Session Util Library",
"version": "0.4.24",
"version": "0.4.25",
"license": "GPL-3.0",
"author": {
"name": "Oxen Project",
Expand Down
5 changes: 3 additions & 2 deletions prepare_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ echo "Continuing..."
yarn dirty_sed

echo "Building tar archive of source..."
python3 build_release_archive.py libsession_util_nodejs-v$PACKAGE_VERSION.tar.gz
python3 build_release_archive.py libsession_util_nodejs-v$PACKAGE_VERSION.tar.gz --include src/version.h

echo "tar archive size:"
du -sh libsession_util_nodejs*.tar.gz

echo "Creating draft release on github $PACKAGE_VERSION..."
GH_RELEASE_URL=$(gh release create v$PACKAGE_VERSION -t v$PACKAGE_VERSION --draft --latest --generate-notes)
GH_RELEASE_URL=$(gh release create v$PACKAGE_VERSION -t v$PACKAGE_VERSION --latest --generate-notes)
echo "Uploading tar archive to release $PACKAGE_VERSION..."
gh release upload v$PACKAGE_VERSION libsession_util_nodejs-v$PACKAGE_VERSION.tar.gz
echo "GH_RELEASE_URL: $GH_RELEASE_URL"
Expand Down
9 changes: 9 additions & 0 deletions src/constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "session/config/groups/info.hpp"
#include "session/config/user_groups.hpp"
#include "session/version.h"
#include "version.h"

namespace session::nodeapi {
ConstantsWrapper::ConstantsWrapper(const Napi::CallbackInfo& info) :
Expand Down Expand Up @@ -35,6 +36,14 @@ Napi::Object ConstantsWrapper::Init(Napi::Env env, Napi::Object exports) {
ObjectWrap::StaticValue(
"LIBSESSION_UTIL_VERSION",
Napi::String::New(env, LIBSESSION_UTIL_VERSION_FULL),
napi_enumerable),
ObjectWrap::StaticValue(
"LIBSESSION_NODEJS_VERSION",
Napi::String::New(env, LIBSESSION_NODEJS_VERSION),
napi_enumerable),
ObjectWrap::StaticValue(
"LIBSESSION_NODEJS_COMMIT",
Napi::String::New(env, LIBSESSION_NODEJS_COMMIT),
napi_enumerable)});

// export object as javascript module
Expand Down
12 changes: 12 additions & 0 deletions types/shared.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ declare module 'libsession_util_nodejs' {
* BASE_URL_MAX_LENGTH + '/r/' + ROOM_MAX_LENGTH + qs_pubkey.size() + hex pubkey + null terminator
*/
COMMUNITY_FULL_URL_MAX_LENGTH: number;
/**
* A string that looks like libsession-util v1.2.0-nogit
*/
LIBSESSION_UTIL_VERSION: string;
/**
* A string that looks like "0.4.24"
*/
LIBSESSION_NODEJS_VERSION: string;
/**
* A string corresponding to the full hash of the commit
*/
LIBSESSION_NODEJS_COMMIT: string;
};

export const CONSTANTS: ConstantsType;
Expand Down
16 changes: 9 additions & 7 deletions update_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
set -e
# set -x

VERSION_FILE="src/version.ts"
rm $VERSION_FILE
VERSION_FILE="src/version.h"

rm -f $VERSION_FILE

export LIBSESSION_NODEJS_VERSION=$(node -p "require('./package.json').version")
# sadly, this is most likely only working on unix
LIBSESSION_NODEJS_COMMIT_SHA=$(git rev-parse HEAD)
LIBSESSION_NODEJS_COMMIT=$(git rev-parse HEAD)

echo "Updating LIBSESSION_NODEJS_VERSION: $LIBSESSION_NODEJS_VERSION"
echo "Updating LIBSESSION_NODEJS_COMMIT_SHA: $LIBSESSION_NODEJS_COMMIT_SHA"
echo "Updating LIBSESSION_NODEJS_COMMIT: $LIBSESSION_NODEJS_COMMIT"


echo "export const LIBSESSION_NODEJS_VERSION = '$LIBSESSION_NODEJS_VERSION';" > $VERSION_FILE
echo "export const LIBSESSION_NODEJS_COMMIT_SHA = '$LIBSESSION_NODEJS_COMMIT_SHA';" >> $VERSION_FILE
echo "const char* LIBSESSION_NODEJS_VERSION = \"$LIBSESSION_NODEJS_VERSION\";" > $VERSION_FILE
echo "const char* LIBSESSION_NODEJS_COMMIT = \"$LIBSESSION_NODEJS_COMMIT\";" >> $VERSION_FILE

echo "\n'$VERSION_FILE' updated to:"
cat $VERSION_FILE
Expand Down