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": false,
"version": "7.0.0-alpha1",
"version": "7.0.0",
"branch": "master",
"build": {
"number": 8467,
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 @@ -61,6 +61,7 @@ export async function buildDistributables(options) {
createArchives,
createRpmPackage,
createDebPackage,
versionQualifier,
} = options;

log.verbose('building distributables with options:', {
Expand All @@ -71,10 +72,12 @@ export async function buildDistributables(options) {
createArchives,
createRpmPackage,
createDebPackage,
versionQualifier,
});

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

const run = createRunner({
Expand Down
5 changes: 5 additions & 0 deletions src/dev/build/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const flags = getopts(process.argv.slice(0), {
'verbose',
'debug',
],
default: {
'version-qualifier': ''
},
alias: {
v: 'verbose',
d: 'debug',
Expand Down Expand Up @@ -74,6 +77,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}
--debug,-d {dim Turn on debug logging}
Expand Down Expand Up @@ -101,6 +105,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 }) {
export async function getConfig({ isRelease, versionQualifier }) {
const pkgPath = resolve(__dirname, '../../../../package.json');
const pkg = require(pkgPath);
const repoRoot = dirname(pkgPath);
Expand All @@ -32,6 +32,7 @@ export async function getConfig({ isRelease }) {
const platforms = ['darwin', 'linux', 'windows'].map(createPlatform);
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(),
};
}