@@ -53,22 +53,40 @@ async function uploadModuleToAppStore(pkgName, marketplaceId, version, minimumMX
5353
5454async function getGithubAssetUrl ( ) {
5555 console . log ( "Retrieving informations from Github Tag" ) ;
56- const request = await fetch ( "GET" , "https://api.github.com/repos/mendix/native-widgets/releases?per_page=10" ) ;
57- const data = ( await request ) ?? [ ] ;
58- const releaseId = data . find ( info => info . tag_name === process . env . TAG ) ?. id ;
59- if ( ! releaseId ) {
60- throw new Error ( `Could not find release with tag ${ process . env . TAG } on GitHub` ) ;
61- }
62- const assetsRequest = await fetch (
63- "GET" ,
64- `https://api.github.com/repos/mendix/native-widgets/releases/${ releaseId } /assets`
65- ) ;
66- const assetsData = ( await assetsRequest ) ?? [ ] ;
67- const downloadUrl = assetsData . find ( asset => asset . name . endsWith ( ".mpk" ) ) ?. browser_download_url ;
68- if ( ! downloadUrl ) {
69- throw new Error ( `Could not retrieve MPK url from GitHub release with tag ${ process . env . TAG } ` ) ;
56+ const tag = process . env . TAG ;
57+ const githubHeaders = process . env . GITHUB_TOKEN ? { Authorization : `Bearer ${ process . env . GITHUB_TOKEN } ` } : { } ;
58+
59+ // Use direct tag lookup endpoint instead of listing releases
60+ // This avoids pagination issues and is more reliable
61+ const maxRetries = 5 ;
62+ const retryDelayMs = 5000 ;
63+
64+ for ( let attempt = 1 ; attempt <= maxRetries ; attempt ++ ) {
65+ console . log ( `Attempt ${ attempt } /${ maxRetries } : Fetching release for tag ${ tag } ` ) ;
66+
67+ const releaseData = await fetch (
68+ "GET" ,
69+ `https://api.github.com/repos/mendix/native-widgets/releases/tags/${ tag } ` ,
70+ undefined ,
71+ githubHeaders
72+ ) ;
73+
74+ if ( releaseData && releaseData . id ) {
75+ console . log ( `Found release: ${ releaseData . name } (id: ${ releaseData . id } )` ) ;
76+ const downloadUrl = releaseData . assets ?. find ( asset => asset . name . endsWith ( ".mpk" ) ) ?. browser_download_url ;
77+ if ( ! downloadUrl ) {
78+ throw new Error ( `Could not retrieve MPK url from GitHub release with tag ${ tag } ` ) ;
79+ }
80+ return downloadUrl ;
81+ }
82+
83+ if ( attempt < maxRetries ) {
84+ console . log ( `Release not found yet, waiting ${ retryDelayMs / 1000 } s before retry...` ) ;
85+ await new Promise ( resolve => setTimeout ( resolve , retryDelayMs ) ) ;
86+ }
7087 }
71- return downloadUrl ;
88+
89+ throw new Error ( `Could not find release with tag ${ tag } on GitHub after ${ maxRetries } attempts` ) ;
7290}
7391
7492async function createDraft ( marketplaceId , version , minimumMXVersion ) {
0 commit comments