Skip to content

Commit

Permalink
Release v0.7.1 and v0.7.2 (#40)
Browse files Browse the repository at this point in the history
* Release script
* Release v0.7.1
* Release v0.7.2
  • Loading branch information
kamilkisiela authored Jan 5, 2019
1 parent 3b1e47d commit a6d8ba9
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"
Expand All @@ -12,7 +12,7 @@ LABEL com.github.actions.color="red"

ENV LOG_LEVEL 'debug'

RUN yarn global add @graphql-inspector/[email protected].0
RUN yarn global add @graphql-inspector/[email protected].2

COPY entrypoint.sh /entrypoint.sh

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.7.0"
"version": "0.7.2"
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
6 changes: 3 additions & 3 deletions packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-inspector/api",
"version": "0.7.0",
"version": "0.0.0-PLACEHOLDER",
"description": "GraphQL Inspector API",
"keywords": [
"graphql",
Expand Down Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/github-actions/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions packages/github/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/load/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-inspector/ui",
"version": "0.7.0",
"version": "0.0.0-PLACEHOLDER",
"description": "GraphQL Inspector GUI",
"keywords": [
"graphql",
Expand Down
89 changes: 89 additions & 0 deletions scripts/release.js
Original file line number Diff line number Diff line change
@@ -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',
});
}

0 comments on commit a6d8ba9

Please sign in to comment.