@@ -48,7 +48,7 @@ async fn upload_release_artifact(
48
48
dry_run : bool ,
49
49
) -> Result < ( ) > {
50
50
if release. assets . iter ( ) . any ( |asset| asset. name == filename) {
51
- println ! ( "release asset {} already present; skipping" , filename ) ;
51
+ println ! ( "release asset {filename } already present; skipping" ) ;
52
52
return Ok ( ( ) ) ;
53
53
}
54
54
@@ -61,15 +61,15 @@ async fn upload_release_artifact(
61
61
62
62
url. query_pairs_mut ( ) . clear ( ) . append_pair ( "name" , & filename) ;
63
63
64
- println ! ( "uploading to {}" , url) ;
65
-
66
- // Octocrab doesn't yet support release artifact upload. And the low-level HTTP API
67
- // forces the use of strings on us. So we have to make our own HTTP client.
64
+ println ! ( "uploading to {url}" ) ;
68
65
69
66
if dry_run {
70
67
return Ok ( ( ) ) ;
71
68
}
72
69
70
+ // Octocrab doesn't yet support release artifact upload. And the low-level HTTP API
71
+ // forces the use of strings on us. So we have to make our own HTTP client.
72
+
73
73
let response = reqwest:: Client :: builder ( )
74
74
. build ( ) ?
75
75
. put ( url)
@@ -138,26 +138,27 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches) -> Result<()
138
138
let mut runs: Vec < octocrab:: models:: workflows:: Run > = vec ! [ ] ;
139
139
140
140
for workflow_id in workflow_ids {
141
+ let commit = args
142
+ . get_one :: < String > ( "commit" )
143
+ . expect ( "commit should be defined" ) ;
144
+ let workflow_name = workflow_names
145
+ . get ( & workflow_id)
146
+ . expect ( "should have workflow name" ) ;
147
+
141
148
runs. push (
142
149
workflows
143
- . list_runs ( format ! ( "{}" , workflow_id ) )
150
+ . list_runs ( format ! ( "{workflow_id}" ) )
144
151
. event ( "push" )
145
152
. status ( "success" )
146
153
. send ( )
147
154
. await ?
148
155
. into_iter ( )
149
156
. find ( |run| {
150
- run. head_sha . as_str ( )
151
- == args
152
- . get_one :: < String > ( "commit" )
153
- . expect ( "commit should be defined" )
157
+ run. head_sha . as_str ( ) == commit
154
158
} )
155
159
. ok_or_else ( || {
156
160
anyhow ! (
157
- "could not find workflow run for commit for workflow {}" ,
158
- workflow_names
159
- . get( & workflow_id)
160
- . expect( "should have workflow name" )
161
+ "could not find workflow run for commit {commit} for workflow {workflow_name}" ,
161
162
)
162
163
} ) ?,
163
164
) ;
@@ -206,13 +207,15 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches) -> Result<()
206
207
207
208
// Iterate over `RELEASE_TRIPLES` in reverse-order to ensure that if any triple is a
208
209
// substring of another, the longest match is used.
209
- if let Some ( ( triple, release) ) = RELEASE_TRIPLES . iter ( ) . rev ( ) . find_map ( |( triple, release) | {
210
- if name. contains ( triple) {
211
- Some ( ( triple, release) )
212
- } else {
213
- None
214
- }
215
- } ) {
210
+ if let Some ( ( triple, release) ) =
211
+ RELEASE_TRIPLES . iter ( ) . rev ( ) . find_map ( |( triple, release) | {
212
+ if name. contains ( triple) {
213
+ Some ( ( triple, release) )
214
+ } else {
215
+ None
216
+ }
217
+ } )
218
+ {
216
219
let stripped_name = if let Some ( s) = name. strip_suffix ( ".tar.zst" ) {
217
220
s
218
221
} else {
@@ -366,8 +369,10 @@ pub async fn command_upload_release_distributions(args: &ArgMatches) -> Result<(
366
369
for f in & missing {
367
370
println ! ( "missing release artifact: {}" , f) ;
368
371
}
369
- if !missing. is_empty ( ) && !ignore_missing {
370
- return Err ( anyhow ! ( "missing release artifacts" ) ) ;
372
+ if missing. is_empty ( ) {
373
+ println ! ( "found all {} release artifacts" , wanted_filenames. len( ) ) ;
374
+ } else if !ignore_missing {
375
+ return Err ( anyhow ! ( "missing {} release artifacts" , missing. len( ) ) ) ;
371
376
}
372
377
373
378
let client = OctocrabBuilder :: new ( )
@@ -379,10 +384,14 @@ pub async fn command_upload_release_distributions(args: &ArgMatches) -> Result<(
379
384
let release = if let Ok ( release) = releases. get_by_tag ( tag) . await {
380
385
release
381
386
} else {
382
- return Err ( anyhow ! (
383
- "release {} does not exist; create it via GitHub web UI" ,
384
- tag
385
- ) ) ;
387
+ return if dry_run {
388
+ println ! ( "release {tag} does not exist; exiting dry-run mode..." ) ;
389
+ Ok ( ( ) )
390
+ } else {
391
+ Err ( anyhow ! (
392
+ "release {tag} does not exist; create it via GitHub web UI"
393
+ ) )
394
+ } ;
386
395
} ;
387
396
388
397
let mut digests = BTreeMap :: new ( ) ;
@@ -444,6 +453,11 @@ pub async fn command_upload_release_distributions(args: &ArgMatches) -> Result<(
444
453
445
454
// Check that content wasn't munged as part of uploading. This once happened
446
455
// and created a busted release. Never again.
456
+ if dry_run {
457
+ println ! ( "skipping SHA256SUMs check" ) ;
458
+ return Ok ( ( ) ) ;
459
+ }
460
+
447
461
let release = releases
448
462
. get_by_tag ( tag)
449
463
. await
0 commit comments