1
- use crate :: util:: { get_crates, path_to_crates, Crate } ;
2
- use anyhow:: { anyhow, Context , Result } ;
1
+ use crate :: util:: { exec , get_crates, path_to_crates, Crate } ;
2
+ use anyhow:: { anyhow, Result } ;
3
3
use std:: { process:: Command , thread:: sleep, time:: Duration } ;
4
4
use structopt:: StructOpt ;
5
5
6
6
#[ derive( Debug , StructOpt ) ]
7
7
#[ structopt( name = "bump" ) ]
8
8
pub struct PublishCommand {
9
9
/// Tag the current commit and push the tags to the default upstream; equivalent to `git tag
10
- /// v[version]` and ` git push v[version]`.
10
+ /// v[version] && git push origin v[version]`.
11
11
#[ structopt( long) ]
12
12
git : bool ,
13
13
/// Do not publish any crates; instead, simply print the actions that would have been taken.
@@ -43,13 +43,19 @@ impl PublishCommand {
43
43
for krate in PUBLICATION_ORDER {
44
44
println ! ( "> publish {}" , krate) ;
45
45
if !self . dry_run {
46
- assert ! ( Command :: new( "cargo" )
47
- . arg( "publish" )
48
- . current_dir( crates_dir. clone( ) . join( krate) )
49
- . arg( "--no-verify" )
50
- . status( )
51
- . with_context( || format!( "failed to run cargo publish on '{}' crate" , krate) ) ?
52
- . success( ) ) ;
46
+ let crate_dir = crates_dir. clone ( ) . join ( krate) ;
47
+ let exec_result = exec (
48
+ Command :: new ( "cargo" )
49
+ . arg ( "publish" )
50
+ . arg ( "--no-verify" )
51
+ . current_dir ( & crate_dir) ,
52
+ ) ;
53
+
54
+ // We want to continue even if a crate does not publish: this allows us to re-run
55
+ // the `publish` command if uploading one or more crates fails.
56
+ if let Err ( e) = exec_result {
57
+ println ! ( "Failed to publish crate {}, continuing:\n {}" , krate, e) ;
58
+ }
53
59
54
60
// Hopefully this gives crates.io enough time for subsequent publications to work.
55
61
sleep ( Duration :: from_secs ( 20 ) ) ;
@@ -61,18 +67,8 @@ impl PublishCommand {
61
67
if self . git {
62
68
println ! ( "> push Git tag: {}" , tag) ;
63
69
if !self . dry_run {
64
- assert ! ( Command :: new( "git" )
65
- . arg( "tag" )
66
- . arg( & tag)
67
- . status( )
68
- . with_context( || format!( "failed to run `git tag {}` command" , & tag) ) ?
69
- . success( ) ) ;
70
- assert ! ( Command :: new( "git" )
71
- . arg( "push" )
72
- . arg( & tag)
73
- . status( )
74
- . with_context( || format!( "failed to run `git push {}` command" , & tag) ) ?
75
- . success( ) ) ;
70
+ exec ( Command :: new ( "git" ) . arg ( "tag" ) . arg ( & tag) ) ?;
71
+ exec ( Command :: new ( "git" ) . arg ( "push" ) . arg ( "origin" ) . arg ( & tag) ) ?;
76
72
}
77
73
}
78
74
0 commit comments