Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updated Make for multiple targets and updated security.yaml to use ma…
…ke and bake.
  • Loading branch information
ausbru87 committed Oct 14, 2025
commit 6b8d1813632a8083f9cd90af3ecd1307a68d1537
19 changes: 6 additions & 13 deletions .github/workflows/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,19 @@ jobs:
go-version-file: "go.mod"

- name: Build binary for linux/amd64
run: |
TAG=$(git describe --always)
mkdir -p bin
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags "-X github.com/coder/code-marketplace/buildinfo.tag=${TAG}" \
-o bin/code-marketplace-linux-amd64 \
./cmd/marketplace/main.go
run: make build/linux/amd64

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker image
id: build
run: |
docker buildx build \
--platform linux/amd64 \
--tag code-marketplace:scan \
--load \
--build-arg TARGETARCH=amd64 \
.
docker buildx bake \
-f ./docker-bake.hcl \
--set "*.platform=linux/amd64" \
--set "*.tags=code-marketplace:scan" \
--load
echo "image=code-marketplace:scan" >> "$GITHUB_OUTPUT"

- name: Run Trivy vulnerability scanner (table output for logs)
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ upload:

TAG=$(shell git describe --always)

build/linux/amd64:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
build/linux/amd64:
bin/coder-marketplace-linux-amd64:

You can keep the PHONY (after editing the target name) for simplicity's sake though, otherwise you'll need to specify every Go-related file as a dependency

Copy link
Author

@ausbru87 ausbru87 Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be better to leave PHONY or to use a pattern like one of the following to ensure Make can still optimize by not building if no Go files change?

bin/code-marketplace-linux-amd64: $(wildcard **/*.go) go.mod go.sum

If you think leaving PHONY is simpler and cleaner then I am open just like using Make to optimize builds even in small repos like this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to do it you'll probably have to use shell find cuz I don't think make's wildcard is very good. But it's probably fine to just leave it as PHONY for this PR

mkdir -p bin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could maybe just put a $(shell mkdir -p bin) at the top of the file (not in a target) to avoid having to duplicate it in every target

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-X github.com/coder/code-marketplace/buildinfo.tag=$(TAG)" -o bin/code-marketplace-linux-amd64 ./cmd/marketplace/main.go
.PHONY: build/linux/amd64

build:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-X github.com/coder/code-marketplace/buildinfo.tag=$(TAG)" -o bin/code-marketplace-mac-amd64 ./cmd/marketplace/main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "-X github.com/coder/code-marketplace/buildinfo.tag=$(TAG)" -o bin/code-marketplace-mac-arm64 ./cmd/marketplace/main.go
Expand Down