@@ -144,14 +144,25 @@ export async function fetchReleaseAssetMetadataFromTag(
144144 // When the binary name is provided, look for matching binary and target triple.
145145 if ( isSome ( binaryName ) ) {
146146 const targetLabel = `${ binaryName . value } -${ targetTriple } ` ;
147- const asset = releaseMetadata . data . assets . find (
147+
148+ // First try to find asset by label (original behavior)
149+ let asset = releaseMetadata . data . assets . find (
148150 ( asset ) => asset . label === targetLabel ,
149151 ) ;
152+
153+ // If not found by label, try to find asset by exact name match
154+ if ( asset === undefined ) {
155+ asset = releaseMetadata . data . assets . find (
156+ ( asset ) => asset . name === binaryName . value ,
157+ ) ;
158+ }
159+
150160 if ( asset === undefined ) {
151161 throw new Error (
152- `Expected to find asset in release ${ slug . owner } /${ slug . repository } @${ tag } with label ${ targetLabel } ` ,
162+ `Expected to find asset in release ${ slug . owner } /${ slug . repository } @${ tag } with label ${ targetLabel } or name ${ binaryName . value } ` ,
153163 ) ;
154164 }
165+
155166 return {
156167 binaryName : binaryName ,
157168 url : asset . url ,
@@ -160,16 +171,17 @@ export async function fetchReleaseAssetMetadataFromTag(
160171
161172 // When the binary name is not provided, support two use cases:
162173 // 1. There is only one binary uploaded to this release, a named binary.
163- // 2. There is an asset label matching the target triple (with no binary name).
174+ // 2. There is an asset label or name matching the target triple (with no binary name).
164175 // In both cases, we assume that's the binary the user meant.
165176 // If there is ambiguity, exit with an error.
166177 const matchingTargetTriples = releaseMetadata . data . assets . filter (
167178 ( asset ) =>
168- typeof asset . label === "string" && asset . label . endsWith ( targetTriple ) ,
179+ ( typeof asset . label === "string" && asset . label . endsWith ( targetTriple ) ) ||
180+ ( typeof asset . name === "string" && asset . name . endsWith ( targetTriple ) ) ,
169181 ) ;
170182 if ( matchingTargetTriples . length === 0 ) {
171183 throw new Error (
172- `Expected to find asset in release ${ slug . owner } /${ slug . repository } @${ tag } with label ending in ${ targetTriple } ` ,
184+ `Expected to find asset in release ${ slug . owner } /${ slug . repository } @${ tag } with label or name ending in ${ targetTriple } ` ,
173185 ) ;
174186 }
175187 if ( matchingTargetTriples . length > 1 ) {
@@ -180,7 +192,16 @@ To resolve, specify the desired binary with the target format ${slug.owner}/${sl
180192 ) ;
181193 }
182194 const asset = matchingTargetTriples . shift ( ) ! ;
183- const targetName = stripTargetTriple ( asset . label ! ) ;
195+
196+ // Determine binaryName based on whether we matched by label or name
197+ let targetName ;
198+ if ( typeof asset . label === "string" && asset . label . endsWith ( targetTriple ) ) {
199+ targetName = stripTargetTriple ( asset . label ) ;
200+ } else {
201+ // If matched by name, use the full asset name as binary name
202+ targetName = some ( asset . name as BinaryName ) ;
203+ }
204+
184205 return {
185206 binaryName : targetName ,
186207 url : asset . url ,
0 commit comments