Skip to content

Commit 4bbd001

Browse files
committed
Rewrite clgen.sh to not construct entire changelog.
This allows hand-written changelog entries. Also makes the release process not need the tag-and-untag dance that's been needed. Closes #16
1 parent 577a774 commit 4bbd001

File tree

2 files changed

+48
-30
lines changed

2 files changed

+48
-30
lines changed

README.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@ This is an export of [`rustdoc-json-types`](https://github.com/rust-lang/rust/bl
88

99
1. Run `./update.sh` to pull code from upstream
1010
2. Run `cargo test`
11-
3. Update `version` field in `Cargo.toml`
12-
4. `git add` and `git commit` changed files
13-
5. `git tag vMAJOR.MINOR.PATCH`
14-
6. `git push --tags`
15-
7. `git push`
11+
3. Run `./clgen.sh <old_version> <new_version>`
12+
4. Edit the `TODO` section in `CHANGELOG.md` to include what was done in this release.
13+
5. `git add .`
14+
6. `git commit -m <new_version>`
1615
7. `cargo publish`
16+
8. `git tag <new_version>`
17+
9. `git push`
18+
10. `git push --tags`
19+
20+
1721

1822
## License
1923

clgen.sh

+39-25
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,42 @@ grepor() {
1414
grep $1 || true
1515
}
1616

17-
for version_tag in $(git tag --sort=-version:refname); do
18-
date=$(git show -s $version_tag --format=%ci | sd "[0-9]{2}:[0-9]{2}:[0-9]{2} \+[0-9]{4}" "")
19-
format_version=$(git show $version_tag:src/lib.rs | grepor FORMAT_VERSION | col6 | sd ";" "")
20-
21-
if [[ $version_tag == "v0.1.0" ]]; then
22-
prev_tag=""
23-
rustc_commit=7dc1e852d43cb8c9e77dc1e53014f0eb85d2ebfb
24-
else
25-
prev_tag=$(git tag --sort=-version:refname | grep -A 1 $version_tag | tail -n 1)
26-
rustc_commit=$(git show $version_tag:COMMIT.txt)
27-
fi
28-
29-
# Handle pre https://github.com/rust-lang/rust/pull/89906
30-
if [[ -z $format_version ]]; then
31-
format_version=$(curl -L# https://raw.githubusercontent.com/rust-lang/rust/$rustc_commit/src/librustdoc/json/mod.rs | grep format_version | col2 | sd "," "")
32-
fi
33-
34-
echo "<a name=\"$version_tag\"></a>"
35-
echo "# [$version_tag](https://github.com/aDotInTheVoid/rustdoc-types/releases/tag/$version_tag) - $date"
36-
echo "- Format Version: $format_version"
37-
echo "- Upstream Commit: [\`$rustc_commit\`](https://github.com/rust-lang/rust/commit/$rustc_commit)"
38-
echo "- Diff: [$version_tag...$prev_tag](https://github.com/aDotInTheVoid/rustdoc-types/compare/$prev_tag...$version_tag)"
39-
40-
echo ""
41-
done
17+
# Check we have two arguments, and assign them to variables
18+
19+
if [[ $# -ne 2 ]]; then
20+
echo "Usage: $0 <old_version> <new_version>"
21+
exit 1
22+
fi
23+
24+
old_version=$1
25+
new_version=$2
26+
27+
# Update the version in Cargo.toml
28+
cat Cargo.toml | sd "version = \"$old_version\"" "version = \"$new_version\"" > tmp
29+
# Error if the version is not updated
30+
if [[ $(cat tmp | grep $new_version | wc -l) -ne 1 ]]; then
31+
echo "Error: Version not updated in Cargo.toml"
32+
exit 1
33+
fi
34+
mv tmp Cargo.toml
35+
36+
date=$(date --utc --rfc-3339=date)
37+
format_version=$(cat src/lib.rs | grepor FORMAT_VERSION | col6 | sd ";" "")
38+
rustc_commit=$(cat COMMIT.txt)
39+
40+
# We do a shuffling dance to append the new version to the top of the changelog
41+
cat<<EOF > tmp
42+
<a name="$new_version"></a>"
43+
# [$new_version](https://github.com/aDotInTheVoid/rustdoc-types/releases/tag/$new_version) - $date"
44+
45+
TODO: Changelog.
46+
47+
- Format Version: $format_version"
48+
- Upstream Commit: [\`$rustc_commit\`](https://github.com/rust-lang/rust/commit/$rustc_commit)"
49+
- Diff: [$new_version...$new_version](https://github.com/aDotInTheVoid/rustdoc-types/compare/$old_version...$new_version)"
50+
EOF
51+
52+
cat tmp CHANGELOG.md > tmp2
53+
mv tmp2 CHANGELOG.md
54+
rm tmp
55+

0 commit comments

Comments
 (0)