forked from SmartThingsCommunity/smartthings-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.sh
executable file
·76 lines (63 loc) · 2.54 KB
/
publish.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
#!/bin/bash
# Currently using lerna publish locally with interactive confirmation until we are confident
# enough to add to CI/CD.
#
# Requirements to run:
# 1. lerna installed
# 2. smartthingspi Github PAT environment variable set "export GH_TOKEN=pi-token-here"
# 3. npm login as smartthingspi
# 4. local master is up to date with upstream and no changes have been committed on top
#
# All configuration not shown in commands here is set in lerna.json under "command.publish" or release-it.yaml.
# Once we are out of pre-release, if we are still using release-it to update releases with binaries, we'll need
# to set "preRelease: false". If we are still using lerna, "command.publish.conventionalPrerelease" and
# "command.publish.preid" should be removed. Further one-time lerna commands will be needed to "graduate" packages out of pre.
#
# See https://github.com/lerna/lerna/blob/f6e7a13e60fefc523d701efddfcf0ed41a77749b/commands/version/README.md#prerelease
set -e
export GIT_AUTHOR_NAME=smartthingspi
export [email protected]
export GIT_COMMITTER_NAME=smartthingspi
export [email protected]
if [ -z $GH_TOKEN ]; then
echo "ERROR: lerna requires GH_TOKEN environment variable to be set to create Github release."
exit 1
fi
# verify npm auth and ping just in case to prevent commiting everything and then failing
npm whoami
npm ping
# full clean
rm -rf node_modules packages/*/node_modules
rm -f node_modules packages/*/tsconfig.tsbuildinfo
rm -rf packages/*/dist
rm -rf packages/*/dist_bin
# bootstrap
lerna bootstrap
lerna run clean
lerna run compile
lerna run test
# build binaries (duplicated as a test first before versioning/publishing)
lerna run package
# ignoring lifecycle scripts for now due to an error running oclif-dev inside the lerna version and publish commands.
# the "version" npm-scripts all work outside of those commands by running "lerna run version"
lerna publish --ignore-scripts
# repeat after lerna bumped and committed versioned files
lerna run compile
lerna run package
function zip_binary() {
os=$1
ext=$2
(
cd packages/cli/dist_bin
mv "cli-$os$ext" "smartthings$ext"
zip ../../../smartthings-$os.zip "smartthings$ext"
mv "smartthings$ext" "cli-$os$ext"
)
}
# zip package output binaries for uploading to github releases
zip_binary linux
zip_binary macos
zip_binary win .exe
# update github release with zipped binaries (bulk of config in .release-it.yaml)
# required due to lerna not supporting assets https://github.com/lerna/lerna/issues/2743
npx release-it -VV --no-increment --no-npm --ci