-
Notifications
You must be signed in to change notification settings - Fork 82
/
release.sh
executable file
·101 lines (85 loc) · 1.92 KB
/
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#! /bin/bash
set -e
version="${1}"
if [ -z "${version}" ] || [[ "${version}" == v* ]]; then
echo 'USAGE: ./release.sh <version> (without `v` prefix)'
exit 1
fi
check_binaries() {
for bin in git towncrier twine python npm cargo mdbook; do
if ! which ${bin} >/dev/null; then
echo "Install ${bin} first."
exit 1
fi
done
}
check_tag() {
if git rev-parse "v${version}" 2>/dev/null >/dev/null; then
echo "Version ${version} is already tagged."
exit 1
fi
}
update_changelog() {
local cl_version=$(head -n 1 CHANGELOG.rst | cut -d' ' -f 2)
if [ "${cl_version}" == "${version}" ]; then
return
fi
towncrier --version=$version --draft
read -p "Look OK? (ctrl-c if not, enter if OK)"
towncrier --version=$version --yes
}
update_version_rs() {
sed -i -e "s/^version = \"[0-9.]*\"/version = \"$version\"/" rs/Cargo.toml
( cd rs; cargo build )
git add rs/Cargo.{toml,lock}
}
update_version_js() {
sed -i -e "s/\"version\": \"[0-9.]*\"/\"version\": \"$version\"/" js/package.json
git add js/package.json
}
update_version_py() {
sed -i -e "s/^version = \"[0-9.]*\"/version = \"$version\"/" py/setup.py
git add py/setup.py
}
commit_and_tag() {
git commit -m "v$version"
git tag "v$version"
}
upload_rs() {
cd rs
cp ../specification.yml .
cargo publish --allow-dirty
rm specification.yml
cd ..
}
upload_js() {
cd js
npm publish
cd ..
}
upload_py() {
cd py
rm -rf dist/*
python setup.py sdist bdist_wheel
twine upload dist/*
cd ..
}
push_git() {
git push upstream main:main
git push upstream --follow-tags "v$version"
}
# Check stuff
check_tag
check_binaries
# Update the repo contents and commit
update_changelog
update_version_rs
update_version_js
update_version_py
commit_and_tag
# Upload various packages
upload_rs
upload_js
upload_py
push_git
./deploy-docs.sh