@@ -221,21 +221,28 @@ export async function fetchLatestActionVersion(actionName: string): Promise<stri
221221 } )
222222
223223 if ( releasesResponse . ok ) {
224- const releases = await releasesResponse . json ( ) as Array < { tag_name ?: string , published_at ?: string } >
225- console . log ( `📋 Found ${ releases . length } releases` )
226-
227- // Filter out pre-releases and sort by published date
228- const stableReleases = releases
229- . filter ( release => release . tag_name && ! release . tag_name . includes ( '-' ) )
230- . sort ( ( a , b ) => {
231- const dateA = a . published_at ? new Date ( a . published_at ) . getTime ( ) : 0
232- const dateB = b . published_at ? new Date ( b . published_at ) . getTime ( ) : 0
233- return dateB - dateA // Sort descending (newest first)
234- } )
224+ const releases = await releasesResponse . json ( )
235225
236- if ( stableReleases . length > 0 ) {
237- console . log ( `✅ Found latest stable release: ${ stableReleases [ 0 ] . tag_name } ` )
238- return stableReleases [ 0 ] . tag_name || null
226+ // Ensure we have an array
227+ if ( ! Array . isArray ( releases ) ) {
228+ console . log ( `⚠️ Unexpected releases response format (expected array)` )
229+ }
230+ else {
231+ console . log ( `📋 Found ${ releases . length } releases` )
232+
233+ // Filter out pre-releases and sort by published date
234+ const stableReleases = releases
235+ . filter ( ( release : any ) => release . tag_name && ! release . tag_name . includes ( '-' ) )
236+ . sort ( ( a : any , b : any ) => {
237+ const dateA = a . published_at ? new Date ( a . published_at ) . getTime ( ) : 0
238+ const dateB = b . published_at ? new Date ( b . published_at ) . getTime ( ) : 0
239+ return dateB - dateA // Sort descending (newest first)
240+ } )
241+
242+ if ( stableReleases . length > 0 ) {
243+ console . log ( `✅ Found latest stable release: ${ stableReleases [ 0 ] . tag_name } ` )
244+ return stableReleases [ 0 ] . tag_name || null
245+ }
239246 }
240247 }
241248 else {
@@ -249,35 +256,42 @@ export async function fetchLatestActionVersion(actionName: string): Promise<stri
249256 } )
250257
251258 if ( tagsResponse . ok ) {
252- const tags = await tagsResponse . json ( ) as Array < { name ?: string } >
253- console . log ( `📋 Found ${ tags . length } tags` )
254-
255- // Filter out pre-releases and find the latest stable tag
256- const stableTags = tags
257- . filter ( tag => tag . name && ! tag . name . includes ( '-' ) )
258- . map ( tag => tag . name ! )
259- . sort ( ( a , b ) => {
260- // Simple version comparison for tags
261- // Remove 'v' prefix if present for proper number parsing
262- const aClean = a . replace ( / ^ v / , '' )
263- const bClean = b . replace ( / ^ v / , '' )
264-
265- const aParts = aClean . split ( '.' ) . map ( Number )
266- const bParts = bClean . split ( '.' ) . map ( Number )
267-
268- for ( let i = 0 ; i < Math . max ( aParts . length , bParts . length ) ; i ++ ) {
269- const aPart = aParts [ i ] || 0
270- const bPart = bParts [ i ] || 0
271- if ( aPart !== bPart ) {
272- return bPart - aPart // Sort descending
259+ const tags = await tagsResponse . json ( )
260+
261+ // Ensure we have an array
262+ if ( ! Array . isArray ( tags ) ) {
263+ console . log ( `⚠️ Unexpected tags response format (expected array)` )
264+ }
265+ else {
266+ console . log ( `📋 Found ${ tags . length } tags` )
267+
268+ // Filter out pre-releases and find the latest stable tag
269+ const stableTags = tags
270+ . filter ( ( tag : any ) => tag . name && ! tag . name . includes ( '-' ) )
271+ . map ( ( tag : any ) => tag . name ! )
272+ . sort ( ( a : string , b : string ) => {
273+ // Simple version comparison for tags
274+ // Remove 'v' prefix if present for proper number parsing
275+ const aClean = a . replace ( / ^ v / , '' )
276+ const bClean = b . replace ( / ^ v / , '' )
277+
278+ const aParts = aClean . split ( '.' ) . map ( Number )
279+ const bParts = bClean . split ( '.' ) . map ( Number )
280+
281+ for ( let i = 0 ; i < Math . max ( aParts . length , bParts . length ) ; i ++ ) {
282+ const aPart = aParts [ i ] || 0
283+ const bPart = bParts [ i ] || 0
284+ if ( aPart !== bPart ) {
285+ return bPart - aPart // Sort descending
273286 }
274287 }
275288 return 0
276289 } )
277290
278- if ( stableTags . length > 0 ) {
279- console . log ( `✅ Found latest stable tag: ${ stableTags [ 0 ] } ` )
280- return stableTags [ 0 ]
291+ if ( stableTags . length > 0 ) {
292+ console . log ( `✅ Found latest stable tag: ${ stableTags [ 0 ] } ` )
293+ return stableTags [ 0 ]
294+ }
281295 }
282296 }
283297 else {
0 commit comments