Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Workflow to build all Arch #1218

Merged
merged 17 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 76 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ on:
branches:
- master

defaults:
run:
shell: bash

jobs:
release:
runs-on: ubuntu-latest
build-binaries:
runs-on: ubuntu-20.04
name: Build binaries
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -23,29 +28,86 @@ jobs:
run: |
make build
chmod -R +x dist
zip -r release.zip dist
- name: Make checksums
run: make checksums
- name: store artifacts
uses: actions/upload-artifact@v2
with:
name: binaries
path: dist

- name: Release binaries
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
build-push-linux-multi:
name: Build & push linux/amd64 and linux/arm64
needs: [ build-binaries ]
runs-on: ubuntu-20.04
strategy:
matrix:
target: [ argo-events ]
steps:
- uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
files: release.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
platforms: amd64,arm64

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

- name: Docker Login
uses: Azure/docker-login@v1
- name: Download binaries
uses: actions/download-artifact@v2
with:
login-server: quay.io
name: binaries
path: dist/

- name: Registry Login
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAYIO_USERNAME }}
password: ${{ secrets.QUAYIO_PASSWORD }}

- name: Build & Push Linux Docker Images
- name: set tag csv value
id: tag
env:
QUAYIO_ORG: ${{ secrets.QUAYIO_ORG }}
TARGET: ${{ matrix.target }}
run: |
tag=$(basename $GITHUB_REF)
if [ $tag = "master" ]; then
tag="latest"
fi
make image IMAGE_TAG=${tag} IMAGE_NAMESPACE=${QUAYIO_ORG} DOCKER_PUSH=true
image_name="${QUAYIO_ORG}/${TARGET}:${tag}"
echo "::set-output name=TAG_LIST::$image_name"

- name: Container build and push
mickkael marked this conversation as resolved.
Show resolved Hide resolved
uses: docker/build-push-action@v2
env:
QUAYIO_ORG: ${{ secrets.QUAYIO_ORG }}
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: "true"
tags: ${{ steps.tag.outputs.TAG_LIST }}
target: ${{ matrix.target }}

release:
runs-on: ubuntu-latest
needs: [ build-push-linux-multi ]
steps:
- name: Download binaries
uses: actions/download-artifact@v2
with:
name: binaries
path: dist/

- name: Release binaries
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
dist/*.gz
dist/*.gz.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15 changes: 8 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
ARG ARCH=$TARGETARCH
####################################################################################################
# base
####################################################################################################
FROM alpine:3.12.3 as base
ARG ARCH
RUN apk update && apk upgrade && \
apk add ca-certificates && \
apk --no-cache add tzdata

ENV ARGO_VERSION=v3.0.2

RUN wget -q https://github.com/argoproj/argo/releases/download/${ARGO_VERSION}/argo-linux-amd64.gz
RUN gunzip argo-linux-amd64.gz
RUN chmod +x argo-linux-amd64
RUN mv ./argo-linux-amd64 /usr/local/bin/argo
RUN argo version
RUN wget -q https://github.com/argoproj/argo/releases/download/${ARGO_VERSION}/argo-linux-${ARCH}.gz
RUN gunzip argo-linux-${ARCH}.gz
RUN chmod +x argo-linux-${ARCH}
RUN mv ./argo-linux-${ARCH} /usr/local/bin/argo

####################################################################################################
# argo-events
####################################################################################################
FROM scratch as argo-events
ARG ARCH
COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=base /usr/local/bin/argo /usr/local/bin/argo
COPY dist/argo-events /bin/argo-events
COPY dist/argo-events-linux-${ARCH} /bin/argo-events
ENTRYPOINT [ "/bin/argo-events" ]

21 changes: 18 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,37 @@ endif

# build
.PHONY: build
build: dist/$(BINARY_NAME)-linux-amd64
build: dist/$(BINARY_NAME)-linux-amd64.gz dist/$(BINARY_NAME)-linux-arm64.gz dist/$(BINARY_NAME)-linux-arm.gz dist/$(BINARY_NAME)-linux-ppc64le.gz dist/$(BINARY_NAME)-linux-s390x.gz

dist/$(BINARY_NAME)-%.gz: dist/$(BINARY_NAME)-%
gzip --force --keep dist/$(BINARY_NAME)-$*

dist/$(BINARY_NAME): GOARGS = GOOS= GOARCH=
dist/$(BINARY_NAME)-linux-amd64: GOARGS = GOOS=linux GOARCH=amd64
dist/$(BINARY_NAME)-linux-arm64: GOARGS = GOOS=linux GOARCH=arm64
dist/$(BINARY_NAME)-linux-arm: GOARGS = GOOS=linux GOARCH=arm
dist/$(BINARY_NAME)-linux-ppc64le: GOARGS = GOOS=linux GOARCH=ppc64le
dist/$(BINARY_NAME)-linux-s390x: GOARGS = GOOS=linux GOARCH=s390x

dist/$(BINARY_NAME):
go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/$(BINARY_NAME) ./cmd

dist/$(BINARY_NAME)-%:
CGO_ENABLED=0 $(GOARGS) go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/$(BINARY_NAME) ./cmd
CGO_ENABLED=0 $(GOARGS) go build -v -ldflags '${LDFLAGS}' -o ${DIST_DIR}/$(BINARY_NAME)-$* ./cmd

.PHONY: build
image: dist/$(BINARY_NAME)-linux-amd64
DOCKER_BUILDKIT=1 docker build -t $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION) --target argo-events -f $(DOCKERFILE) .
DOCKER_BUILDKIT=1 docker build -t $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION) --target $(BINARY_NAME) -f $(DOCKERFILE) .
@if [ "$(DOCKER_PUSH)" = "true" ]; then docker push $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION); fi

image-linux-%: dist/$(BINARY_NAME)-linux-$*
DOCKER_BUILDKIT=1 docker build --build-arg "ARCH=$*" -t $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-$* --platform "linux/$*" --target $(BINARY_NAME) -f $(DOCKERFILE) .
@if [ "$(DOCKER_PUSH)" = "true" ]; then docker push $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-$*; fi

image-multi: image-linux-amd64 image-linux-arm64
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION) $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-arm64 $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-amd64
@if [ "$(DOCKER_PUSH)" = "true" ]; then docker manifest push $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION); fi
mickkael marked this conversation as resolved.
Show resolved Hide resolved

test:
go test $(shell go list ./... | grep -v /vendor/ | grep -v /test/e2e/) -race -short -v

Expand Down Expand Up @@ -149,3 +161,6 @@ update-manifests-version:
cat Makefile | sed 's/^VERSION?=.*/VERSION?=$(VERSION)/' | sed 's/^BASE_VERSION:=.*/BASE_VERSION:=$(VERSION)/' > /tmp/ae_makefile
mv /tmp/ae_makefile Makefile

.PHONY: checksums
checksums:
for f in ./dist/$(BINARY_NAME)-*.gz; do openssl dgst -sha256 "$$f" | awk ' { print $$2 }' > "$$f".sha256 ; done