Skip to content

Commit

Permalink
Rewrite clgen.sh to not construct entire changelog.
Browse files Browse the repository at this point in the history
This allows hand-written changelog entries.

Also makes the release process not need the tag-and-untag dance that's been needed.

Closes #16
  • Loading branch information
aDotInTheVoid committed Dec 23, 2023
1 parent 577a774 commit 4bbd001
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 30 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ This is an export of [`rustdoc-json-types`](https://github.com/rust-lang/rust/bl

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



## License

Expand Down
64 changes: 39 additions & 25 deletions clgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,42 @@ grepor() {
grep $1 || true
}

for version_tag in $(git tag --sort=-version:refname); do
date=$(git show -s $version_tag --format=%ci | sd "[0-9]{2}:[0-9]{2}:[0-9]{2} \+[0-9]{4}" "")
format_version=$(git show $version_tag:src/lib.rs | grepor FORMAT_VERSION | col6 | sd ";" "")

if [[ $version_tag == "v0.1.0" ]]; then
prev_tag=""
rustc_commit=7dc1e852d43cb8c9e77dc1e53014f0eb85d2ebfb
else
prev_tag=$(git tag --sort=-version:refname | grep -A 1 $version_tag | tail -n 1)
rustc_commit=$(git show $version_tag:COMMIT.txt)
fi

# Handle pre https://github.com/rust-lang/rust/pull/89906
if [[ -z $format_version ]]; then
format_version=$(curl -L# https://raw.githubusercontent.com/rust-lang/rust/$rustc_commit/src/librustdoc/json/mod.rs | grep format_version | col2 | sd "," "")
fi

echo "<a name=\"$version_tag\"></a>"
echo "# [$version_tag](https://github.com/aDotInTheVoid/rustdoc-types/releases/tag/$version_tag) - $date"
echo "- Format Version: $format_version"
echo "- Upstream Commit: [\`$rustc_commit\`](https://github.com/rust-lang/rust/commit/$rustc_commit)"
echo "- Diff: [$version_tag...$prev_tag](https://github.com/aDotInTheVoid/rustdoc-types/compare/$prev_tag...$version_tag)"

echo ""
done
# 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
cat<<EOF > tmp
<a name="$new_version"></a>"
# [$new_version](https://github.com/aDotInTheVoid/rustdoc-types/releases/tag/$new_version) - $date"
TODO: Changelog.
- Format Version: $format_version"
- Upstream Commit: [\`$rustc_commit\`](https://github.com/rust-lang/rust/commit/$rustc_commit)"
- Diff: [$new_version...$new_version](https://github.com/aDotInTheVoid/rustdoc-types/compare/$old_version...$new_version)"
EOF

cat tmp CHANGELOG.md > tmp2
mv tmp2 CHANGELOG.md
rm tmp

0 comments on commit 4bbd001

Please sign in to comment.