1
1
//! This has been copied pretty much wholesale from https://github.com/nrf-rs/nrf-hal/blob/master/xtask/src/lib.rs
2
2
use super :: CRATES ;
3
+ use chrono:: Local ;
3
4
use std:: fs;
4
5
5
6
fn file_replace ( path : & str , from : & str , to : & str , dry_run : bool ) {
@@ -33,13 +34,17 @@ pub fn bump_versions(new_version: &str, dry_run: bool) {
33
34
let changelog = fs:: read_to_string ( changelog_path) . unwrap ( ) ;
34
35
// (ignore empty changelog when this is a dry_run, since that runs in normal CI)
35
36
assert ! (
36
- dry_run || !changelog. contains( "(no entries )" ) ,
37
- "changelog contains `(no entries )`; please fill it"
37
+ dry_run || !changelog. contains( "(no changes )" ) ,
38
+ "changelog contains `(no changes )`; please fill it"
38
39
) ;
39
40
40
41
// Prepend empty "[Unreleased]" section, promote the current one.
42
+ let today = Local :: today ( ) . format ( "%Y-%m-%d" ) . to_string ( ) ;
41
43
let from = String :: from ( "## [Unreleased]" ) ;
42
- let to = format ! ( "## [Unreleased]\n \n (no changes)\n \n ## [{}]" , new_version) ;
44
+ let to = format ! (
45
+ "## [Unreleased]\n \n (no changes)\n \n ## [{}] - {}" ,
46
+ new_version, today
47
+ ) ;
43
48
file_replace ( changelog_path, & from, & to, dry_run) ;
44
49
45
50
// Replace the Unreleased link
@@ -48,21 +53,12 @@ pub fn bump_versions(new_version: &str, dry_run: bool) {
48
53
old_version = old_version,
49
54
) ;
50
55
let to = format ! (
51
- r#"[Unreleased]: https://github.com/nrf-rs/microbit/compare/v{new_version}...HEAD"# ,
56
+ "[Unreleased]: https://github.com/nrf-rs/microbit/compare/v{new_version}...HEAD\n \
57
+ [{new_version}]: https://github.com/nrf-rs/microbit/releases/tag/v{old_version}...v{new_version}",
52
58
new_version = new_version,
59
+ old_version = old_version,
53
60
) ;
54
61
file_replace ( changelog_path, & from, & to, dry_run) ;
55
-
56
- // Append release link at the end.
57
- let mut changelog = fs:: read_to_string ( changelog_path) . unwrap ( ) ;
58
- changelog. push_str ( & format ! (
59
- "[{new_version}]: https://github.com/nrf-rs/microbit/releases/tag/v{new_version}...v{old_version}\n " ,
60
- new_version = new_version,
61
- old_version = old_version,
62
- ) ) ;
63
- if !dry_run {
64
- fs:: write ( changelog_path, changelog) . unwrap ( ) ;
65
- }
66
62
}
67
63
68
64
{
0 commit comments