Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] Support version-qualifier flag #21663

Merged
merged 17 commits into from
Nov 2, 2018
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dashboarding"
],
"private": true,
"version": "7.0.0-alpha1",
"version": "7.0.0",
"branch": "master",
"types": "./target/types/type_exports.d.ts",
"build": {
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-es/src/install/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ exports.installSnapshot = async function installSnapshot({
installPath = path.resolve(basePath, version),
log = defaultLog,
}) {
const fileName = getFilename(license, version);
// TODO: revert
Copy link
Contributor

@tylersmalley tylersmalley Nov 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the TODO;

TODO: remove -alpha1 once elastic/elasticsearch#35172 has been merged

const fileName = getFilename(license, version + '-alpha1');
const url = `https://snapshots.elastic.co/downloads/elasticsearch/${fileName}`;
const dest = path.resolve(basePath, 'cache', fileName);

Expand Down
3 changes: 3 additions & 0 deletions src/dev/build/build_distributables.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export async function buildDistributables(options) {
createArchives,
createRpmPackage,
createDebPackage,
versionQualifier,
targetAllPlatforms,
} = options;

Expand All @@ -73,10 +74,12 @@ export async function buildDistributables(options) {
createArchives,
createRpmPackage,
createDebPackage,
versionQualifier,
});

const config = await getConfig({
isRelease,
versionQualifier,
targetAllPlatforms
});

Expand Down
5 changes: 4 additions & 1 deletion src/dev/build/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ const flags = getopts(process.argv.slice(0), {
d: 'debug',
},
default: {
debug: true
debug: true,
'version-qualifier': ''
},
unknown: (flag) => {
unknownFlags.push(flag);
Expand Down Expand Up @@ -79,6 +80,7 @@ if (flags.help) {
--rpm {dim Only build the rpm package}
--deb {dim Only build the deb package}
--release {dim Produce a release-ready distributable}
--version-qualifier {dim Suffix version with a qualifier}
--skip-node-download {dim Reuse existing downloads of node.js}
--verbose,-v {dim Turn on verbose logging}
--no-debug {dim Turn off debug logging}
Expand Down Expand Up @@ -110,6 +112,7 @@ function isOsPackageDesired(name) {
buildDistributables({
log,
isRelease: Boolean(flags.release),
versionQualifier: flags['version-qualifier'],
buildOssDist: flags.oss !== false,
buildDefaultDist: !flags.oss,
downloadFreshNode: !Boolean(flags['skip-node-download']),
Expand Down
11 changes: 11 additions & 0 deletions src/dev/build/lib/__tests__/version_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,15 @@ describe('dev/build/lib/version_info', () => {
expect(versionInfo).to.have.property('buildNumber').a('number').greaterThan(1000);
});
});

describe('versionQualifier', () => {
it('appends a version qualifier', async () => {
const versionInfo = await getVersionInfo({
isRelease: true,
versionQualifier: 'beta55',
pkg
});
expect(versionInfo).to.have.property('buildVersion').be(pkg.version + '-beta55');
});
});
});
3 changes: 2 additions & 1 deletion src/dev/build/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { platform as getOsPlatform } from 'os';
import { getVersionInfo } from './version_info';
import { createPlatform } from './platform';

export async function getConfig({ isRelease, targetAllPlatforms }) {
export async function getConfig({ isRelease, targetAllPlatforms, versionQualifier }) {
const pkgPath = resolve(__dirname, '../../../../package.json');
const pkg = require(pkgPath);
const repoRoot = dirname(pkgPath);
Expand All @@ -33,6 +33,7 @@ export async function getConfig({ isRelease, targetAllPlatforms }) {

const versionInfo = await getVersionInfo({
isRelease,
versionQualifier,
pkg,
});

Expand Down
9 changes: 7 additions & 2 deletions src/dev/build/lib/version_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@ async function getBuildNumber() {
return parseFloat(wc.stdout.trim());
}

export async function getVersionInfo({ isRelease, pkg }) {
export async function getVersionInfo({ isRelease, versionQualifier, pkg }) {
const buildVersion = pkg.version.concat(
versionQualifier ? `-${versionQualifier}` : '',
isRelease ? '' : '-SNAPSHOT'
);

return {
buildSha: await execa.stdout('git', ['rev-parse', 'HEAD']),
buildVersion: isRelease ? pkg.version : `${pkg.version}-SNAPSHOT`,
buildVersion,
buildNumber: await getBuildNumber(),
};
}
2 changes: 1 addition & 1 deletion x-pack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "x-pack",
"version": "7.0.0-alpha1",
"version": "7.0.0",
"author": "Elastic",
"private": true,
"license": "Elastic-License",
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/canvas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "canvas",
"version": "7.0.0-alpha1",
"version": "7.0.0",
"description": "Data driven workpads for kibana",
"main": "index.js",
"kibana": {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/infra/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "Elastic",
"name": "infra",
"version": "7.0.0-alpha1",
"version": "7.0.0",
"scripts": {
"build-graphql-types": "node scripts/generate_types_from_graphql.js"
},
Expand Down
6 changes: 4 additions & 2 deletions x-pack/tasks/helpers/build_version.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import yargs from 'yargs';
import semver from 'semver';

yargs
.alias('r', 'release').describe('r', 'Create a release build, not a snapshot');
.alias('r', 'release').describe('r', 'Create a release build, not a snapshot')
.alias('build-qualifier').describe('build-qualifier', 'Suffix the build version');
const argv = yargs.argv;

export default function getVersion(pkg) {
Expand All @@ -21,5 +22,6 @@ export default function getVersion(pkg) {
}

const snapshotText = (argv.release) ? '' : '-SNAPSHOT';
return `${version}${snapshotText}`;
const qualifierText = argv['build-qualifier'] ? '-' + argv['build-qualifier'] : '';
return `${version}${qualifierText}${snapshotText}`;
}