From 3d7a75ee0aa445eb8360b8fa52bb704c567d7578 Mon Sep 17 00:00:00 2001 From: Damien Retzinger Date: Sun, 7 Aug 2022 15:19:15 -0400 Subject: [PATCH] chore(release): automate version bump of yaml on release --- .versionrc | 28 +++++++++++++++++++++++ compose/base/2.3.yml | 19 ++++++++-------- compose/base/2.4.yml | 27 +++++++++++----------- compose/php/7.2/7.2-dolphin.yml | 3 +-- compose/php/7.3/7.3-dolphin.yml | 5 ++--- compose/php/7.4/7.4-dolphin.yml | 5 ++--- compose/php/8.1/8.1-dolphin.yml | 5 ++--- package-lock.json | 18 ++++++++++++++- package.json | 3 ++- tools/standard-version/compose-yml.js | 32 +++++++++++++++++++++++++++ 10 files changed, 108 insertions(+), 37 deletions(-) create mode 100644 .versionrc create mode 100644 tools/standard-version/compose-yml.js diff --git a/.versionrc b/.versionrc new file mode 100644 index 0000000..8f64bcb --- /dev/null +++ b/.versionrc @@ -0,0 +1,28 @@ +{ + "bumpFiles": [ + { + "filename": "compose/base/2.3.yml", + "updater": "tools/standard-version/compose-yml" + }, + { + "filename": "compose/base/2.4.yml", + "updater": "tools/standard-version/compose-yml" + }, + { + "filename": "compose/php/7.2/7.2-dolphin.yml", + "updater": "tools/standard-version/compose-yml" + }, + { + "filename": "compose/php/7.3/7.3-dolphin.yml", + "updater": "tools/standard-version/compose-yml" + }, + { + "filename": "compose/php/7.4/7.4-dolphin.yml", + "updater": "tools/standard-version/compose-yml" + }, + { + "filename": "compose/php/8.1/8.1-dolphin.yml", + "updater": "tools/standard-version/compose-yml" + } + ] +} \ No newline at end of file diff --git a/compose/base/2.3.yml b/compose/base/2.3.yml index 23d0a6f..4d6c316 100644 --- a/compose/base/2.3.yml +++ b/compose/base/2.3.yml @@ -1,5 +1,4 @@ -version : '3' - +version: "3" services: ingress: extends: @@ -7,16 +6,16 @@ services: service: ingress image: graycore/magento-nginx:1.18-alpine-develop-v6.0.0-alpha.2 depends_on: - - magento2 + - magento2 magento2: extends: file: ./compose/base/base.yml service: magento2 image: graycore/magento-php:7.4-fpm-alpine-dolphin-v6.0.0-alpha.2 environment: - - CONFIG__DEFAULT__CATALOG__SEARCH__ELASTICSEARCH6_SERVER_HOSTNAME=elasticsearch - - CONFIG__DEFAULT__CATALOG__SEARCH__ENGINE=elasticsearch6 - - CONFIG__DEFAULT__CATALOG__SEARCH__ELASTICSEARCH6_SERVER_PORT=9200 + - CONFIG__DEFAULT__CATALOG__SEARCH__ELASTICSEARCH6_SERVER_HOSTNAME=elasticsearch + - CONFIG__DEFAULT__CATALOG__SEARCH__ENGINE=elasticsearch6 + - CONFIG__DEFAULT__CATALOG__SEARCH__ELASTICSEARCH6_SERVER_PORT=9200 database: extends: file: ./compose/base/base.yml @@ -51,8 +50,8 @@ services: volumes: - es_data:/usr/share/elasticsearch/data networks: - frontend: - backend: + frontend: null + backend: null volumes: - db_data: - es_data: \ No newline at end of file + db_data: null + es_data: null diff --git a/compose/base/2.4.yml b/compose/base/2.4.yml index a43f33c..e93adee 100644 --- a/compose/base/2.4.yml +++ b/compose/base/2.4.yml @@ -1,5 +1,4 @@ -version : '3' - +version: "3" services: ingress: extends: @@ -7,20 +6,20 @@ services: service: ingress image: graycore/magento-nginx:1.18-alpine-develop-v6.0.0-alpha.2 depends_on: - - magento2 + - magento2 magento2: extends: file: ./compose/base/base.yml service: magento2 image: graycore/magento-php:7.4-fpm-alpine-dolphin-v6.0.0-alpha.2 environment: - - CONFIG__DEFAULT__CATALOG__SEARCH__ELASTICSEARCH7_SERVER_HOSTNAME=elasticsearch - - CONFIG__DEFAULT__CATALOG__SEARCH__ENGINE=elasticsearch7 - - CONFIG__DEFAULT__CATALOG__SEARCH__ELASTICSEARCH7_SERVER_PORT=9200 - - PHP_SENDMAIL_PATH=/usr/sbin/sendmail -S mailhog:1025 - - XDEBUG_CLIENT_PORT=9003 - - XDEBUG_CLIENT_HOST=localhost - - XDEBUG_MODE=debug + - CONFIG__DEFAULT__CATALOG__SEARCH__ELASTICSEARCH7_SERVER_HOSTNAME=elasticsearch + - CONFIG__DEFAULT__CATALOG__SEARCH__ENGINE=elasticsearch7 + - CONFIG__DEFAULT__CATALOG__SEARCH__ELASTICSEARCH7_SERVER_PORT=9200 + - PHP_SENDMAIL_PATH=/usr/sbin/sendmail -S mailhog:1025 + - XDEBUG_CLIENT_PORT=9003 + - XDEBUG_CLIENT_HOST=localhost + - XDEBUG_MODE=debug database: extends: file: ./compose/base/base.yml @@ -65,8 +64,8 @@ services: networks: - backend networks: - frontend: - backend: + frontend: null + backend: null volumes: - db_data: - es_data: \ No newline at end of file + db_data: null + es_data: null diff --git a/compose/php/7.2/7.2-dolphin.yml b/compose/php/7.2/7.2-dolphin.yml index 08242ed..111a68e 100644 --- a/compose/php/7.2/7.2-dolphin.yml +++ b/compose/php/7.2/7.2-dolphin.yml @@ -1,8 +1,7 @@ version: "3" - services: magento2: image: graycore/magento-php:7.2-fpm-alpine-dolphin-v6.0.0-alpha.2 environment: XDEBUG_REMOTE_PORT: "9002" - XDEBUG_REMOTE_HOST: "localhost" \ No newline at end of file + XDEBUG_REMOTE_HOST: localhost diff --git a/compose/php/7.3/7.3-dolphin.yml b/compose/php/7.3/7.3-dolphin.yml index 33ad158..32b01d8 100644 --- a/compose/php/7.3/7.3-dolphin.yml +++ b/compose/php/7.3/7.3-dolphin.yml @@ -1,9 +1,8 @@ version: "3" - services: magento2: image: graycore/magento-php:7.3-fpm-alpine-dolphin-v6.0.0-alpha.2 environment: XDEBUG_CLIENT_PORT: "9003" - XDEBUG_CLIENT_HOST: "localhost" - XDEBUG_MODE: "debug" \ No newline at end of file + XDEBUG_CLIENT_HOST: localhost + XDEBUG_MODE: debug diff --git a/compose/php/7.4/7.4-dolphin.yml b/compose/php/7.4/7.4-dolphin.yml index b918f03..87dc947 100644 --- a/compose/php/7.4/7.4-dolphin.yml +++ b/compose/php/7.4/7.4-dolphin.yml @@ -1,9 +1,8 @@ version: "3" - services: magento2: image: graycore/magento-php:7.4-fpm-alpine-dolphin-v6.0.0-alpha.2 environment: XDEBUG_CLIENT_PORT: "9003" - XDEBUG_CLIENT_HOST: "localhost" - XDEBUG_MODE: "debug" \ No newline at end of file + XDEBUG_CLIENT_HOST: localhost + XDEBUG_MODE: debug diff --git a/compose/php/8.1/8.1-dolphin.yml b/compose/php/8.1/8.1-dolphin.yml index 8562326..f8a4fae 100644 --- a/compose/php/8.1/8.1-dolphin.yml +++ b/compose/php/8.1/8.1-dolphin.yml @@ -1,9 +1,8 @@ version: "3" - services: magento2: image: graycore/magento-php:8.1-fpm-alpine-dolphin-v6.0.0-alpha.2 environment: XDEBUG_CLIENT_PORT: "9003" - XDEBUG_CLIENT_HOST: "localhost" - XDEBUG_MODE: "debug" \ No newline at end of file + XDEBUG_CLIENT_HOST: localhost + XDEBUG_MODE: debug diff --git a/package-lock.json b/package-lock.json index c9a0040..89e7e7d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,8 @@ "version": "5.0.0", "license": "MIT", "devDependencies": { - "standard-version": "^9.3.1" + "standard-version": "^9.3.1", + "yaml": "^2.1.1" } }, "node_modules/@babel/code-frame": { @@ -2054,6 +2055,15 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, + "node_modules/yaml": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.1.1.tgz", + "integrity": "sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw==", + "dev": true, + "engines": { + "node": ">= 14" + } + }, "node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", @@ -3675,6 +3685,12 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, + "yaml": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.1.1.tgz", + "integrity": "sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw==", + "dev": true + }, "yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", diff --git a/package.json b/package.json index 30eb883..afd5fa6 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ }, "homepage": "https://github.com/graycoreio/mage2docker#readme", "devDependencies": { - "standard-version": "^9.3.1" + "standard-version": "^9.3.1", + "yaml": "^2.1.1" } } diff --git a/tools/standard-version/compose-yml.js b/tools/standard-version/compose-yml.js new file mode 100644 index 0000000..8698c27 --- /dev/null +++ b/tools/standard-version/compose-yml.js @@ -0,0 +1,32 @@ +const yaml = require('yaml'); + +const semverMatchRegex = /-v(\d*.*)$/; + +module.exports.readVersion = function (contents) { + const data = yaml.parse(contents); + + for(let key of Object.keys(data.services)) { + if(data.services[key]?.image?.includes("graycore")){ + const matchedVersion = data.services[key]?.image.match(semverMatchRegex)[1]; + if(matchedVersion){ + return matchedVersion; + } + } + } + + throw new Error("Unable to find version"); +} + +module.exports.writeVersion = function (contents, version) { + const data = yaml.parse(contents); + + for(let key of Object.keys(data.services)) { + if(data.services[key]?.image?.includes("graycore")){ + const matchedVersion = data.services[key]?.image.match(semverMatchRegex)[1]; + console.lo + data.services[key].image = data.services[key].image.replace(matchedVersion, version); + } + } + + return yaml.stringify(data); +}