Skip to content

Commit 899f767

Browse files
authored
Merge pull request #18 from Bilb/feat/export-versions
chore: add script to generate and upload release
2 parents 5e25813 + 08f2844 commit 899f767

File tree

8 files changed

+74
-13
lines changed

8 files changed

+74
-13
lines changed

Diff for: .github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
if: runner.os == 'Windows'
5353
shell: bash
5454
run: |
55-
sed -i "s/target_compile_options(oxen-logging-warnings INTERFACE/#target_compile_options(oxen-logging-warnings INTERFACE/" libsession-util/external/oxen-libquic/external/oxen-logging/CMakeLists.txt
55+
yarn dirty_sed
5656
cat libsession-util/external/oxen-libquic/external/oxen-logging/CMakeLists.txt
5757
5858
- name: build libsession-util-nodejs

Diff for: .gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
.yarn/
1313
*.cjs
1414
*.mjs
15-
15+
src/version.ts

Diff for: .prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/version.ts

Diff for: README.md

+1-9
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,7 @@ git commit
5454
git push upstream main
5555
# Make sure you do the steps above, otherwise the tag won't be on the right commit with the `gh release create`
5656
57-
virtualenv venv
58-
source venv/bin/activate
59-
pip install git-archive-all
60-
PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[", ]//g')
61-
echo $PACKAGE_VERSION
62-
# NOTE: before you build the archive, below check test.yml for the sed command to apply locally. Will be fixed soon :tm:
63-
python3 build_release_archive.py libsession_util_nodejs-v$PACKAGE_VERSION.tar.gz
64-
gh release create v$PACKAGE_VERSION -t v$PACKAGE_VERSION --latest --generate-notes
65-
gh release upload v$PACKAGE_VERSION libsession_util_nodejs-v$PACKAGE_VERSION.tar.gz
57+
yarn prepare_release
6658
```
6759

6860
And then upload the generated `libsession_util_nodejs-v$PACKAGE_VERSION.tar.gz` to that release just created on github.

Diff for: package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
"main": "index.js",
33
"name": "libsession_util_nodejs",
44
"description": "Wrappers for the Session Util Library",
5-
"version": "0.4.23",
5+
"version": "0.4.24",
66
"license": "GPL-3.0",
77
"author": {
88
"name": "Oxen Project",
99
"email": "[email protected]"
1010
},
1111
"scripts": {
12+
"update_version": "sh update_version.sh",
1213
"clean": "rimraf .cache build",
13-
"install": "cmake-js compile --runtime=electron --runtime-version=25.8.4 --CDSUBMODULE_CHECK=OFF --CDLOCAL_MIRROR=https://oxen.rocks/deps --CDENABLE_ONIONREQ=OFF --CDWITH_TESTS=OFF"
14+
"install": "cmake-js compile --runtime=electron --runtime-version=25.8.4 --CDSUBMODULE_CHECK=OFF --CDLOCAL_MIRROR=https://oxen.rocks/deps --CDENABLE_ONIONREQ=OFF --CDWITH_TESTS=OFF",
15+
"prepare_release": "sh prepare_release.sh",
16+
"dirty_sed": "sed -i \"s/target_compile_options(oxen-logging-warnings INTERFACE/#target_compile_options(oxen-logging-warnings INTERFACE/\" libsession-util/external/oxen-libquic/external/oxen-logging/CMakeLists.txt"
1417
},
1518
"devDependencies": {
1619
"clang-format": "^1.8.0",

Diff for: prepare_release.sh

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/sh
2+
set -e
3+
# set -x
4+
5+
read_char() {
6+
stty -icanon -echo
7+
eval "$1=\$(dd bs=1 count=1 2>/dev/null)"
8+
stty icanon echo
9+
}
10+
11+
12+
rm -f ./libsession_util_nodejs*.tar.gz
13+
virtualenv venv
14+
. venv/bin/activate
15+
pip install git-archive-all
16+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
17+
yarn update_version
18+
echo "PACKAGE_VERSION: $PACKAGE_VERSION"
19+
echo "Is '$PACKAGE_VERSION' the correct version? If yes, press 'y' to create the release. Press anything else to exit."
20+
read_char char_read
21+
case "$char_read" in
22+
y) break ;;
23+
*) echo "Exiting..."; exit 1 ;;
24+
esac
25+
26+
27+
echo "Continuing..."
28+
# see test.yml for explanation of this sed command
29+
yarn dirty_sed
30+
31+
echo "Building tar archive of source..."
32+
python3 build_release_archive.py libsession_util_nodejs-v$PACKAGE_VERSION.tar.gz
33+
echo "tar archive size:"
34+
du -sh libsession_util_nodejs*.tar.gz
35+
36+
echo "Creating draft release on github $PACKAGE_VERSION..."
37+
GH_RELEASE_URL=$(gh release create v$PACKAGE_VERSION -t v$PACKAGE_VERSION --draft --latest --generate-notes)
38+
echo "Uploading tar archive to release $PACKAGE_VERSION..."
39+
gh release upload v$PACKAGE_VERSION libsession_util_nodejs-v$PACKAGE_VERSION.tar.gz
40+
echo "GH_RELEASE_URL: $GH_RELEASE_URL"
41+
echo "Done"

Diff for: src/constants.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "session/config/contacts.hpp"
44
#include "session/config/groups/info.hpp"
55
#include "session/config/user_groups.hpp"
6+
#include "session/version.h"
67

78
namespace session::nodeapi {
89
ConstantsWrapper::ConstantsWrapper(const Napi::CallbackInfo& info) :
@@ -30,6 +31,10 @@ Napi::Object ConstantsWrapper::Init(Napi::Env env, Napi::Object exports) {
3031
ObjectWrap::StaticValue(
3132
"COMMUNITY_FULL_URL_MAX_LENGTH",
3233
Napi::Number::New(env, session::config::community::FULL_URL_MAX_LENGTH),
34+
napi_enumerable),
35+
ObjectWrap::StaticValue(
36+
"LIBSESSION_UTIL_VERSION",
37+
Napi::String::New(env, LIBSESSION_UTIL_VERSION_FULL),
3338
napi_enumerable)});
3439

3540
// export object as javascript module

Diff for: update_version.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
set -e
3+
# set -x
4+
5+
VERSION_FILE="src/version.ts"
6+
rm $VERSION_FILE
7+
export LIBSESSION_NODEJS_VERSION=$(node -p "require('./package.json').version")
8+
# sadly, this is most likely only working on unix
9+
LIBSESSION_NODEJS_COMMIT_SHA=$(git rev-parse HEAD)
10+
11+
echo "Updating LIBSESSION_NODEJS_VERSION: $LIBSESSION_NODEJS_VERSION"
12+
echo "Updating LIBSESSION_NODEJS_COMMIT_SHA: $LIBSESSION_NODEJS_COMMIT_SHA"
13+
14+
echo "export const LIBSESSION_NODEJS_VERSION = '$LIBSESSION_NODEJS_VERSION';" > $VERSION_FILE
15+
echo "export const LIBSESSION_NODEJS_COMMIT_SHA = '$LIBSESSION_NODEJS_COMMIT_SHA';" >> $VERSION_FILE
16+
17+
echo "\n'$VERSION_FILE' updated to:"
18+
cat $VERSION_FILE
19+

0 commit comments

Comments
 (0)