@@ -3,7 +3,7 @@ const { join } = require("path");
33
44const config = {
55 appStoreUrl : "https://appstore.home.mendix.com/rest/packagesapi/v2" ,
6- contributorUrl : "https://contributor.mendixcloud .com/apis/v1" ,
6+ contributorUrl : "https://contributor.mendix .com/apis/v1" ,
77 // This one, for some reasons, needs to be added as OpenID header to contributor request.
88 // The open id value (a39025a8-55b8-4532-bc5d-4e74901d11f9) is taken from widgets@mendix.com
99 // account and could be found at Profile -> Advanced -> Personal Info -> View My Data -> Open id
@@ -44,6 +44,8 @@ async function uploadModuleToAppStore(pkgName, marketplaceId, version, minimumMX
4444 const postResponse = await createDraft ( marketplaceId , version , minimumMXVersion ) ;
4545 await publishDraft ( postResponse . UUID ) ;
4646 console . log ( `Successfully uploaded ${ pkgName } to the Mendix Marketplace.` ) ;
47+
48+ await verifyReleasePublished ( marketplaceId , version , pkgName ) ;
4749 } catch ( error ) {
4850 error . message = `Failed uploading ${ pkgName } to appstore with error: ${ error . message } ` ;
4951 throw error ;
@@ -176,3 +178,78 @@ function packageMetadata() {
176178 const { name, widgetName, version, marketplace } = require ( pkgPath ) ;
177179 return { name, widgetName, version, marketplace } ;
178180}
181+
182+ async function verifyReleasePublished ( contentId , expectedVersion , pkgName ) {
183+ const normalizedExpectedVersion = expectedVersion . startsWith ( "v" ) ? expectedVersion . substring ( 1 ) : expectedVersion ;
184+
185+ console . log ( `Verifying release ${ normalizedExpectedVersion } is published for content ID ${ contentId } ...` ) ;
186+
187+ const patToken = process . env . MENDIX_PAT_TOKEN ;
188+ if ( ! patToken ) {
189+ console . warn ( "WARNING: MENDIX_PAT_TOKEN environment variable is not set. Skipping release verification." ) ;
190+ return ;
191+ }
192+
193+ const maxRetries = 5 ;
194+ const initialDelayMs = 60000 ;
195+ const retryDelayMs = 60000 ;
196+
197+ await new Promise ( resolve => setTimeout ( resolve , initialDelayMs ) ) ;
198+
199+ for ( let attempt = 1 ; attempt <= maxRetries ; attempt ++ ) {
200+ console . log ( `Verification attempt ${ attempt } /${ maxRetries } : Checking for version ${ expectedVersion } ` ) ;
201+
202+ try {
203+ // Call the Mendix Content API to get all released module versions
204+ const versionsResponse = await nodefetch (
205+ `https://marketplace-api.mendix.com/v1/content/${ contentId } /versions` ,
206+ {
207+ method : "GET" ,
208+ headers : {
209+ Accept : "application/json" ,
210+ Authorization : `MxToken ${ patToken } `
211+ }
212+ }
213+ ) ;
214+
215+ if ( ! versionsResponse . ok ) {
216+ const errorText = await versionsResponse . text ( ) ;
217+ throw new Error (
218+ `Content API returned status ${ versionsResponse . status } : ${ versionsResponse . statusText } . Response: ${ errorText } `
219+ ) ;
220+ }
221+
222+ const responseData = await versionsResponse . json ( ) ;
223+
224+ if ( ! responseData . items || ! Array . isArray ( responseData . items ) ) {
225+ throw new Error ( `Unexpected API response structure: ${ JSON . stringify ( responseData ) } ` ) ;
226+ }
227+
228+ const versions = responseData . items ;
229+
230+ const versionFound = versions . some ( v => v . versionNumber === normalizedExpectedVersion ) ;
231+
232+ if ( versionFound ) {
233+ console . log (
234+ `Successfully verified: Version ${ normalizedExpectedVersion } is published on Mendix Marketplace!`
235+ ) ;
236+ return ;
237+ }
238+
239+ if ( attempt < maxRetries ) {
240+ await new Promise ( resolve => setTimeout ( resolve , retryDelayMs ) ) ;
241+ }
242+ } catch ( error ) {
243+ console . error ( `Error during verification attempt ${ attempt } : ${ error . message } ` ) ;
244+ if ( attempt < maxRetries ) {
245+ await new Promise ( resolve => setTimeout ( resolve , retryDelayMs ) ) ;
246+ }
247+ }
248+ }
249+
250+ throw new Error (
251+ `Release verification FAILED: Version ${ normalizedExpectedVersion } for ${ pkgName } (content ID: ${ contentId } ) ` +
252+ `was not found on Mendix Marketplace after ${ maxRetries } attempts. ` +
253+ `The publish step reported success, but the version is not publicly available. `
254+ ) ;
255+ }
0 commit comments