forked from rust-lang/rustdoc-types
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clgen.sh
executable file
·68 lines (54 loc) · 1.56 KB
/
clgen.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
#!/bin/bash
set -eou pipefail
sd() {
sed -E "s/$1/$2/g"
}
col2() {
awk '{print $2}'
}
col6() {
awk '{print $6}'
}
grepor() {
grep $1 || true
}
# Check we have two arguments, and assign them to variables
if [[ $# -ne 2 ]]; then
echo "Usage: $0 <old_version> <new_version>"
exit 1
fi
old_version=$1
new_version=$2
# Update the version in Cargo.toml
cat Cargo.toml | sd "version = \"$old_version\"" "version = \"$new_version\"" > tmp
# Error if the version is not updated
if [[ $(cat tmp | grep $new_version | wc -l) -ne 1 ]]; then
echo "Error: Version not updated in Cargo.toml"
exit 1
fi
mv tmp Cargo.toml
date=$(date --utc --rfc-3339=date)
format_version=$(cat src/lib.rs | grepor FORMAT_VERSION | col6 | sd ";" "")
rustc_commit=$(cat COMMIT.txt)
# We do a shuffling dance to append the new version to the top of the changelog
new_tag="v$new_version"
old_tag="v$old_version"
cat<<EOF > tmp
<a name="$new_tag"></a>
# [$new_tag](https://github.com/aDotInTheVoid/rustdoc-types/releases/tag/$new_tag) - $date
TODO: Changelog.
- Format Version: $format_version
- Upstream Commit: [\`$rustc_commit\`](https://github.com/rust-lang/rust/commit/$rustc_commit)
- Diff: [$old_tag...$new_tag](https://github.com/aDotInTheVoid/rustdoc-types/compare/$old_tag...$new_tag)
EOF
cat tmp CHANGELOG.md > tmp2
mv tmp2 CHANGELOG.md
rm tmp
echo "First, edit the TODO in CHANGELOG.md"
echo "Then, check the diff"
echo "Finaly Run:"
echo "git add Cargo.toml CHANGELOG.md COMMIT.txt src/"
echo "git commit -m $new_tag"
echo "git tag $new_tag"
echo "git push && git push --tags"
echo "cargo publish"