Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/custom-registries.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-
https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-arm64
```

## `buf`

Buf releases are downloaded from:

- `https://github.com/bufbuild/buf/releases`

Samples:

```txt
https://github.com/bufbuild/buf/releases/download/v1.67.0/buf-Linux-x84_64.tar.gz
https://github.com/bufbuild/buf/releases/download/v1.67.0/buf-Linux-aarch64.tar.gz
https://github.com/bufbuild/buf/releases/download/v1.67.0/sha256.txt
```

## `bun`

Bun releases are downloaded from:
Expand Down
2 changes: 2 additions & 0 deletions src/cli/install-tool/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from '../services/index.ts';
import { ApkoInstallService } from '../tools/apko.ts';
import { BazeliskInstallService } from '../tools/bazelisk.ts';
import { BufInstallService } from '../tools/buf.ts';
import { BunInstallService } from '../tools/bun.ts';
import { DartInstallService } from '../tools/dart/index.ts';
import { DenoInstallService } from '../tools/deno.ts';
Expand Down Expand Up @@ -132,6 +133,7 @@ async function prepareInstallContainer(): Promise<Container> {
container.bind(INSTALL_TOOL_TOKEN).to(BazeliskInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(BuildxInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(BunInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(BufInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(CabalInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(CocoapodsInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(ConanInstallService);
Expand Down
66 changes: 66 additions & 0 deletions src/cli/tools/buf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import fs from 'node:fs/promises';
import { join } from 'node:path';
import { injectFromHierarchy, injectable } from 'inversify';
import { BaseInstallService } from '../install-tool/base-install.service.ts';

@injectable()
@injectFromHierarchy()
export class BufInstallService extends BaseInstallService {
readonly name = 'buf';

private get ghArch(): string {
switch (this.envSvc.arch) {
case 'arm64':
return 'aarch64';
case 'amd64':
return 'x86_64';
}
}

override async install(version: string): Promise<void> {
/**
* @example
* @see {@href https://github.com/bufbuild/buf/releases/tag/v1.67.0}
*/
const baseUrl = `https://github.com/bufbuild/buf/releases/download/v${version}/`;

const filename = `buf-Linux-${this.ghArch}.tar.gz`;

const checksumFile = await this.http.download({
url: `${baseUrl}sha256.txt`,
});
const expectedChecksum = (await fs.readFile(checksumFile, 'utf-8'))
.split('\n')
.find((l) => l.includes(filename))
?.split(' ')[0];

const file = await this.http.download({
url: `${baseUrl}${filename}`,
checksumType: 'sha256',
expectedChecksum,
});

await this.pathSvc.ensureToolPath(this.name);

const path = join(
await this.pathSvc.createVersionedToolPath(this.name, version),
'bin',
);
await fs.mkdir(path);
await this.compress.extract({
file,
cwd: path,
strip: 1,
files: ['bin/buf'],
});
}

override async link(version: string): Promise<void> {
const src = join(this.pathSvc.versionedToolPath(this.name, version), 'bin');
await this.shellwrapper({ srcDir: src });
}

override async test(_version: string): Promise<void> {
await this._spawn(this.name, ['--version']);
}
}
1 change: 1 addition & 0 deletions src/cli/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const NoPrepareTools = [
'apko',
'bazelisk',
'bower',
'buf',
'buildx',
'bun',
'bundler',
Expand Down
3 changes: 3 additions & 0 deletions test/Dockerfile.distro
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ FROM build AS test
# renovate: datasource=github-releases packageName=bazelbuild/bazelisk
RUN install-tool bazelisk v1.28.1

# renovate: datasource=github-releases packageName=bufbuild/buf
RUN install-tool buf v1.67.0

# renovate: datasource=npm
RUN install-tool bun 1.3.11

Expand Down
5 changes: 4 additions & 1 deletion test/latest/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,16 @@ RUN prepare-tool all
RUN set -ex; [ -d /usr/local/erlang ] && echo "works" || exit 1;

#--------------------------------------
# test: bazelisk, bun, deno, devbox, helmfile, kustomize, skopeo, tofu, vendir
# test: bazelisk, buf, bun, deno, devbox, helmfile, kustomize, skopeo, tofu, vendir
#--------------------------------------
FROM base AS teste

# renovate: datasource=github-releases packageName=bazelbuild/bazelisk
RUN install-tool bazelisk v1.28.1

# renovate: datasource=github-releases packageName=bufbuild/buf
RUN install-tool buf v1.67.0

# renovate: datasource=npm
RUN install-tool bun 1.3.11

Expand Down
3 changes: 3 additions & 0 deletions test/latest/Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ RUN install-tool vendir v0.45.2
#--------------------------------------
FROM base AS test-others

# renovate: datasource=github-releases packageName=bufbuild/buf
RUN install-tool buf v1.67.0

# renovate: datasource=github-releases packageName=kubernetes/kubernetes
RUN install-tool kubectl v1.35.3

Expand Down
Loading