Skip to content

Commit 4ee3567

Browse files
author
Nikhil Thorat
authored
Split the publish script into multiple scripts so they don't step on each other. (tensorflow#250)
Currently if you run ./scripts/publish-npm.sh the first publish needs an OTP and for the scripts after don't wait so they step on each other and put the repo in a bad state and I have to manually call npm publish. This makes you now have to run the scripts separately: ``` ./scripts/publish-npm.sh ./scripts/publish-npm-gpu.sh ``` Hopefully in the future we can merge the packages (letting the user specify when installing which binary they want). I have *not* tested this script (I will do it during the next release and modify it and re-check it in).
1 parent 02fb545 commit 4ee3567

File tree

5 files changed

+104
-24
lines changed

5 files changed

+104
-24
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"scripts": {
1515
"build": "tsc",
1616
"build-npm": "./scripts/build-npm.sh",
17+
"build-npm-gpu": "./scripts/build-npm-gpu.sh",
1718
"clean-deps": "rm -rf deps",
1819
"coverage": "nyc ts-node src/run_tests.ts",
1920
"enable-gpu": "node scripts/install.js gpu download && yarn",

scripts/build-npm-gpu.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2018 Google Inc. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# =============================================================================
16+
17+
set -e
18+
19+
# The binding builds with a symlink by default, for NPM packages change the
20+
# download option to move libtensorflow next to the prebuilt binary.
21+
sed -i -e 's/symlink/move/' binding.gyp
22+
23+
# Build GPU:
24+
sed -i -e 's/tfjs-node"/tfjs-node-gpu"/' package.json
25+
sed -i -e 's/install.js"/install.js gpu download"/' package.json
26+
rimraf deps/
27+
rimraf dist/
28+
yarn
29+
yarn prep
30+
tsc --sourceMap false
31+
# This produces a tarball that will later be used by `npm publish`.
32+
npm pack
33+
34+
# Revert GPU changes:
35+
git checkout .

scripts/build-npm.sh

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,5 @@ rimraf dist/
2525
yarn
2626
yarn prep
2727
tsc --sourceMap false
28+
# This produces a tarball that will later be used by `npm publish`.
2829
npm pack
29-
30-
# Build GPU:
31-
sed -i -e 's/tfjs-node"/tfjs-node-gpu"/' package.json
32-
sed -i -e 's/install.js"/install.js gpu download"/' package.json
33-
rimraf deps/
34-
rimraf dist/
35-
yarn
36-
yarn prep
37-
tsc --sourceMap false
38-
npm pack
39-
40-
# Revert GPU changes:
41-
git checkout .

scripts/publish-npm-gpu.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2017 Google Inc. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# =============================================================================
16+
17+
# Before you run this script, do this:
18+
# 1) Update the version in package.json
19+
# 2) Run ./scripts/make-version from the base dir of the project.
20+
# 3) Run `yarn` to update `yarn.lock`, in case you updated dependencies
21+
# 4) Commit to the master branch.
22+
23+
# Then:
24+
# 5) Checkout the master branch of this repo.
25+
# 6) Run this script as `./scripts/publish-npm-gpu.sh` from the project base dir.
26+
27+
set -e
28+
29+
BRANCH=`git rev-parse --abbrev-ref HEAD`
30+
ORIGIN=`git config --get remote.origin.url`
31+
32+
if [ "$BRANCH" != "master" ] && [ "$BRANCH" != "0.3.x" ]; then
33+
echo "Error: Switch to the master or a release branch before publishing."
34+
exit
35+
fi
36+
37+
if ! [[ "$ORIGIN" =~ tensorflow/tfjs-node ]]; then
38+
echo "Error: Switch to the main repo (tensorflow/tfjs-node) before publishing."
39+
exit
40+
fi
41+
42+
./scripts/make-version # This is for safety in case you forgot to do 2).
43+
44+
GPU_TARBALLS=$(ls tensorflow-tfjs-node-gpu*.tgz)
45+
GPU_TARBALL_COUNT=$(echo $GPU_TARBALLS | wc -w | xargs)
46+
if [ "$GPU_TARBALL_COUNT" != "1" ]; then
47+
echo "Error: Please make sure there is exactly one GPU tarball, found:"
48+
echo $GPU_TARBALLS
49+
exit
50+
fi
51+
52+
yarn build-npm-gpu
53+
# Publish the GPU package
54+
echo $GPU_TARBALLS | xargs npm publish
55+
./scripts/tag-version
56+
echo 'Yay! Published the tfjs-node-gpu package to npm.'

scripts/publish-npm.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
# limitations under the License.
1515
# =============================================================================
1616

17+
################################################################################
18+
# NOTE: This does *not* publish the GPU package. Please run
19+
# ./scripts/publish-npm-gpu.sh separately to publish the GPU package.
20+
################################################################################
21+
1722
# Before you run this script, do this:
1823
# 1) Update the version in package.json
1924
# 2) Run ./scripts/make-version from the base dir of the project.
@@ -42,17 +47,12 @@ fi
4247
yarn build-npm
4348
./scripts/make-version # This is for safety in case you forgot to do 2).
4449

45-
GPU_TARBALLS=$(ls tensorflow-tfjs-node-gpu*.tgz)
46-
GPU_TARBALL_COUNT=$(echo $GPU_TARBALLS | wc -w | xargs)
47-
if [ "$GPU_TARBALL_COUNT" != "1" ]; then
48-
echo "Error: Please make sure there is exactly one GPU tarball, found:"
49-
echo $GPU_TARBALLS
50-
exit
51-
fi
52-
5350
# Publish the CPU package
5451
npm publish
55-
# Publish the GPU package
56-
echo $GPU_TARBALLS | xargs npm publish
5752
./scripts/tag-version
58-
echo 'Yay! Published a new package to npm.'
53+
echo 'Yay! Published the tfjs-node package to npm.'
54+
55+
echo '#########################################################################'
56+
echo '# NOTE: This does *not* publish the GPU package. Please run'
57+
echo '# ./scripts/publish-npm-gpu.sh separately to publish the GPU package.'
58+
echo '#########################################################################'

0 commit comments

Comments
 (0)