-
Notifications
You must be signed in to change notification settings - Fork 30
/
run-release.sh
executable file
·71 lines (58 loc) · 1.4 KB
/
run-release.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
#!/bin/bash
set -e
set -x
tag=$1
user=jkcfg
repo=jk
pkg=github.com/$user/$repo
function docker_run() {
docker run -e GITHUB_TOKEN -e NPM_TOKEN -v "$(pwd)":/go/src/$pkg jkcfg/build "$@"
}
function run() {
cmd=$1
if [[ $cmd != ./* ]] && command -v $cmd; then
"$@"
else
docker_run $@
fi
}
echo "==> Creating $tag release"
run github-release release \
--user $user \
--repo $repo \
--tag $tag \
|| true
function upload() {
file=$1
run github-release upload \
--user $user \
--repo $repo \
--tag $tag \
--name $file \
--file $file
}
os=`go env GOOS`
binary=jk-$os-`go env GOARCH`
mv jk $binary
echo "==> Uploading $binary"
upload $binary
echo "==> Uploading $binary.sha256"
shasum -a 256 $binary > $binary.sha256
upload $binary.sha256
# We can only upload the npm module once. Do it from the Linux CI.
if [ $os != "linux" ]; then
exit 0
fi
echo "==> Checking package.json is up to date"
version=$(run ./$binary run std/version.jk)
if [ "$version" != "$tag" ]; then
echo "error: releasing $tag but std/package.json references $version"
exit 1
fi
echo "==> Uploading npm module"
if [ -z "$NPM_TOKEN" ]; then
echo "error: NPM_TOKEN needs to be defined for pushing npm modules"
exit 1
fi
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > @jkcfg/std/.npmrc
docker_run bash -c "'cd @jkcfg/std && npm publish'"