Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 051cf5c

Browse files
Merge pull request #93 from docker/manage_binary_names
Use platform specific binary names for release
2 parents de36406 + 5ddd2f8 commit 051cf5c

4 files changed

Lines changed: 13 additions & 8 deletions

File tree

.github/workflows/release-weekly-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797
- name: Ship it
9898
uses: ncipollo/release-action@v1
9999
with:
100-
artifacts: "dist/docker-scan-macos-latest/*, dist/docker-scan-linux-latest/*, dist/docker-scan-windows-latest/*"
100+
artifacts: "dist/*/*"
101101
prerelease: true
102102
draft: true
103103
token: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
6969
# SCAN
7070
####
7171
FROM scratch AS scan
72-
COPY --from=build /go/src/github.com/docker/scan-cli-plugin/bin/docker-scan /docker-scan
72+
ARG TARGETOS
73+
COPY --from=build /go/src/github.com/docker/scan-cli-plugin/bin/docker-scan_${TARGETOS} /docker-scan_${TARGETOS}
7374

7475
####
7576
# CROSS_BUILD
@@ -126,6 +127,8 @@ RUN make -f builder.Makefile download
126127
# E2E
127128
####
128129
FROM builder AS e2e
130+
ARG TARGETOS
131+
ARG TARGETARCH
129132
ARG SNYK_DESKTOP_VERSION=1.332.0
130133
ENV SNYK_DESKTOP_VERSION=${SNYK_DESKTOP_VERSION}
131134
ARG SNYK_USER_VERSION=1.334.0
@@ -142,6 +145,6 @@ COPY --from=download /go/bin/gotestsum /usr/local/bin/gotestsum
142145
# install docker CLI
143146
COPY --from=cli /usr/local/bin/docker /usr/local/bin/docker
144147
# install docker-scan plugin
145-
COPY --from=cross-build /go/src/github.com/docker/scan-cli-plugin/dist/docker-scan_linux_amd64 ./bin/docker-scan
146-
RUN chmod +x ./bin/docker-scan
148+
COPY --from=cross-build /go/src/github.com/docker/scan-cli-plugin/dist/docker-scan_${TARGETOS}_${TARGETARCH} ./bin/docker-scan_${TARGETOS}_${TARGETARCH}
149+
RUN chmod +x ./bin/docker-scan_${TARGETOS}_${TARGETARCH}
147150
CMD ["make", "-f", "builder.Makefile", "e2e"]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ validate-go-mod: ## Validate go.mod and go.sum are up-to-date
8282
@docker build . --target check-go-mod
8383

8484
.PHONY: validate
85-
validate: validate-headers validate-go-mod ## Validate sources
85+
validate: validate-go-mod validate-headers ## Validate sources
8686

8787
.PHONY: help
8888
help: ## Show help

builder.Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ LDFLAGS := "-s -w \
1818
-X $(PKG_NAME)/internal.GitCommit=$(COMMIT) \
1919
-X $(PKG_NAME)/internal.Version=$(TAG_NAME)"
2020
GO_BUILD = $(STATIC_FLAGS) go build -trimpath -ldflags=$(LDFLAGS)
21-
BINARY:=docker-scan
21+
BINARY=docker-scan
22+
PLATFORM_BINARY:=$(BINARY)_$(GOOS)_amd64
2223
SNYK_DOWNLOAD_NAME:=snyk-linux
2324
SNYK_BINARY:=snyk
2425
PWD:=$(shell pwd)
2526
ifeq ($(GOOS),windows)
27+
PLATFORM_BINARY=docker-scan_$(GOOS)_amd64.exe
2628
BINARY=docker-scan.exe
2729
SNYK_DOWNLOAD_NAME:=snyk-win.exe
2830
SNYK_BINARY=snyk.exe
@@ -50,7 +52,7 @@ lint:
5052
e2e:
5153
mkdir -p docker-config/scan
5254
mkdir -p docker-config/cli-plugins
53-
cp ./bin/${BINARY} docker-config/cli-plugins/${BINARY}
55+
cp ./bin/${PLATFORM_BINARY} docker-config/cli-plugins/${BINARY}
5456
$(VARS) gotestsum ./e2e $(RUN_TEST) -- -ldflags=$(LDFLAGS)
5557

5658
.PHONY: test-unit
@@ -65,7 +67,7 @@ cross:
6567
.PHONY: build
6668
build:
6769
mkdir -p bin
68-
$(GO_BUILD) -o bin/$(BINARY) ./cmd/docker-scan
70+
$(GO_BUILD) -o bin/$(PLATFORM_BINARY) ./cmd/docker-scan
6971

7072
# For multi-platform (windows,macos,linux) github actions
7173
.PHONY: download

0 commit comments

Comments
 (0)