diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3f9707c..ed4f50e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/.gitignore b/.gitignore index a93efd4..7ace362 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ .yarn/ *.cjs *.mjs -src/version.ts + +/src/version.h diff --git a/.prettierignore b/.prettierignore index 2ec05e1..8c079e4 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1 @@ -src/version.ts \ No newline at end of file +/src/version.h diff --git a/package.json b/package.json index 5f0d3c9..cb87a07 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/prepare_release.sh b/prepare_release.sh index c65bf52..bd7b578 100755 --- a/prepare_release.sh +++ b/prepare_release.sh @@ -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" diff --git a/src/constants.cpp b/src/constants.cpp index 619df71..2514a1d 100644 --- a/src/constants.cpp +++ b/src/constants.cpp @@ -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) : @@ -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 diff --git a/types/shared.d.ts b/types/shared.d.ts index 69fbd47..185acf3 100644 --- a/types/shared.d.ts +++ b/types/shared.d.ts @@ -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; diff --git a/update_version.sh b/update_version.sh index 1e367a3..055d29f 100755 --- a/update_version.sh +++ b/update_version.sh @@ -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