Fix detecting branch in CI and don't include remote-config.json in app bundle

This commit is contained in:
Samuel Elliott 2023-06-02 01:49:43 +01:00
parent 49b6d0dce2
commit c3016f9889
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
4 changed files with 15 additions and 6 deletions

View File

@ -100,7 +100,8 @@
"!dist/app/package",
"!**/node_modules/**/*",
"resources/app",
"resources/common"
"resources/common",
"!resources/common/remote-config.json"
],
"asar": false,
"extraMetadata": {

View File

@ -11,8 +11,8 @@ const git = (...args) => execFile('git', args, options).then(({stdout}) => stdou
const pkg = JSON.parse(await fs.readFile(new URL('../../package.json', import.meta.url), 'utf-8'));
const [revision, branch_str, changed_files_str, tags_str, commit_count_str] = await Promise.all([
git('rev-parse', 'HEAD'),
git('rev-parse', '--abbrev-ref', 'HEAD'),
process.env.CI_COMMIT_SHA || git('rev-parse', 'HEAD'),
process.env.CI_COMMIT_BRANCH || git('rev-parse', '--abbrev-ref', 'HEAD'),
git('diff', '--name-only', 'HEAD'),
git('log', '--tags', '--no-walk', '--pretty=%D'),
git('rev-list', '--count', 'HEAD'),

View File

@ -10,8 +10,8 @@ const git = (...args) => execFile('git', args, options).then(({stdout}) => stdou
const pkg = JSON.parse(await fs.readFile(new URL('../../package.json', import.meta.url), 'utf-8'));
const [revision, branch, changed_files] = await Promise.all([
git('rev-parse', 'HEAD'),
git('rev-parse', '--abbrev-ref', 'HEAD'),
process.env.CI_COMMIT_SHA || git('rev-parse', 'HEAD'),
process.env.CI_COMMIT_BRANCH || git('rev-parse', '--abbrev-ref', 'HEAD'),
git('diff', '--name-only', 'HEAD'),
]);

View File

@ -18,6 +18,14 @@ const default_remote_config =
JSON.parse(fs.readFileSync(path.join(dir, 'resources', 'common', 'remote-config.json'), 'utf-8'));
const git = (() => {
if (process.env.GITLAB_CI && process.env.CI_COMMIT_SHA) {
return {
revision: process.env.CI_COMMIT_SHA,
branch: process.env.CI_COMMIT_BRANCH || null,
changed_files: [],
};
}
try {
fs.statSync(path.join(dir, '.git'));
} catch (err) {
@ -34,7 +42,7 @@ const git = (() => {
branch: branch && branch !== 'HEAD' ? branch : null,
changed_files: changed_files.length ? changed_files.split('\n') : [],
};
})();;
})();
// If CI_COMMIT_TAG is set this is a tagged version for release
const release = process.env.NODE_ENV === 'production' ? process.env.CI_COMMIT_TAG || null : null;