create_build_info_ts

This script will create a file with the given name containing build information accessible by TypeScript code.

The value of build.id is depending on where this script is run:

locally

the current timestamp

AppVeyor

the value of the APPVEYOR_BUILD_ID environment variable

Bitbucket

the value of the BITBUCKET_BUILD_NUMBER environment variable

CircleCI

the value of the CIRCLE_WORKFLOW_ID environment variable

GitHub

the value of the GITHUB_RUN_ID environment variable

GitLab

the value of the CI_PIPELINE_ID environment variable

Jenkins

the value of the BUILD_ID environment variable

TeamCity

the value of the BUILD_NUMBER environment variable

Travis

the value of the TRAVIS_BUILD_ID environment variable

The value of build.time is either the value of the SOURCE_DATE_EPOCH environment variable or the current timestamp.

Usage

$ scripts/web/create_build_info_ts.sh src/build-info.ts

src/build-info.ts
export type BuildInfo = {
// ...
};

export const buildInfo: BuildInfo = {
  build: {
    id: '1710116078',
    time: '2024-03-11T00:14:38Z',
  },
  git: {
    branch: 'main',
    commit: {
      id: '95189bb08fa918576f10339eb15303d152ade2aa',
      time: '2024-03-10T23:52:54Z',
    },
  },
};