Skip to content

Commit

Permalink
Packages: Use lerna for release orchestration (grafana#17985)
Browse files Browse the repository at this point in the history
  • Loading branch information
dprokop authored and ryantxu committed Jul 9, 2019
1 parent 6599bdc commit c32365f
Show file tree
Hide file tree
Showing 16 changed files with 99 additions and 275 deletions.
6 changes: 6 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"npmClient": "yarn",
"useWorkspaces": true,
"packages": ["packages/*"],
"version": "6.3.0-alpha.36"
}
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"husky": "1.3.1",
"jest": "24.8.0",
"jest-date-mock": "1.0.7",
"lerna": "^3.15.0",
"lint-staged": "8.1.5",
"load-grunt-tasks": "3.5.2",
"mini-css-extract-plugin": "0.5.0",
Expand Down Expand Up @@ -143,13 +144,11 @@
"storybook:build": "cd packages/grafana-ui && yarn storybook:build",
"prettier:check": "prettier --list-different \"**/*.{ts,tsx,scss}\"",
"prettier:write": "prettier --list-different \"**/*.{ts,tsx,scss}\" --write",
"gui:tslint": "tslint -c ./packages/grafana-ui/tslint.json --project ./packages/grafana-ui/tsconfig.json",
"gui:build": "grafana-toolkit gui:build",
"gui:releasePrepare": "grafana-toolkit gui:release",
"gui:publish": "cd packages/grafana-ui/dist && npm publish --access public",
"gui:release": "grafana-toolkit gui:release -p --createVersionCommit",
"precommit": "grafana-toolkit precommit",
"themes:generate": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/generateSassVariableFiles.ts"
"themes:generate": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/generateSassVariableFiles.ts",
"packages:prepare": "lerna run clean && npm run test && lerna version --tag-version-prefix=\"packages@\" -m \"Packages: publish %s\" --no-push",
"packages:build": "lerna run clean && lerna run build",
"packages:publish": "lerna publish from-package --contents dist --tag-version-prefix=\"packages@\" --dist-tag next"
},
"husky": {
"hooks": {
Expand Down
15 changes: 15 additions & 0 deletions packages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Grafana frontend packages

## Releasing new version
We use [Lerna](https://github.com/lerna/lerna) for packages versioning and releases

### Manual release
1. Run `packages:prepare` script from root directory. This will perform cleanup, run all tests and bump version for all packages. Also, it will create `@packages@[version]` tag and version bump commit with `Packages: publish [version]` message.
2. Run `packages:build` script that will prepare distribution packages.
3. Run `packages:publish` to publish new versions
- add `--dist-tag next` to publish under `next` tag
4. Push version commit

### Building individual packages
To build induvidual packages run `grafana-toolkit package:build --scope=<ui|toolkit|runtime|data>`

3 changes: 3 additions & 0 deletions packages/grafana-data/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# (2019-07-08)
First public release

7 changes: 4 additions & 3 deletions packages/grafana-data/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@grafana/data",
"version": "6.3.0-alpha.0",
"version": "6.3.0-alpha.36",
"description": "Grafana Data Library",
"keywords": [
"typescript"
Expand All @@ -10,11 +10,12 @@
"tslint": "tslint -c tslint.json --project tsconfig.json",
"typecheck": "tsc --noEmit",
"clean": "rimraf ./dist ./compiled",
"build": "rollup -c rollup.config.ts"
"bundle": "rollup -c rollup.config.ts",
"build": "grafana-toolkit package:build --scope=data",
"postpublish": "npm run clean"
},
"author": "Grafana Labs",
"license": "Apache-2.0",
"dependencies": {},
"devDependencies": {
"@types/jest": "23.3.14",
"@types/jquery": "1.10.35",
Expand Down
3 changes: 3 additions & 0 deletions packages/grafana-runtime/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# (2019-07-08)
First public release

6 changes: 4 additions & 2 deletions packages/grafana-runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@grafana/runtime",
"version": "6.3.0-alpha.0",
"version": "6.3.0-alpha.36",
"description": "Grafana Runtime Library",
"keywords": [
"typescript",
Expand All @@ -12,7 +12,9 @@
"tslint": "tslint -c tslint.json --project tsconfig.json",
"typecheck": "tsc --noEmit",
"clean": "rimraf ./dist ./compiled",
"build": "rollup -c rollup.config.ts"
"bundle": "rollup -c rollup.config.ts",
"build": "grafana-toolkit package:build --scope=runtime",
"postpublish": "npm run clean"
},
"author": "Grafana Labs",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/grafana-runtime/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const buildCjsPackage = ({ env }) => {
globals: {},
},
],
external: ['lodash'], // Use Lodash from grafana
external: ['lodash', '@grafana/ui', '@grafana/data'], // Use Lodash from grafana
plugins: [
commonjs({
include: /node_modules/,
Expand Down
6 changes: 4 additions & 2 deletions packages/grafana-toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@grafana/toolkit",
"version": "6.3.0-alpha.2",
"version": "6.3.0-alpha.36",
"description": "Grafana Toolkit",
"keywords": [
"typescript",
Expand All @@ -14,7 +14,9 @@
"tslint": "tslint -c tslint.json --project tsconfig.json",
"typecheck": "tsc --noEmit",
"precommit": "npm run tslint & npm run typecheck",
"clean": "rimraf ./dist ./compiled"
"clean": "rimraf ./dist ./compiled",
"build": "grafana-toolkit toolkit:build",
"postpublish": "npm run clean"
},
"author": "Grafana Labs",
"license": "Apache-2.0",
Expand Down
25 changes: 6 additions & 19 deletions packages/grafana-toolkit/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import program from 'commander';
import { execTask } from './utils/execTask';
import chalk from 'chalk';
import { startTask } from './tasks/core.start';
import { buildTask } from './tasks/grafanaui.build';
import { releaseTask } from './tasks/grafanaui.release';
import { changelogTask } from './tasks/changelog';
import { cherryPickTask } from './tasks/cherrypick';
import { precommitTask } from './tasks/precommit';
Expand All @@ -16,6 +14,7 @@ import { searchTestDataSetupTask } from './tasks/searchTestDataSetup';
import { closeMilestoneTask } from './tasks/closeMilestone';
import { pluginDevTask } from './tasks/plugin.dev';
import { pluginCITask } from './tasks/plugin.ci';
import { buildPackageTask } from './tasks/package.build';

export const run = (includeInternalScripts = false) => {
if (includeInternalScripts) {
Expand All @@ -33,24 +32,12 @@ export const run = (includeInternalScripts = false) => {
});

program
.command('gui:build')
.description('Builds @grafana/ui package to packages/grafana-ui/dist')
.command('package:build')
.option('-s, --scope <packages>', 'packages=[data|runtime|ui|toolkit]')
.description('Builds @grafana/* package to packages/grafana-*/dist')
.action(async cmd => {
// @ts-ignore
await execTask(buildTask)();
});

program
.command('gui:release')
.description('Prepares @grafana/ui release (and publishes to npm on demand)')
.option('-p, --publish', 'Publish @grafana/ui to npm registry')
.option('-u, --usePackageJsonVersion', 'Use version specified in package.json')
.option('--createVersionCommit', 'Create and push version commit')
.action(async cmd => {
await execTask(releaseTask)({
publishToNpm: !!cmd.publish,
usePackageJsonVersion: !!cmd.usePackageJsonVersion,
createVersionCommit: !!cmd.createVersionCommit,
await execTask(buildPackageTask)({
scope: cmd.scope,
});
});

Expand Down
190 changes: 0 additions & 190 deletions packages/grafana-toolkit/src/cli/tasks/grafanaui.release.ts

This file was deleted.

Loading

0 comments on commit c32365f

Please sign in to comment.