Skip to content

Commit bb38b35

Browse files
authored
1 parent f5ad145 commit bb38b35

File tree

4 files changed

+80
-4
lines changed

4 files changed

+80
-4
lines changed
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
steps:
2+
- group: "Build Bacalhau Image"
3+
steps:
4+
- trigger: "bacalhau-golang"
5+
label: ":rocket: Build CLI "
6+
env:
7+
TRIGGER_JOB_ID: "${BUILDKITE_JOB_ID}"
8+
build:
9+
message: "${BUILDKITE_MESSAGE}"
10+
commit: "${BUILDKITE_COMMIT}"
11+
branch: "${BUILDKITE_BRANCH}"
12+
13+
- wait: ~
14+
- label: ":fish: Build Bacalhau Image"
15+
command: "./buildkite/scripts/build_bacalhau_image.sh"

buildkite/pipelines/bacalhau-golang.yaml

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
# build.pull_request.labels includes "build/go" ||
55
# build.pull_request.labels includes "build/golang" ||
66
# build.tag != null
7-
87
steps:
98
- label: ":golang: Lint"
109
command: "./buildkite/scripts/lint.sh"
1110
key: "lint"
1211
agents:
13-
queue: "buildkite-hosted-linux-medium"
12+
queue: "buildkite-hosted-linux-large"
1413

1514
- group: ":package: Build Tarball"
1615
key: "build-tarball"
@@ -64,9 +63,14 @@ steps:
6463

6564
- wait: ~
6665

67-
# Release CLI is only triggered if the tag is present.
66+
- label: ":docker: Build & Publish Bacalhau Image"
67+
command: "./buildkite/scripts/bacalhau_image.sh"
68+
key: "publish-bacalhau-image"
69+
agents:
70+
queue: "buildkite-hosted-linux-large"
71+
if: build.tag != null
6872

6973
- label: ":rocket: Release CLI"
7074
command: "./buildkite/scripts/release_cli.sh"
7175
key: "release-cli"
72-
if: build.tag != ""
76+
if: build.tag != null

buildkite/scripts/bacalhau_image.sh

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
set_environment_variables() {
6+
export GIT_TAG=$(git describe --tags --always)
7+
}
8+
9+
docker_login() {
10+
export GHCR_PAT=$(buildkite-agent secret get GHCR_PAT)
11+
echo $GHCR_PAT | docker login ghcr.io -u bacalhau-infra-bot --password-stdin
12+
}
13+
14+
docker_context_create() {
15+
docker context create buildx-build
16+
docker buildx create --use buildx-build
17+
}
18+
19+
download_and_extract_artifact() {
20+
local arch=$1
21+
local tarball="bacalhau_${GIT_TAG}_linux_${arch}.tar.gz"
22+
local target_dir="bin/linux/${arch}"
23+
24+
mkdir -p "$target_dir"
25+
if ! tar xf "$tarball" -C "$target_dir"; then
26+
echo "Error: Failed to extract $tarball" >&2
27+
exit 1
28+
fi
29+
echo "Extracted $tarball to $target_dir folder"
30+
}
31+
32+
download_artifacts() {
33+
if ! buildkite-agent artifact download "*.*" . --build "$BUILDKITE_BUILD_ID"; then
34+
echo "Error: Failed to download artifacts from build pipeline" >&2
35+
exit 1
36+
fi
37+
echo "Downloaded artifacts from build pipeline"
38+
39+
download_and_extract_artifact "amd64"
40+
download_and_extract_artifact "arm64"
41+
}
42+
43+
main() {
44+
if [ -n "${BUILDKITE_TAG:-}" ]; then
45+
set_environment_variables
46+
docker_context_create
47+
download_artifacts
48+
make build-bacalhau-image
49+
docker_login
50+
make push-bacalhau-image
51+
else
52+
echo "Skipping artifact download: BUILDKITE_TAG is not present"
53+
fi
54+
}
55+
56+
main

buildkite/scripts/build_tarball.sh

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
export PRIVATE_PEM_B64=$(buildkite-agent secret get PRIVATE_PEM_B64)
44
export PUBLIC_PEM_B64=$(buildkite-agent secret get PUBLIC_PEM_B64)
5+
export PRIVATE_KEY_PASSPHRASE_B64=$(buildkite-agent secret get PRIVATE_KEY_PASSPHRASE_B64)
56
echo "$PRIVATE_PEM_B64" | base64 --decode > /tmp/private.pem
67
echo "$PUBLIC_PEM_B64" | base64 --decode > /tmp/public.pem
78
export PRIVATE_KEY_PASSPHRASE="$(echo $PRIVATE_KEY_PASSPHRASE_B64 | base64 --decode)"

0 commit comments

Comments
 (0)