Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ RUN apk update && apk upgrade
COPY package.json .
COPY package-lock.json .
COPY generateEsModulesFromJson.cjs .
COPY updateVersionOpenApi.cjs .
COPY openapi.yaml .

RUN npm ci --omit=dev

COPY src ./src
COPY openapi.yaml .

CMD ["npm", "start"]
2 changes: 1 addition & 1 deletion api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ info:
title: iExec market API
description: >-
iExec market API OpenAPI specification
version: 6.4.1
version: 7.1.1
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
Expand Down
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"npm": ">=10.0.0"
},
"scripts": {
"codegen": "node generateEsModulesFromJson.cjs",
"codegen": "node generateEsModulesFromJson.cjs && node updateVersionOpenApi.cjs",
"postinstall": "npm run codegen",
"format": "prettier --write .",
"check-format": "prettier --check .",
Expand Down
35 changes: 35 additions & 0 deletions api/updateVersionOpenApi.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const path = require('path');
const { writeFile, readFile } = require('fs/promises');

const OPEN_API_SPECIFICATION_FILE = 'openapi.yaml';

async function updateVersionOpenApi() {
const packagePath = path.join(__dirname, 'package.json');
const packageContent = await readFile(packagePath, 'utf8');
const packageJson = JSON.parse(packageContent);
const packageVersion = packageJson.version;

const openApiPath = path.join(__dirname, OPEN_API_SPECIFICATION_FILE);
const openApiContent = await readFile(openApiPath, 'utf8');
const openApiVersionPattern = /version: \d+\.\d+\.\d+(-\S+)?/;

const [match] = openApiContent.match(openApiVersionPattern);

const currentVersion = match.split('version: ')[1];
if (currentVersion === packageVersion) {
return;
}
const updatedContent = openApiContent.replace(
openApiVersionPattern,
`version: ${packageVersion}`,
);
await writeFile(openApiPath, updatedContent, 'utf8');
console.log(
`version updated from ${currentVersion} to ${packageVersion} in ${OPEN_API_SPECIFICATION_FILE}`,
);
}

updateVersionOpenApi().catch((error) => {
console.error('Error updating OpenAPI version:', error);
process.exit(1);
});