diff --git a/Dockerfile b/Dockerfile index 804d5bfa3f..0336b9903b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM node:10-slim -LABEL version="1.0.1" +LABEL version="0.7.2" LABEL repository="http://github.com/kamilkisiela/graphql-inspector" LABEL homepage="http://github.com/kamilkisiela/graphql-inspector" LABEL maintainer="Kamil Kisiela " @@ -12,7 +12,7 @@ LABEL com.github.actions.color="red" ENV LOG_LEVEL 'debug' -RUN yarn global add @graphql-inspector/actions@0.7.0 +RUN yarn global add @graphql-inspector/actions@0.7.2 COPY entrypoint.sh /entrypoint.sh diff --git a/lerna.json b/lerna.json index 4ef702fd2c..534f0fd7ce 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { "npmClient": "yarn", "useWorkspaces": true, - "version": "0.7.0" + "version": "0.7.2" } diff --git a/package.json b/package.json index 4e03c202e4..32fcff9edc 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,9 @@ }, "dependencies": { "husky": "1.2.0", - "lerna": "3.6.0" + "immer": "1.10.0", + "lerna": "3.6.0", + "shelljs": "0.8.3" }, "workspaces": { "packages": [ diff --git a/packages/api/package.json b/packages/api/package.json index cc1094d96d..a74bb13719 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-inspector/api", - "version": "0.7.0", + "version": "0.0.0-PLACEHOLDER", "description": "GraphQL Inspector API", "keywords": [ "graphql", @@ -28,8 +28,8 @@ "prepublishOnly": "yarn build" }, "dependencies": { - "@graphql-inspector/core": "0.7.0", - "@graphql-inspector/load": "0.7.0", + "@graphql-inspector/core": "0.0.0-PLACEHOLDER", + "@graphql-inspector/load": "0.0.0-PLACEHOLDER", "@graphql-modules/epoxy": "0.2.17", "apollo-server-express": "2.2.6", "graphql": "14.0.2", diff --git a/packages/cli/package.json b/packages/cli/package.json index 3300923f1c..818aaefdd9 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-inspector/cli", - "version": "0.7.0", + "version": "0.0.0-PLACEHOLDER", "description": "Tooling for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.", "keywords": [ "graphql", @@ -45,10 +45,10 @@ "typescript": "3.2.2" }, "dependencies": { - "@graphql-inspector/api": "0.7.0", - "@graphql-inspector/core": "0.7.0", - "@graphql-inspector/load": "0.7.0", - "@graphql-inspector/ui": "0.7.0", + "@graphql-inspector/api": "0.0.0-PLACEHOLDER", + "@graphql-inspector/core": "0.0.0-PLACEHOLDER", + "@graphql-inspector/load": "0.0.0-PLACEHOLDER", + "@graphql-inspector/ui": "0.0.0-PLACEHOLDER", "apollo-server": "2.2.6", "apollo-server-express": "2.2.6", "chalk": "2.4.1", diff --git a/packages/core/package.json b/packages/core/package.json index a128f50454..eeea7358db 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-inspector/core", - "version": "0.7.0", + "version": "0.0.0-PLACEHOLDER", "description": "Tooling for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.", "keywords": [ "graphql", diff --git a/packages/github-actions/package.json b/packages/github-actions/package.json index 754c4fa8d3..1cff7af355 100644 --- a/packages/github-actions/package.json +++ b/packages/github-actions/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-inspector/actions", - "version": "0.7.0", + "version": "0.0.0-PLACEHOLDER", "description": "Github Actions for GraphQL", "sideEffects": false, "author": { @@ -32,7 +32,7 @@ "prepublishOnly": "yarn build" }, "dependencies": { - "@graphql-inspector/github": "0.7.0", + "@graphql-inspector/github": "0.0.0-PLACEHOLDER", "graphql": "14.0.2", "probot": "7.4.0", "uuid": "3.3.2" diff --git a/packages/github/package.json b/packages/github/package.json index b6bb254d8d..58a04bd9b3 100644 --- a/packages/github/package.json +++ b/packages/github/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-inspector/github", - "version": "0.7.0", + "version": "0.0.0-PLACEHOLDER", "description": "Probot for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.", "keywords": [ "graphql", @@ -36,7 +36,7 @@ "probot": "^7.4.0" }, "dependencies": { - "@graphql-inspector/core": "0.7.0" + "@graphql-inspector/core": "0.0.0-PLACEHOLDER" }, "devDependencies": { "@types/express": "4.16.0", diff --git a/packages/load/package.json b/packages/load/package.json index 3c0466fdff..175547d17a 100644 --- a/packages/load/package.json +++ b/packages/load/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-inspector/load", - "version": "0.7.0", + "version": "0.0.0-PLACEHOLDER", "description": "Load GraphQL Schema and Documents from any source", "keywords": [ "graphql", diff --git a/packages/ui/package.json b/packages/ui/package.json index a0a9a9dd45..68112c81df 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-inspector/ui", - "version": "0.7.0", + "version": "0.0.0-PLACEHOLDER", "description": "GraphQL Inspector GUI", "keywords": [ "graphql", diff --git a/scripts/release.js b/scripts/release.js new file mode 100755 index 0000000000..a463768de9 --- /dev/null +++ b/scripts/release.js @@ -0,0 +1,89 @@ +#!/usr/bin/env node + +const {readFileSync, writeFileSync} = require('fs'); +const {resolve, join, relative} = require('path'); +const {exec} = require('shelljs'); +const semver = require('semver'); +const detectIndent = require('detect-indent'); +const immer = require('immer').default; + +const placeholder = '0.0.0-PLACEHOLDER'; +const [, , version] = process.argv; +const rootDir = resolve(__dirname, '../'); +const rootPackage = join(rootDir, 'package.json'); +const lerna = join(rootDir, 'lerna.json'); + +const packages = JSON.parse( + readFileSync(rootPackage, {encoding: 'utf-8'}), +).workspaces.packages.map(p => join(rootDir, p)); + +const current = JSON.parse(readFileSync(lerna, {encoding: 'utf-8'})).version; +const branch = `release/v${version}`; + +if (!semver.valid(version)) { + throw new Error(`Version ${version} is not valid`); +} + +// ! lerna.json as the source of truth of a version number + +// 0. Branch out +exec(`git checkout -b ${branch}`); + +// 1. Set version in lerna.json +updateJSON(lerna, data => { + data.version = version; +}); + +// 2. Set version in packages +packages.map(dir => { + updateString(join(dir, 'package.json'), pkg => + pkg.replace(new RegExp(placeholder, 'g'), version), + ); +}); + +// 3. Set version in Dockerfile (both LABEL and RUN) +updateString(join(rootDir, 'Dockerfile'), docker => + docker.replace(new RegExp(current, 'g'), version), +); + +// 4. Run npm publish in all libraries +packages.map(dir => { + exec(`(cd ${dir} && npm publish --access public)`); +}); + +// 5. Revert changes in libraries (back to placeholders) +exec( + `git checkout -- ${packages.map(dir => relative(rootDir, dir)).join(' ')}`, +); + +// 6. Add changes and commit as `Release vX.X.X` +exec(`git add . && git commit -m "Release v${version}"`); + +// 7. git push origin release/vX.X.X +exec(`git push origin ${branch}`); + +// 8. git checkout master +exec(`git checkout master`); + +// 9. git branch -D release/vX.X.X +exec(`git branch -D ${branch}`); + +function updateJSON(filepath, updateFn) { + const content = readFileSync(filepath, {encoding: 'utf-8'}); + const {indent} = detectIndent(content); + const data = JSON.parse(content); + + const modified = immer(data, updateFn); + + writeFileSync(filepath, JSON.stringify(modified, null, indent), { + encoding: 'utf-8', + }); +} + +function updateString(filepath, updateFn) { + const content = readFileSync(filepath, {encoding: 'utf-8'}); + + writeFileSync(filepath, updateFn(content), { + encoding: 'utf-8', + }); +}