forked from distil/diffus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.sh
executable file
·70 lines (58 loc) · 1.75 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
#!/usr/bin/env bash
# ./publish.sh 0.13.37
set -o errexit -o nounset -o pipefail -o xtrace
VERSION="$1"
command -v jq > /dev/null
cargo_publish () {
(
cd $1
cargo package
echo "Files added:"
cargo package --list
read -r -p "Looks good to publish to crates.io? " response
case "$response" in
[yY][eE][sS]|[yY])
cargo publish
;;
*)
echo "Aborted"
exit 5
;;
esac
)
}
(
cd "$( dirname "${BASH_SOURCE[0]}" )"
git fetch
test -z "$(git status --porcelain)" || (echo "Dirty repo"; exit 2)
test -z "$(git diff origin/master)" || (echo "Not up to date with origin/master"; exit 3)
./test.sh
git fetch --tags
git tag -l | sed '/^'"${VERSION}"'$/{q2}' > /dev/null \
|| (echo "${VERSION} already exists"; exit 4)
find . \
-iname Cargo.toml \
-not -path "./target/*" \
-exec sed -i 's/^version = .*$/version = "'"${VERSION}"'"/g' '{}' \; \
-exec sed -i 's/^\(diffus-derive = { version = "\)\(=[0-9]*\.[0-9]*\.[0-9]*\)\(".*\)$/\1='"${VERSION}"'\3/g' '{}' \; \
-exec git add '{}' \;
git diff origin/master
read -r -p "Deploying ${VERSION}, are you sure? [y/N]? " response
case "$response" in
[yY][eE][sS]|[yY])
git commit -m"Version ${VERSION}"
git tag "${VERSION}"
git push origin "${VERSION}"
git push origin master
cargo_publish diffus-derive
until cargo_publish diffus; do
printf '.'
sleep 1
done
;;
*)
git checkout .
echo "Aborted"
;;
esac
)