embed git commit info in nodeinfo&c
this will make it much easier to debug problems for instances that run
unreleased versions!
when run on a tagged commit, `git describe --tags` prints the tag name;
otherwise it prints something like `2025.4.3-32-ga4c0ef824c` which
means:
- the closest tag is 2025.4.3
- there are 32 commits between that tag and this commit
- this commit's id is `a4c0ef824c` (the `g` is just a prefix)
notice that the version as reported by the frontend (in
`/about-sharkey` for example) is _not_ changed, that one is still
sourced from `/package.json` (so, for example, you don't get a
"sharkey has been updated!" pop-up every time)
This commit is contained in:
parent
c4c6aea939
commit
872258b04c
4 changed files with 16 additions and 5 deletions
|
|
@ -51,7 +51,7 @@ function greet() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bootLogger.info('Welcome to Sharkey!');
|
bootLogger.info('Welcome to Sharkey!');
|
||||||
bootLogger.info(`Sharkey v${meta.version}`, null, true);
|
bootLogger.info(`Sharkey v${meta.gitVersion ?? meta.version}`, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -91,7 +91,7 @@ export async function masterMain() {
|
||||||
maxBreadcrumbs: 0,
|
maxBreadcrumbs: 0,
|
||||||
|
|
||||||
// Set release version
|
// Set release version
|
||||||
release: 'Sharkey@' + meta.version,
|
release: 'Sharkey@' + (meta.gitVersion ?? meta.version),
|
||||||
|
|
||||||
...config.sentryForBackend.options,
|
...config.sentryForBackend.options,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ export async function workerMain() {
|
||||||
maxBreadcrumbs: 0,
|
maxBreadcrumbs: 0,
|
||||||
|
|
||||||
// Set release version
|
// Set release version
|
||||||
release: "Sharkey@" + meta.version,
|
release: "Sharkey@" + (meta.gitVersion ?? meta.version),
|
||||||
|
|
||||||
...config.sentryForBackend.options,
|
...config.sentryForBackend.options,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -397,7 +397,7 @@ export function loadConfig(): Config {
|
||||||
applyEnvOverrides(config);
|
applyEnvOverrides(config);
|
||||||
|
|
||||||
const url = tryCreateUrl(config.url ?? process.env.MISSKEY_URL ?? '');
|
const url = tryCreateUrl(config.url ?? process.env.MISSKEY_URL ?? '');
|
||||||
const version = meta.version;
|
const version = meta.gitVersion ?? meta.version;
|
||||||
const host = url.host;
|
const host = url.host;
|
||||||
const hostname = url.hostname;
|
const hostname = url.hostname;
|
||||||
const scheme = url.protocol.replace(/:$/, '');
|
const scheme = url.protocol.replace(/:$/, '');
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,24 @@
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const packageJsonPath = __dirname + '/../package.json'
|
const packageJsonPath = __dirname + '/../package.json'
|
||||||
|
const { execFileSync } = require('node:child_process');
|
||||||
|
|
||||||
function build() {
|
function build() {
|
||||||
|
let gitVersion;
|
||||||
|
try {
|
||||||
|
gitVersion = execFileSync('git', ['describe', '--tags'], {
|
||||||
|
encoding: 'utf-8',
|
||||||
|
});
|
||||||
|
gitVersion = gitVersion.trim();
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("couldn't get git commit details, ignoring",e);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const json = fs.readFileSync(packageJsonPath, 'utf-8')
|
const json = fs.readFileSync(packageJsonPath, 'utf-8')
|
||||||
const meta = JSON.parse(json);
|
const meta = JSON.parse(json);
|
||||||
fs.mkdirSync(__dirname + '/../built', { recursive: true });
|
fs.mkdirSync(__dirname + '/../built', { recursive: true });
|
||||||
fs.writeFileSync(__dirname + '/../built/meta.json', JSON.stringify({ version: meta.version }), 'utf-8');
|
fs.writeFileSync(__dirname + '/../built/meta.json', JSON.stringify({ version: meta.version, gitVersion }), 'utf-8');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue