@@ -14,28 +14,42 @@ grepor() {
14
14
grep $1 || true
15
15
}
16
16
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