[build] Support version-qualifier flag (#21663)

* [build] Support version-qualifier flag

* add help description

* fix test

* is-release

* temp: re-add alpha1 to package.json

* use version qualifier in build

* fix merge

* Revert "temp: re-add alpha1 to package.json"

This reverts commit a70688542c.

* x-pack

* remove ci build flag

* remove ci build flag

* remove qualifier from canvas

* remove qualifier from infra

* fix x-pack argv

* update comment
This commit is contained in:
Jonathan Budzenski 2018-11-02 09:39:12 -05:00 committed by GitHub
parent d92cbea5b4
commit fa8237d197
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 39 additions and 11 deletions

View file

@ -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": {

View file

@ -46,7 +46,8 @@ exports.installSnapshot = async function installSnapshot({
installPath = path.resolve(basePath, version),
log = defaultLog,
}) {
const fileName = getFilename(license, version);
// 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);

View file

@ -61,6 +61,7 @@ export async function buildDistributables(options) {
createArchives,
createRpmPackage,
createDebPackage,
versionQualifier,
targetAllPlatforms,
} = options;
@ -72,10 +73,12 @@ export async function buildDistributables(options) {
createArchives,
createRpmPackage,
createDebPackage,
versionQualifier,
});
const config = await getConfig({
isRelease,
versionQualifier,
targetAllPlatforms
});

View file

@ -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);
@ -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}
@ -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']),

View file

@ -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');
});
});
});

View file

@ -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);
@ -33,6 +33,7 @@ export async function getConfig({ isRelease, targetAllPlatforms }) {
const versionInfo = await getVersionInfo({
isRelease,
versionQualifier,
pkg,
});

View file

@ -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(),
};
}

View file

@ -1,6 +1,6 @@
{
"name": "x-pack",
"version": "7.0.0-alpha1",
"version": "7.0.0",
"author": "Elastic",
"private": true,
"license": "Elastic-License",

View file

@ -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": {

View file

@ -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"
},

View file

@ -8,7 +8,10 @@ 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')
.option('build-qualifier', {
default: null
});
const argv = yargs.argv;
export default function getVersion(pkg) {
@ -21,5 +24,6 @@ export default function getVersion(pkg) {
}
const snapshotText = (argv.release) ? '' : '-SNAPSHOT';
return `${version}${snapshotText}`;
const qualifierText = argv.buildQualifier ? '-' + argv.buildQualifier : '';
return `${version}${qualifierText}${snapshotText}`;
}