Skip to content

Commit d469be2

Browse files
authored
Merge pull request #4752 from vvoland/ci-bin-image
ci: Add bin-image workflow
2 parents 708d113 + 15d4c99 commit d469be2

4 files changed

Lines changed: 78 additions & 1 deletion

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:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,4 @@ FROM scratch AS plugins
124124
COPY --from=build-plugins /out .
125125

126126
FROM scratch AS binary
127-
COPY --from=build /out .
127+
COPY --from=build /out/docker /docker

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+
}

scripts/build/.variables

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ else
2222
BUILDTIME=${BUILDTIME:-$(TZ=UTC date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +"%Y-%m-%dT%H:%M:%SZ")}
2323
fi
2424

25+
case "$VERSION" in
26+
refs/tags/v*) VERSION=${VERSION#refs/tags/v} ;;
27+
refs/tags/*) VERSION=${VERSION#refs/tags/} ;;
28+
refs/heads/*) VERSION=$(echo "${VERSION#refs/heads/}" | sed -r 's#/+#-#g') ;;
29+
refs/pull/*) VERSION=pr-$(echo "$VERSION" | grep -o '[0-9]\+') ;;
30+
esac
31+
2532
GOOS="$(go env GOOS)"
2633
GOARCH="$(go env GOARCH)"
2734
if [ "${GOARCH}" = "arm" ]; then

0 commit comments

Comments
 (0)