Skip to content

Commit 15d4c99

Browse files
committed
ci: Add bin-image workflow
Build and push an image containing a static CLI binary for master branch and every release branch and tag. This is a slightly adjusted copy of the bin-image workflow from docker/buildx (by @crazy-max). Co-authored-by: CrazyMax <[email protected]> Signed-off-by: Paweł Gronowski <[email protected]>
1 parent ecf338f commit 15d4c99

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ concurrency:
44
group: ${{ github.workflow }}-${{ github.ref }}
55
cancel-in-progress: true
66

7+
env:
8+
VERSION: ${{ github.ref }}
9+
710
on:
811
workflow_dispatch:
912
push:
@@ -86,6 +89,50 @@ jobs:
8689
path: /tmp/out/*
8790
if-no-files-found: error
8891

92+
bin-image:
93+
runs-on: ubuntu-20.04
94+
if: ${{ github.event_name != 'pull_request' && github.repository == 'docker/cli' }}
95+
steps:
96+
-
97+
name: Checkout
98+
uses: actions/checkout@v4
99+
-
100+
name: Set up QEMU
101+
uses: docker/setup-qemu-action@v3
102+
-
103+
name: Set up Docker Buildx
104+
uses: docker/setup-buildx-action@v3
105+
-
106+
name: Docker meta
107+
id: meta
108+
uses: docker/metadata-action@v5
109+
with:
110+
images: dockereng/cli-bin
111+
tags: |
112+
type=semver,pattern={{version}}
113+
type=ref,event=branch
114+
type=ref,event=pr
115+
type=sha
116+
-
117+
name: Login to DockerHub
118+
if: github.event_name != 'pull_request'
119+
uses: docker/login-action@v3
120+
with:
121+
username: ${{ secrets.DOCKERHUB_CLIBIN_USERNAME }}
122+
password: ${{ secrets.DOCKERHUB_CLIBIN_TOKEN }}
123+
-
124+
name: Build and push image
125+
uses: docker/bake-action@v4
126+
with:
127+
files: |
128+
./docker-bake.hcl
129+
${{ steps.meta.outputs.bake-file }}
130+
targets: bin-image-cross
131+
push: ${{ github.event_name != 'pull_request' }}
132+
set: |
133+
*.cache-from=type=gha,scope=bin-image
134+
*.cache-to=type=gha,scope=bin-image,mode=max
135+
89136
prepare-plugins:
90137
runs-on: ubuntu-20.04
91138
outputs:

docker-bake.hcl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,26 @@ target "e2e-gencerts" {
165165
dockerfile = "./e2e/testdata/Dockerfile.gencerts"
166166
output = ["./e2e/testdata"]
167167
}
168+
169+
target "docker-metadata-action" {
170+
tags = ["cli-bin:local"]
171+
}
172+
173+
target "bin-image" {
174+
inherits = ["binary", "docker-metadata-action"]
175+
output = ["type=docker"]
176+
}
177+
178+
target "bin-image-cross" {
179+
inherits = ["bin-image"]
180+
output = ["type=image"]
181+
platforms = [
182+
"linux/amd64",
183+
"linux/arm/v6",
184+
"linux/arm/v7",
185+
"linux/arm64",
186+
"linux/ppc64le",
187+
"linux/s390x",
188+
"windows/amd64"
189+
]
190+
}

0 commit comments

Comments
 (0)