diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index db5c9357e3..54f77764f0 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -155,6 +155,8 @@ export type Config = { signToActivityPubGet: boolean | undefined; version: string; + gitDescribe: string; + gitCommit: string; publishTarballInsteadOfProvideRepositoryUrl: boolean; setupPassword: string | undefined; host: string; @@ -218,7 +220,7 @@ export function loadConfig(): Config { const config = yaml.load(fs.readFileSync(path, 'utf-8')) as Source; const url = tryCreateUrl(config.url ?? process.env.MISSKEY_URL ?? ''); - const version = meta.version; + const { version, gitDescribe, gitCommit } = meta; const host = url.host; const hostname = url.hostname; const scheme = url.protocol.replace(/:$/, ''); @@ -236,6 +238,8 @@ export function loadConfig(): Config { return { version, + gitCommit, + gitDescribe, publishTarballInsteadOfProvideRepositoryUrl: !!config.publishTarballInsteadOfProvideRepositoryUrl, setupPassword: config.setupPassword, url: url.origin, diff --git a/packages/backend/src/server/NodeinfoServerService.ts b/packages/backend/src/server/NodeinfoServerService.ts index 9a641007ee..740d6b6a58 100644 --- a/packages/backend/src/server/NodeinfoServerService.ts +++ b/packages/backend/src/server/NodeinfoServerService.ts @@ -105,6 +105,8 @@ export class NodeinfoServerService { name: meta.maintainerName, email: meta.maintainerEmail, }, + gitCommit: this.config.gitCommit, + gitDescribe: this.config.gitDescribe, langs: meta.langs, tosUrl: meta.termsOfServiceUrl, privacyPolicyUrl: meta.privacyPolicyUrl, diff --git a/scripts/build-pre.js b/scripts/build-pre.js index a90d53c75d..d269754196 100644 --- a/scripts/build-pre.js +++ b/scripts/build-pre.js @@ -4,14 +4,23 @@ */ const fs = require('fs'); +const child_process = require('child_process'); const packageJsonPath = __dirname + '/../package.json' function build() { try { + const gitDescribe = child_process.execSync('git describe --tags --always').toString().trim(); + const gitCommit = child_process.execSync('git rev-parse HEAD').toString().trim(); const json = fs.readFileSync(packageJsonPath, 'utf-8') const meta = JSON.parse(json); 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, + gitCommit: gitCommit, + gitDescribe: gitDescribe, + }), 'utf-8'); } catch (e) { console.error(e) }