Skip to content

Commit

Permalink
Added a comprehensive version string to a32nx_build_info.json
Browse files Browse the repository at this point in the history
  • Loading branch information
frankkopp committed Dec 18, 2022
1 parent 33ef173 commit 90f6369
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions scripts/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,42 @@ const GITHUB_ACTOR = process.env['GITHUB_ACTOR'] ?? evaluate('git log -1 --prett
const GITHUB_EVENT_NAME = process.env['GITHUB_EVENT_NAME'] ?? 'manual';
const GITHUB_REF = process.env['GITHUB_REF'] ?? evaluate('git show-ref HEAD').replace(/.+\//, '');
const GITHUB_SHA = process.env['GITHUB_SHA'] ?? evaluate('git show-ref -s HEAD');
const GIT_COMMIT_SHA = GITHUB_SHA.substring(0, 9);
const GITHUB_RELEASE_PRETTY_NAME = (require('./pretty-release-name'))();
const GITHUB_BUILT = evaluate('date -u -Iseconds');

const isPullRequest = process.env.GITHUB_REF && process.env.GITHUB_REF.startsWith('refs/pull/');
let GIT_BRANCH;
if (isPullRequest) {
GIT_BRANCH = process.env.GITHUB_REF.match('^refs/pull/([0-9]+)/.*$')[1];
} else {
GIT_BRANCH = process.env.GITHUB_REF_NAME
? process.env.GITHUB_REF_NAME
: evaluate('git rev-parse --abbrev-ref HEAD');
}
const edition = require('../package.json').edition;

let preFix;
if (edition === 'stable') {
preFix = 'rel';
} else if (GIT_BRANCH === 'master') {
preFix = 'dev';
} else if (GIT_BRANCH === 'experimental') {
preFix = 'exp';
} else {
preFix = `${GIT_BRANCH}`;
}

const VERSION = require('../package.json').version + `-${preFix}` + `.${GIT_COMMIT_SHA}`;

const object = {
built: GITHUB_BUILT,
ref: GITHUB_REF,
sha: GITHUB_SHA,
actor: GITHUB_ACTOR,
event_name: GITHUB_EVENT_NAME ?? 'manual',
pretty_release_name: GITHUB_RELEASE_PRETTY_NAME,
version: VERSION,
};

const outDirArg = process.argv[2];
Expand Down

0 comments on commit 90f6369

Please sign in to comment.