Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Configure CI to use Docker to build the FIPS binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
nacx committed Mar 5, 2024
1 parent cf035a9 commit 4a6d368
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/fips.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@ env:
GOPROXY: https://proxy.golang.org

jobs:
fips:
fips-build:
runs-on: ubuntu-latest
env:
BUILD_FIPS_IN_DOCKER: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: docker/setup-qemu-action@v3
with:
platforms: amd64,arm64
- run: make fips
- run: make docker-fips
9 changes: 6 additions & 3 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ env:
jobs:
publish:
runs-on: ubuntu-latest
env:
BUILD_FIPS_IN_DOCKER: true
steps:
- name: "Set release tag"
if: ${{ github.ref_type == 'tag' }}
Expand All @@ -37,15 +39,16 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version-file: go.mod

- run: make check

- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-qemu-action@v3
with:
platforms: amd64,arm64

- run: make check
- run: make docker-push
- run: make docker-push-fips

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ $(OUTDIR)/$(NAME)-static-%: $(OUTDIR)
$(OUTDIR)/$(NAME)-fips-%: GOOS=$(word 1,$(subst -, ,$(subst $(NAME)-fips-,,$(@F))))
$(OUTDIR)/$(NAME)-fips-%: GOARCH=$(word 2,$(subst -, ,$(subst $(NAME)-fips-,,$(@F))))
$(OUTDIR)/$(NAME)-fips-%: $(OUTDIR)
ifneq ($(OS),Darwin)
ifneq ($(BUILD_FIPS_IN_DOCKER),true)
@echo "Build $(@F)"
@GOEXPERIMENT=boringcrypto CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(BUILD_OPTS) \
-ldflags '-linkmode=external -s -w -extldflags "-static"' -tags "netgo" \
Expand Down
5 changes: 5 additions & 0 deletions env.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ else
DOCKER_TAG ?= $(shell git rev-parse HEAD)
endif

# In non-Linux systems, use Docker to build FIPS-compliant binaries.
OS := $(shell uname)
ifeq ($(OS),Darwin)
BUILD_FIPS_IN_DOCKER ?= true
endif

export ARCH := $(shell uname -m)
ifeq ($(ARCH),x86_64)
export ARCH := amd64
Expand Down
2 changes: 1 addition & 1 deletion run-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ docker run \
-e GOPRIVATE="$(go env GOPRIVATE)" \
-w /source \
"${BUILD_IMAGE}" \
/bin/bash -c "${*:2}"
/bin/bash -c "git config --global --add safe.directory /source ; ${*:2}"

0 comments on commit 4a6d368

Please sign in to comment.