mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 05:45:46 +00:00
590ae5fa5c
* Onboard consul to use new .release/VERSION file and reproducible actions-go-build * Onboard consul to use new .release/VERSION file and reproducible actions * Onboard consul to use new .release/VERSION file and reproducible actions * fix to consul * Onboard consul to use new .release/VERSION file and reproducible actions * Onboard consul to use new .release/VERSION file and reproducible actions * Onboard consul to use new .release/VERSION file and reproducible actions * test out ent changes * just or testing * Added setup go for build ui * try removing VERSION file out of .release dir * add checkout action for build ui and update checkout version * try no -dev marker * try removing extra ldflags * test version * add back in setup-go step? * Update utils.js read from static VERSION file * remove actions-setup go * add 1.15.0-dev * Using prepare workflow for pre-stable channel workflow * Test prepare workflow * Remove set-product-version branch from release pipeline * Use METADATA in environment * Correct env vars * Remove current branch from build trigger list Co-authored-by: emilymianeil <emilymianeil@gmail.com> Co-authored-by: Sarah <sthompson@hashicorp.com> Co-authored-by: hc-github-team-nomad-core <github-team-nomad-core@hashicorp.com> Co-authored-by: emily neil <63985869+emilymianeil@users.noreply.github.com>
49 lines
1.6 KiB
JavaScript
49 lines
1.6 KiB
JavaScript
const read = require('fs').readFileSync;
|
|
const exec = require('child_process').execSync;
|
|
|
|
// See tests ../node-tests/config/utils.js
|
|
const repositoryYear = function (date = exec('git show -s --format=%ci HEAD')) {
|
|
return date.toString().trim().split('-').shift();
|
|
};
|
|
const repositorySHA = function (sha = exec('git rev-parse --short HEAD')) {
|
|
return sha.toString().trim();
|
|
};
|
|
const binaryVersion = function (repositoryRoot) {
|
|
return function (versionFileContents = read(`${repositoryRoot}/version/VERSION`)) {
|
|
// see /scripts/dist.sh:8
|
|
return versionFileContents
|
|
.toString()
|
|
};
|
|
};
|
|
const env = function ($) {
|
|
return function (flag, fallback) {
|
|
// a fallback value MUST be set
|
|
if (typeof fallback === 'undefined') {
|
|
throw new Error(`Please provide a fallback value for $${flag}`);
|
|
}
|
|
// return the env var if set
|
|
if (typeof $[flag] !== 'undefined') {
|
|
if (typeof fallback === 'boolean') {
|
|
// if we are expecting a boolean JSON parse strings to numbers/booleans
|
|
return !!JSON.parse($[flag]);
|
|
}
|
|
return $[flag];
|
|
}
|
|
// If the fallback is a function call it and return the result.
|
|
// Lazily calling the function means binaries used for fallback don't need
|
|
// to be available if we are sure the environment variables will be set
|
|
if (typeof fallback === 'function') {
|
|
return fallback();
|
|
}
|
|
// just return the fallback value
|
|
return fallback;
|
|
};
|
|
};
|
|
|
|
module.exports = {
|
|
repositoryYear: repositoryYear,
|
|
repositorySHA: repositorySHA,
|
|
binaryVersion: binaryVersion,
|
|
env: env,
|
|
};
|