forked from lalrpop/lalrpop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.sh
executable file
·67 lines (57 loc) · 1.66 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
#!/bin/bash
#
# A script to bump the version number on all Cargo.toml files etc in
# an atomic fashion.
VERSION=$(
ls lalrpop*/Cargo.toml | \
xargs grep "# LALRPOP" | \
perl -p -e 's/.*version = "([0-9.]+)" # LALRPOP/$1/' |
sort |
uniq)
if [ $(echo $VERSION | wc -w) != 1 ]; then
echo "Error: inconsistent versions detected across Cargo.toml files!"
echo "$VERSION"
exit 1
fi
echo "Found consistent version $VERSION"
BASE_DIR="$PWD"
TMPDIR=${TMPDIR:-"/tmp"}
function publish_fail {
printf "ERROR\n"
cat $TMPDIR/publish-log
exit 1
}
function publish {
printf "Publishing %s..." "$1"
cd $1
cargo publish >& $TMPDIR/publish-log || publish_fail $1
cd $BASE_DIR
printf "OK\n"
}
publish lalrpop-util
sleep 25 # Wait for lalrpop-util to be available on crates.io
publish lalrpop
git tag $VERSION
git push origin tag $VERSION
git push upstream tag $VERSION || true
printf "Updated version in docs etc..."
perl -p -i -e 's/^version = "[0-9.]+"$/version = "'$VERSION'"/' \
doc/*/Cargo.toml \
>& $TMPDIR/publish-log || publish_fail
perl -p -i -e 's/^lalrpop = "[0-9.]+"$/lalrpop = "'$VERSION'"/' \
doc/src/*.md \
doc/src/tutorial/*.md \
doc/*/Cargo.toml \
>& $TMPDIR/publish-log || publish_fail
perl -p -i -e 's/^lalrpop-util = "[0-9.]+"$/lalrpop-util = "'$VERSION'"/' \
doc/src/*.md \
doc/src/tutorial/*.md \
doc/*/Cargo.toml \
>& $TMPDIR/publish-log || publish_fail
git add -f \
doc/src/*.md \
doc/src/tutorial/*.md \
doc/*/Cargo.toml \
>& $TMPDIR/publish-log || publish_fail
printf "OK\n"
printf "\nAll set. **Do not forget to commit new changes.**\n"