Skip to content

Commit

Permalink
[build] Use build sha instead of build number for CDN assets (elastic…
Browse files Browse the repository at this point in the history
…#176186)

elastic#175898 updates routes to cache
bust using the build checksum instead of build number. This updates the
directory structure of the CDN assets archive accordingly.

```
kibana-8.13.0-SNAPSHOT-cdn-assets
└── e96cc06
    ├── bundles
    │   ├── core
    │   ├── kbn-monaco
    │   ├── kbn-ui-shared-deps-npm
    │   ├── kbn-ui-shared-deps-src
    │   └── plugin
    └── ui
        ├── favicons
        ├── fonts
        ├── legacy_dark_theme.css
        ├── legacy_dark_theme.min.css
        ├── legacy_light_theme.css
        └── legacy_light_theme.min.css

11 directories, 4 files
```
  • Loading branch information
jbudz authored and CoenWarmer committed Feb 15, 2024
1 parent f2b6caa commit bf07f0d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/dev/build/lib/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const config = new Config(
{
buildNumber: 1234,
buildSha: 'abcd1234',
buildShaShort: 'abcd',
buildVersion: '8.0.0',
buildDate: '2023-05-15T23:12:09+0000',
},
Expand Down
7 changes: 7 additions & 0 deletions src/dev/build/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ export class Config {
return this.versionInfo.buildSha;
}

/**
* Get the first 12 digits of the git sha for this build
*/
getBuildShaShort() {
return this.versionInfo.buildShaShort;
}

/**
* Get the ISO 8601 date for this build
*/
Expand Down
1 change: 1 addition & 0 deletions src/dev/build/lib/version_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export async function getVersionInfo({ isRelease, versionQualifier, pkg }: Optio

return {
buildSha,
buildShaShort: buildSha.slice(0, 12),
buildVersion,
buildNumber: await getBuildNumber(),
buildDate: new Date().toISOString(),
Expand Down
6 changes: 3 additions & 3 deletions src/dev/build/tasks/create_cdn_assets_task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export const CreateCdnAssets: Task = {

async run(config, log, build) {
const buildSource = build.resolvePath();
const buildNum = config.getBuildNumber();
const buildSha = config.getBuildShaShort();
const buildVersion = config.getBuildVersion();
const assets = config.resolveFromRepo('build', 'cdn-assets');
const bundles = resolve(assets, String(buildNum), 'bundles');
const bundles = resolve(assets, buildSha, 'bundles');

await del(assets);
await mkdirp(assets);
Expand Down Expand Up @@ -83,7 +83,7 @@ export const CreateCdnAssets: Task = {
// packages/core/apps/core-apps-server-internal/src/core_app.ts
await copyAll(
resolve(buildSource, 'node_modules/@kbn/core-apps-server-internal/assets'),
resolve(assets, 'ui')
resolve(assets, buildSha, 'ui')
);

await compressTar({
Expand Down
1 change: 1 addition & 0 deletions src/dev/build/tasks/fetch_agent_versions_list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const config = new Config(
{
buildNumber: 1234,
buildSha: 'abcd1234',
buildShaShort: 'abcd',
buildVersion: '8.0.0',
buildDate: '2023-05-15T23:12:09.000Z',
},
Expand Down

0 comments on commit bf07f0d

Please sign in to comment.