forked from bazel-contrib/rules_nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmirror_buildtools.sh
executable file
·50 lines (41 loc) · 1.42 KB
/
mirror_buildtools.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
#!/usr/bin/env bash
set -x -eu -o pipefail
readonly DRY_RUN="" # uncomment for testing: "--dry-run"
readonly RULES_NODEJS_DIR=$(cd $(dirname "$0")/..; pwd)
cd "${RULES_NODEJS_DIR}/packages"
# Don't accidentally publish extra files, such as previous binaries
git clean -fx
# VERSION is e.g. 0.18.0
readonly VERSION=$1
if [[ -z "$VERSION" ]]; then
echo "Usage: mirror_buildtools.sh [version]"
exit 1
fi
readonly BASEURI="https://github.com/bazelbuild/buildtools/releases/download/${VERSION}"
readonly NPM=$(which npm)
function doMirror () {
local PACKAGE=$1
local TOOL=$2
local EXT=${3-""}
local FILENAME=$TOOL
if [ ! -z "$EXT" ]; then
FILENAME="${FILENAME}.${EXT}"
fi
wget -P ${PACKAGE}/ ${BASEURI}/${FILENAME}
tmp=$(mktemp)
jq ".bin.${TOOL} = \"./${FILENAME}\" | .version = \"${VERSION}\"" < ${PACKAGE}/package.json > $tmp
mv $tmp ${PACKAGE}/package.json
node --max-old-space-size=8192 $NPM publish --access=public $DRY_RUN $PACKAGE
}
doMirror buildozer-linux_x64 buildozer
doMirror buildozer-darwin_x64 buildozer mac
doMirror buildozer-win32_x64 buildozer exe
doMirror buildifier-linux_x64 buildifier
doMirror buildifier-darwin_x64 buildifier mac
doMirror buildifier-win32_x64 buildifier exe
tmp=$(mktemp)
for p in buildozer buildifier; do
jq ".version = \"${VERSION}\" | .optionalDependencies[] = \"${VERSION}\"" < $p/package.json > $tmp
mv $tmp $p/package.json
$NPM publish --access=public $DRY_RUN $p
done