Skip to content

Commit 6a9c2a5

Browse files
[MOO-2322] : Update marketplace deployement contributor url endpoint (#519)
2 parents a756a3f + 115de88 commit 6a9c2a5

3 files changed

Lines changed: 84 additions & 5 deletions

File tree

.github/actions/slack-notification/action.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ runs:
1818
- name: Send Slack notification
1919
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2
2020
with:
21-
channel-id: ${{ inputs.channel-id }}
22-
slack-message: ${{ inputs.message }}
23-
env:
24-
SLACK_BOT_TOKEN: ${{ inputs.bot-token }}
21+
method: chat.postMessage
22+
token: ${{ inputs.bot-token }}
23+
payload: |
24+
channel: "${{ inputs.channel-id }}"
25+
text: "${{ inputs.message }}"

.github/workflows/MarketplaceRelease.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
CPAPI_PASS_PROD: ${{ secrets.CPAPI_PASS_PROD }}
5050
TAG: ${{ steps.variables.outputs.tag }}
5151
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
MENDIX_PAT_TOKEN: ${{ secrets.MENDIX_PAT_TOKEN }}
5253
- name: "Send slack msg on failure"
5354
if: ${{ failure() }}
5455
uses: ./.github/actions/slack-notification

scripts/release/marketplaceRelease.js

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { join } = require("path");
33

44
const 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

Comments
 (0)