Skip to content

Commit 51be0a5

Browse files
authored
Disable cgo on upstream builds and attach binaries to releases (#932)
* Disable cgo on upstream builds * Release binaries
1 parent c3886b6 commit 51be0a5

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

.github/workflows/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,30 @@ jobs:
4343
registry: quay.io
4444
- name: build and push manifest with images
4545
run: MULTIARCH_TARGETS="${{ env.WF_MULTIARCH_TARGETS }}" IMAGE_ORG=${{ env.WF_ORG }} VERSION=${{ env.tag }} CLEAN_BUILD=1 make images
46+
- name: extract binaries
47+
run: MULTIARCH_TARGETS="${{ env.WF_MULTIARCH_TARGETS }}" IMAGE_ORG=${{ env.WF_ORG }} VERSION=${{ env.tag }} make extract-binaries
48+
- name: create draft release
49+
id: create_release
50+
uses: actions/create-release@v1
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
with:
54+
tag_name: ${{ env.tag }}
55+
release_name: ${{ env.tag }}
56+
draft: true
57+
prerelease: false
58+
- name: upload binaries
59+
uses: actions/github-script@v2
60+
with:
61+
github-token: ${{secrets.GITHUB_TOKEN}}
62+
script: |
63+
const fs = require('fs').promises;
64+
const upload_url = '${{ steps.create_release.outputs.upload_url }}';
65+
for (let file of await fs.readdir('./release-assets')) {
66+
console.log('uploading', file);
67+
await github.repos.uploadReleaseAsset({
68+
url: upload_url,
69+
name: file,
70+
data: await fs.readFile(`./release-assets/${file}`)
71+
});
72+
}

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ define manifest_add_target
6969
DOCKER_BUILDKIT=1 $(OCI_BIN) manifest add ${IMAGE} ${IMAGE}-$(1);
7070
endef
7171

72+
# extract a single arch target binary
73+
define extract_target
74+
echo 'extracting binary from ${IMAGE}-$(1)'; \
75+
$(OCI_BIN) create --name flp ${IMAGE}-$(1); \
76+
$(OCI_BIN) cp flp:/app/flowlogs-pipeline ./release-assets/flowlogs-pipeline-${VERSION}-linux-$(1); \
77+
$(OCI_BIN) rm -f flp;
78+
endef
79+
7280
##@ General
7381

7482
# The help target prints out all targets with their descriptions organized
@@ -197,5 +205,11 @@ else
197205
DOCKER_BUILDKIT=1 $(OCI_BIN) manifest push ${IMAGE} docker://${IMAGE};
198206
endif
199207

208+
.PHONY: extract-binaries
209+
extract-binaries: ## Extract all MULTIARCH_TARGETS binaries
210+
trap 'exit' INT; \
211+
mkdir -p release-assets; \
212+
$(foreach target,$(MULTIARCH_TARGETS),$(call extract_target,$(target)))
213+
200214
include .mk/development.mk
201215
include .mk/shortcuts.mk

contrib/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ COPY vendor/ vendor/
1212
COPY cmd/ cmd/
1313
COPY pkg/ pkg/
1414

15-
RUN GOARCH=$TARGETARCH go build -ldflags "$LDFLAGS" -mod vendor -o flowlogs-pipeline cmd/flowlogs-pipeline/main.go
15+
RUN CGO_ENABLED=0 GOARCH=$TARGETARCH go build -ldflags "$LDFLAGS" -mod vendor -o flowlogs-pipeline cmd/flowlogs-pipeline/main.go
1616

1717
# final stage
1818
FROM --platform=linux/$TARGETARCH registry.access.redhat.com/ubi9/ubi-minimal:9.5-1742914212

0 commit comments

Comments
 (0)