forked from eclipse-n4js/n4js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
publish-n4js-libs-npm.sh
executable file
·79 lines (62 loc) · 1.94 KB
/
publish-n4js-libs-npm.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
#
# Copyright (c) 2018 NumberFour AG.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# NumberFour AG - Initial API and implementation
#
set -e
echo "Start publishing n4js-libs and n4js-cli"
cd `dirname $0`
CUR_DIR=`pwd`
yarn cache clean
function echo_exec {
echo "$@"
$@
}
# The first parameter is can be local, staging or public
if [ -z "$1" ]; then
echo "The destination (local, staging or public) must be specified as the first parameter"
exit 1
else
export DESTINATION=$1
fi
# The second parameter is the url to npm registry (http://localhost:4873), if not exists default to npmjs
if [ -z "$2" ]; then
echo "The url to npm registry must be specified"
exit
else
export NPM_REGISTRY=$2
fi
# Navigate to n4js-libs folder
cd n4js-libs
rm -rf node_modules
# If publishing to local or staging, use the dist-tag 'test' otherwise 'latest'
export NPM_TAG=test
if [ "$DESTINATION" = "public" ]; then
if [ -z $NPM_TOKEN ]; then
echo "Publishing to public requires the environment variable NPM_TOKEN to be set but it has not been set!"
exit 0;
fi
export NPM_TAG=latest
else
# Dummy token
export NPM_TOKEN=dummy
fi;
# Install dependencies and prepare npm task scripts
echo "=== Install dependencies and prepare npm task scripts"
yarn install
# Build n4js-cli lib
echo "=== Run lerna run build/test on n4js libs"
export PATH=`pwd`/node_modules/.bin:${PATH}
# Set N4_N4JSC_JAR to the the freshly built n4jsc.jar in tools/hlc/target
export N4_N4JSC_JAR="${CUR_DIR}/tools/org.eclipse.n4js.hlc/target/n4jsc.jar"
lerna run build
lerna run test
# Run npm task script 'publish-canary' to publish n4js-libs and n4js-cli to NPM_REGISTRY
yarn run publish-canary $DESTINATION $NPM_REGISTRY
echo "End publishing n4js-libs and n4js-cli"