@@ -13,15 +13,19 @@ pub struct ReleaseArgs {
1313enum ReleaseCommand {
1414 /// Prepare the release of the matrix-sdk workspace.
1515 ///
16- /// This command will update the `README.md`, prepend the `CHANGELOG.md`
17- /// file using `git cliff`, and bump the versions in the `Cargo.toml`
18- /// files.
16+ /// This command will update the `README.md`, update the `CHANGELOG.md` file
17+ /// using, and bump the versions in the `Cargo.toml` files.
1918 Prepare {
2019 /// What type of version bump we should perform.
2120 version : ReleaseVersion ,
2221 /// Actually prepare a release. Dry-run mode is the default.
2322 #[ clap( long) ]
2423 execute : bool ,
24+ /// The crate or package that should be released. Use this if you'd like
25+ /// to release only one specific crate. The default is to
26+ /// release all crates.
27+ #[ clap( long) ]
28+ package : Option < String > ,
2529 } ,
2630 /// Publish the release.
2731 ///
@@ -31,6 +35,11 @@ enum ReleaseCommand {
3135 /// Actually publish a release. Dry-run mode is the default
3236 #[ clap( long) ]
3337 execute : bool ,
38+ /// The crate or package that should be released. Use this if you'd like
39+ /// to release only one specific crate. The default is to
40+ /// release all crates.
41+ #[ clap( long) ]
42+ package : Option < String > ,
3443 } ,
3544 /// Get a list of interesting changes that happened in the last week.
3645 WeeklyReport ,
@@ -63,8 +72,10 @@ impl ReleaseArgs {
6372 check_prerequisites ( ) ;
6473
6574 match self . cmd {
66- ReleaseCommand :: Prepare { version, execute } => prepare ( version, execute) ,
67- ReleaseCommand :: Publish { execute } => publish ( execute) ,
75+ ReleaseCommand :: Prepare { version, execute, package } => {
76+ prepare ( version, execute, package)
77+ }
78+ ReleaseCommand :: Publish { execute, package } => publish ( execute, package) ,
6879 ReleaseCommand :: WeeklyReport => weekly_report ( ) ,
6980 }
7081 }
@@ -88,9 +99,15 @@ fn check_prerequisites() {
8899 }
89100}
90101
91- fn prepare ( version : ReleaseVersion , execute : bool ) -> Result < ( ) > {
102+ fn prepare ( version : ReleaseVersion , execute : bool , package : Option < String > ) -> Result < ( ) > {
92103 let sh = sh ( ) ;
93- let cmd = cmd ! ( sh, "cargo release --workspace --no-publish --no-tag --no-push" ) ;
104+ let cmd = cmd ! ( sh, "cargo release --no-publish --no-tag --no-push" ) ;
105+
106+ let cmd = if let Some ( package) = package {
107+ cmd. args ( [ "--package" , & package] )
108+ } else {
109+ cmd. arg ( "--workspace" )
110+ } ;
94111
95112 let cmd = if execute { cmd. arg ( "--execute" ) } else { cmd } ;
96113 let cmd = cmd. arg ( version. as_str ( ) ) ;
@@ -108,19 +125,34 @@ fn prepare(version: ReleaseVersion, execute: bool) -> Result<()> {
108125 Ok ( ( ) )
109126}
110127
111- fn publish ( execute : bool ) -> Result < ( ) > {
128+ fn publish ( execute : bool , package : Option < String > ) -> Result < ( ) > {
112129 let sh = sh ( ) ;
113130
114- let cmd = cmd ! ( sh, "cargo release tag --workspace " ) ;
131+ let cmd = cmd ! ( sh, "cargo release tag" ) ;
115132 let cmd = if execute { cmd. arg ( "--execute" ) } else { cmd } ;
133+ let cmd = if let Some ( package) = package. as_deref ( ) {
134+ cmd. args ( [ "--package" , package] )
135+ } else {
136+ cmd. arg ( "--workspace" )
137+ } ;
116138 cmd. run ( ) ?;
117139
118- let cmd = cmd ! ( sh, "cargo release publish --workspace " ) ;
140+ let cmd = cmd ! ( sh, "cargo release publish" ) ;
119141 let cmd = if execute { cmd. arg ( "--execute" ) } else { cmd } ;
142+ let cmd = if let Some ( package) = package. as_deref ( ) {
143+ cmd. args ( [ "--package" , & package] )
144+ } else {
145+ cmd. arg ( "--workspace" )
146+ } ;
120147 cmd. run ( ) ?;
121148
122- let cmd = cmd ! ( sh, "cargo release push --workspace " ) ;
149+ let cmd = cmd ! ( sh, "cargo release push" ) ;
123150 let cmd = if execute { cmd. arg ( "--execute" ) } else { cmd } ;
151+ let cmd = if let Some ( package) = package. as_deref ( ) {
152+ cmd. args ( [ "--package" , & package] )
153+ } else {
154+ cmd. arg ( "--workspace" )
155+ } ;
124156 cmd. run ( ) ?;
125157
126158 Ok ( ( ) )
0 commit comments