-
Notifications
You must be signed in to change notification settings - Fork 1
/
publish
executable file
·35 lines (26 loc) · 942 Bytes
/
publish
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
#!/bin/sh
# Login to NPM
npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN;
version=$(grep -m1 version package.json | awk -F: '{ print $2 }' | sed 's/[", ]//g')
# npm publish is an idempotent action
tempLog=$(mktemp)
echo "Trying to publish..."
npm publish > ${tempLog} 2>&1
if [ $? -eq 0 ]; then
curl -H "Content-Type: application/json" \
-X POST \
-d "{\"text\":\"A new version *$version* of *Radium-Flex* package has been just published. <https://www.npmjs.com/package/radium-flex>\",\"username\":\"circle-ci\",\"icon_emoji\":\":tada:\"}" \
https://hooks.slack.com/services/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
echo "Successfully published!"
else
grep -q "You cannot publish over the previously published version" npm-debug.log
grepStatus=$?
if [ $grepStatus -eq 0 ]; then
echo "Already published."
else
cat ${tempLog}
fi
rm -f ${tempLog}
exit 0
fi
rm -f ${tempLog}