Skip to content

Commit e514bc1

Browse files
authored
chore(ci)!: update CLI build pipeline (#14360)
The CLI build infrastructure is spread across a few intertwined scripts: `bin/docker-pull-binaries`` prepares binaries from release by loading, running, and extracting the contents of the cli-bin container image. `cli/Dockerfile` is responsible for building all of the binaries. Then, the release and integration workflows build the cli via the `bin/docker-build-cli-bin` script, etc... This change moves all of the packaging concerns into `cli/Dockerfile`, removing the `bin/docker-pull-binaries` and `bin/docker-build-cli-bin` scripts. We introduce two small helper workflow utilities: * `workflows/cli-build.yml`` is a callable workflow that uses modern Github actions infrastructure (e.g., docker/build-push-action) * `actions/cli-setup` downloads and 'installs' the linux-amd64 CLI from the artifact produced by the cli-build workflow. BREAKING CHANGE: We no longer publish a cli-bin image with releases. The typical release artifacts, however, remain unchanged.
1 parent b27cf06 commit e514bc1

File tree

6 files changed

+152
-200
lines changed

6 files changed

+152
-200
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
name: CLI Setup
3+
description: Fetches the Linkerd CLI from an artifact and installs it into the target.
4+
5+
inputs:
6+
artifact-id:
7+
description: The ID of the artifact to download.
8+
required: true
9+
target:
10+
description: The path to install the CLI into.
11+
required: true
12+
13+
runs:
14+
using: composite
15+
steps:
16+
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
17+
with:
18+
artifact-ids: ${{ inputs.artifact-id }}
19+
path: ${{ runner.temp }}/cli
20+
- run: mv ${{ runner.temp }}/cli/linkerd2-cli-*-linux-amd64 ${{ inputs.target }} && chmod 755 ${{ inputs.target }}
21+
shell: bash

.github/workflows/cli-build.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
version:
5+
type: string
6+
required: true
7+
target:
8+
type: string
9+
required: false
10+
default: 'multi-arch'
11+
outputs:
12+
artifact-id:
13+
value: ${{ jobs.build.outputs.artifact-id }}
14+
15+
jobs:
16+
build:
17+
runs-on: ${{ vars.LINKERD2_RUNNER || 'ubuntu-24.04' }}
18+
timeout-minutes: 10
19+
steps:
20+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
21+
- uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435
22+
- uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83
23+
id: build
24+
with:
25+
build-args: |
26+
LINKERD_VERSION=${{ inputs.version }}
27+
target: ${{ inputs.target }}
28+
context: .
29+
file: cli/Dockerfile
30+
cache-from: type=gha,scope=${{ github.ref_name }}-cli
31+
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-cli
32+
push: false
33+
load: false
34+
outputs: type=local,dest=.
35+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
36+
id: upload
37+
with:
38+
name: cli-bin-${{ inputs.version }}-${{ inputs.target }}
39+
path: linkerd2-cli-${{ inputs.version }}-*
40+
outputs:
41+
artifact-id: ${{ steps.upload.outputs.artifact-id }}

.github/workflows/integration.yml

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -65,28 +65,10 @@ jobs:
6565
build-cli:
6666
needs: meta
6767
if: needs.meta.outputs.changed == 'true'
68-
runs-on: ${{ vars.LINKERD2_RUNNER || 'ubuntu-24.04' }}
69-
timeout-minutes: 15
70-
steps:
71-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
72-
- uses: ./.github/actions/docker-build
73-
id: build
74-
with:
75-
docker-registry: ${{ env.DOCKER_REGISTRY }}
76-
docker-target: linux-amd64
77-
component: cli-bin
78-
tag: ${{ needs.meta.outputs.tag }}
79-
- name: Extract CLI binary
80-
run: |
81-
mkdir -p /home/runner/archives
82-
id=$(docker create '${{ steps.build.outputs.image }}')
83-
docker cp "$id:/out/linkerd-linux-amd64" /home/runner/archives/linkerd
84-
v=$(/home/runner/archives/linkerd version --short --client)
85-
[[ "$v" == '${{ needs.meta.outputs.tag }}' ]] || exit 1
86-
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
87-
with:
88-
name: image-archives-cli
89-
path: /home/runner/archives
68+
uses: ./.github/workflows/cli-build.yml
69+
with:
70+
version: ${{ needs.meta.outputs.tag }}
71+
target: linux-amd64
9072

9173
##
9274
## Core: Test the core control plane
@@ -146,9 +128,12 @@ jobs:
146128
pattern: image-archives-*
147129
path: image-archives
148130
merge-multiple: true
149-
- run: cp image-archives/linkerd "$HOME" && chmod 755 "$HOME/linkerd"
150131
- run: find image-archives -ls
151-
- run: bin/tests --images archive --cleanup-docker --name ${{ matrix.test }} "$HOME/linkerd"
132+
- uses: ./.github/actions/cli-setup
133+
with:
134+
artifact-id: ${{ needs.build-cli.outputs.artifact-id }}
135+
target: ${{ runner.temp }}/linkerd
136+
- run: bin/tests --images archive --cleanup-docker --name ${{ matrix.test }} ${{ runner.temp }}/linkerd
152137
env:
153138
LINKERD_DOCKER_REGISTRY: ${{ env.DOCKER_REGISTRY }}
154139
TAG: ${{ needs.meta.outputs.tag }}
@@ -196,7 +181,10 @@ jobs:
196181
path: image-archives
197182
merge-multiple: true
198183
- run: find image-archives -ls
199-
- run: cp image-archives/linkerd "$HOME" && chmod 755 "$HOME/linkerd"
184+
- uses: ./.github/actions/cli-setup
185+
with:
186+
artifact-id: ${{ needs.build-cli.outputs.artifact-id }}
187+
target: ${{ runner.temp }}/linkerd
200188
- name: Setup deps
201189
shell: bash
202190
run: |
@@ -217,7 +205,7 @@ jobs:
217205
- run: docker load <image-archives/controller.tar
218206
- run: docker load <image-archives/proxy.tar
219207
- run: docker image ls
220-
- run: just linkerd-tag='${{ needs.meta.outputs.tag }}' linkerd-exec="$HOME/linkerd" linkerd-install
208+
- run: just linkerd-tag='${{ needs.meta.outputs.tag }}' linkerd-exec="${{ runner.temp }}/linkerd" linkerd-install
221209
- name: Load images
222210
run: |
223211
# Image loading is flakey in CI, so retry!
@@ -295,9 +283,12 @@ jobs:
295283
pattern: image-archives-*
296284
path: image-archives
297285
merge-multiple: true
298-
- run: cp image-archives/linkerd "$HOME" && chmod 755 "$HOME/linkerd"
299-
- run: ls -l image-archives/linkerd
300-
- run: bin/tests --images archive --cleanup-docker --name '${{ matrix.integration_test }}' "$HOME/linkerd"
286+
- run: find image-archives -ls
287+
- uses: ./.github/actions/cli-setup
288+
with:
289+
artifact-id: ${{ needs.build-cli.outputs.artifact-id }}
290+
target: ${{ runner.temp }}/linkerd
291+
- run: bin/tests --images archive --cleanup-docker --name '${{ matrix.integration_test }}' ${{ runner.temp }}/linkerd
301292
env:
302293
LINKERD_DOCKER_REGISTRY: ${{ env.DOCKER_REGISTRY }}
303294

@@ -320,9 +311,11 @@ jobs:
320311
pattern: image-archives-*
321312
path: image-archives
322313
merge-multiple: true
323-
- run: cp image-archives/linkerd "$HOME" && chmod 755 "$HOME/linkerd"
324-
- run: ls -l image-archives/linkerd
325-
- run: bin/tests --images archive --cleanup-docker --name viz "$HOME/linkerd"
314+
- uses: ./.github/actions/cli-setup
315+
with:
316+
artifact-id: ${{ needs.build-cli.outputs.artifact-id }}
317+
target: ${{ runner.temp }}/linkerd
318+
- run: bin/tests --images archive --cleanup-docker --name viz ${{ runner.temp }}/linkerd
326319
env:
327320
LINKERD_DOCKER_REGISTRY: ${{ env.DOCKER_REGISTRY }}
328321

@@ -357,8 +350,11 @@ jobs:
357350
pattern: image-archives-*
358351
path: image-archives
359352
merge-multiple: true
360-
- run: cp image-archives/linkerd "$HOME" && chmod 755 "$HOME/linkerd"
361-
- run: ls -l image-archives/linkerd
353+
- run: find image-archives -ls
354+
- uses: ./.github/actions/cli-setup
355+
with:
356+
artifact-id: ${{ needs.build-cli.outputs.artifact-id }}
357+
target: ${{ runner.temp }}/linkerd
362358
- name: Setup deps
363359
shell: bash
364360
run: |

.github/workflows/release.yml

Lines changed: 21 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ jobs:
4040
strategy:
4141
matrix:
4242
component:
43-
- cli-bin
4443
- controller
4544
- debug
4645
- jaeger-webhook
@@ -72,26 +71,12 @@ jobs:
7271
- run: cosign sign '${{ steps.build.outputs.digest }}'
7372
env:
7473
COSIGN_YES: true
75-
- name: Create artifact with CLI
76-
# windows_static_cli_tests below needs this because it can't create linux containers
77-
# inside windows
78-
if: matrix.component == 'cli-bin'
79-
env:
80-
ARCHIVES: /home/runner/archives
81-
DOCKER_TARGET: windows
82-
run: |
83-
bin/docker-pull-binaries "$TAG"
84-
mkdir -p "$ARCHIVES"
85-
cp -r "$PWD/target/release/linkerd2-cli-$TAG-windows.exe" "$ARCHIVES/linkerd-windows.exe"
86-
# `with.path` values do not support environment variables yet, so an
87-
# absolute path is used here.
88-
# https://github.com/actions/upload-artifact/issues/8
89-
- name: Upload artifact
90-
if: matrix.component == 'cli-bin'
91-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
92-
with:
93-
name: image-archives-cli
94-
path: /home/runner/archives
74+
75+
cli:
76+
needs: tag
77+
uses: ./.github/workflows/cli-build.yml
78+
with:
79+
version: ${{ needs.tag.outputs.tag }}
9580

9681
windows_static_cli_tests:
9782
name: Static CLI tests (windows)
@@ -114,7 +99,7 @@ jobs:
11499

115100
integration_tests:
116101
name: Integration tests
117-
needs: [tag, docker_build]
102+
needs: [tag, cli, docker_build]
118103
strategy:
119104
matrix:
120105
integration_test:
@@ -136,42 +121,34 @@ jobs:
136121
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5
137122
with:
138123
go-version: "1.24"
139-
- name: Set environment variables from scripts
124+
- uses: ./.github/actions/cli-setup
125+
with:
126+
artifact-id: ${{ needs.cli.outputs.artifact-id }}
127+
target: ${{ runner.temp }}/linkerd
128+
- run: echo TAG="${{ needs.tag.outputs.tag }}" >> "$GITHUB_ENV"
129+
- name: Validate the CLI version matches the current build tag.
140130
run: |
141-
TAG='${{ needs.tag.outputs.tag }}'
142-
CMD="$PWD/target/release/linkerd2-cli-$TAG-linux-amd64"
143-
echo "CMD=$CMD" >> "$GITHUB_ENV"
144-
echo "TAG=$TAG" >> "$GITHUB_ENV"
145-
- name: Run integration tests
131+
[[ "$TAG" == "$(${{ runner.temp }}/linkerd version --short --client)" ]]
132+
- run: bin/tests --images preload --name ${{ matrix.integration_test }} "${{ runner.temp }}/linkerd"
146133
env:
147134
LINKERD_DOCKER_REGISTRY: ${{ env.DOCKER_REGISTRY }}
148-
run: |
149-
bin/docker-pull-binaries "$TAG"
150-
# Validate the CLI version matches the current build tag.
151-
[[ "$TAG" == "$($CMD version --short --client)" ]]
152-
bin/tests --images preload --name ${{ matrix.integration_test }} "$CMD"
153135

154136
gh_release:
155137
name: Create GH release
156138
needs:
157139
- tag
140+
- cli
158141
- integration_tests
159142
timeout-minutes: 30
160143
runs-on: ${{ vars.LINKERD2_RUNNER || 'ubuntu-24.04' }}
161144
permissions:
162145
contents: write
163146
steps:
164147
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
165-
# - name: Download choco package
166-
# if: startsWith(github.ref, 'refs/tags/stable')
167-
# uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
168-
# with:
169-
# name: choco
170-
# path: choco
171-
- name: Pull CLI binaries
172-
run: DOCKER_TARGET=multi-arch bin/docker-pull-binaries '${{ needs.tag.outputs.tag }}'
173-
# v=${TAG#"stable-"}
174-
# mv choco/linkerd.*.nupkg "target/release/linkerd2-cli-stable-$v.nupkg" || true
148+
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
149+
with:
150+
artifact-ids: ${{ needs.cli.outputs.artifact-id }}
151+
path: cli
175152
- name: Create release
176153
id: create_release
177154
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8
@@ -181,10 +158,7 @@ jobs:
181158
draft: false
182159
prerelease: false
183160
files: |
184-
./target/release/linkerd2-cli-*-darwin*
185-
./target/release/linkerd2-cli-*-linux-*
186-
./target/release/linkerd2-cli-*-windows.*
187-
./target/release/linkerd2-cli-*.nupkg
161+
./cli/linkerd2-cli-*
188162
189163
website_publish:
190164
name: Linkerd website publish

bin/docker-pull-binaries

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)