-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·52 lines (40 loc) · 1.06 KB
/
release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
set -e
set -o pipefail
ARCH=$(uname -m)
PLATFORM=$(uname -s | tr '[:upper:]' '[:lower:]')
OPAM_FILE=$(basename -- $(find *.opam))
LIB="${OPAM_FILE%.*}"
SOURCE_BIN="_build/default/bin/bin.exe"
RELEASE_DIR="_release"
RELEASE_ZIP="$RELEASE_DIR/release.zip"
RELEASE_BIN_DIR="$RELEASE_DIR/bin"
RELEASE_BIN="$RELEASE_BIN_DIR/$LIB-$PLATFORM-$ARCH.exe"
if [ ! -f "$RELEASE_ZIP" ]; then
echo "$RELEASE_ZIP does not exist. Download it from Github and put in $RELEASE_DIR/ dir."
exit 1
fi
echo "=== Releasing $LIB"
echo "=== Unzipping release archive"
unzip -d $RELEASE_DIR $RELEASE_ZIP
rm $RELEASE_ZIP
tree -a -L 2 $RELEASE_DIR
echo ""
echo "=== Preparing $PLATFORM $ARCH binary"
CHMOD=$(stat -c %a "$RELEASE_BIN_DIR/$(ls $RELEASE_BIN_DIR | head -n 1)")
dune build
cp $SOURCE_BIN $RELEASE_BIN
chmod $CHMOD $RELEASE_BIN
tree -a -L 2 $RELEASE_DIR
echo ""
echo "=== Publishing to npm"
cd $RELEASE_DIR
rm .DS_Store >/dev/null 2>&1 || true
echo "package.json:"
cat package.json
echo ""
npm publish
cd ..
echo ""
echo "=== Cleaning up"
rm -rf $RELEASE_DIR/*
tree -a -L 2 $RELEASE_DIR