diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e098dd84b0..c4522c7da0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 @@ -23,29 +28,167 @@ 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-arm64: + name: Build & push linux/arm64 + needs: [ build-binaries ] + runs-on: ubuntu-20.04 + strategy: + matrix: + platform: [ linux/arm64 ] + target: [ argo-events ] + steps: + - uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Download binaries + uses: actions/download-artifact@v2 with: - files: release.zip + name: binaries + path: dist/ + + - name: Docker Login + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAYIO_USERNAME }} + password: ${{ secrets.QUAYIO_PASSWORD }} + + - name: Docker Buildx env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + QUAYIO_ORG: ${{ secrets.QUAYIO_ORG }} + PLATFORM: ${{ matrix.platform }} + TARGET: ${{ matrix.target }} + run: | + tag=$(basename $GITHUB_REF) + if [ $tag = "master" ]; then + tag="latest" + fi + + tag_suffix=$(echo $PLATFORM | sed -r "s/\//-/g") + image_name="${QUAYIO_ORG}/${TARGET}:${tag}-${tag_suffix}" + + docker buildx build \ + --output "type=image,push=true" \ + --platform="${PLATFORM}" \ + --build-arg "ARCH=arm64" \ + --target $TARGET \ + --tag quay.io/$image_name . + + build-push-linux-amd64: + name: Build & push linux/amd64 + needs: [ build-binaries ] + runs-on: ubuntu-20.04 + strategy: + matrix: + platform: [ linux/amd64 ] + target: [ argo-events ] + steps: + - uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Download binaries + uses: actions/download-artifact@v2 + with: + name: binaries + path: dist/ - name: Docker Login + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAYIO_USERNAME }} + password: ${{ secrets.QUAYIO_PASSWORD }} + + - name: Docker Buildx + env: + QUAYIO_ORG: ${{ secrets.QUAYIO_ORG }} + PLATFORM: ${{ matrix.platform }} + TARGET: ${{ matrix.target }} + run: | + tag=$(basename $GITHUB_REF) + if [ $tag = "master" ]; then + tag="latest" + fi + + tag_suffix=$(echo $PLATFORM | sed -r "s/\//-/g") + image_name="${QUAYIO_ORG}/${TARGET}:${tag}-${tag_suffix}" + + docker buildx build \ + --output "type=image,push=true" \ + --platform="${PLATFORM}" \ + --build-arg "ARCH=amd64" \ + --target $TARGET \ + --tag quay.io/$image_name . + + push-images-multi-manifest: + name: Push manifest with all images + runs-on: ubuntu-20.04 + needs: [ build-push-linux-arm64, build-push-linux-amd64 ] + steps: + - uses: actions/checkout@v2 + + - name: Login to Quay uses: Azure/docker-login@v1 with: login-server: quay.io username: ${{ secrets.QUAYIO_USERNAME }} password: ${{ secrets.QUAYIO_PASSWORD }} - - name: Build & Push Linux Docker Images + - name: Push Multiarch Image env: QUAYIO_ORG: ${{ secrets.QUAYIO_ORG }} run: | + echo $(jq -c '. + { "experimental": "enabled" }' ${DOCKER_CONFIG}/config.json) > ${DOCKER_CONFIG}/config.json + + quay_org=$QUAYIO_ORG + tag=$(basename $GITHUB_REF) if [ $tag = "master" ]; then tag="latest" fi - make image IMAGE_TAG=${tag} IMAGE_NAMESPACE=${QUAYIO_ORG} DOCKER_PUSH=true + + targets="argo-events" + for target in $targets; do + image_name="${quay_org}/${target}:${tag}" + + docker manifest create quay.io/$image_name quay.io/${image_name}-linux-arm64 quay.io/${image_name}-linux-amd64 + + docker manifest push quay.io/$image_name + done + + release: + runs-on: ubuntu-latest + needs: [ push-images-multi-manifest ] + 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 }} diff --git a/Dockerfile b/Dockerfile index ac9115bfbd..b597ab1a6a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,9 +20,9 @@ RUN argo version # 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" ] - diff --git a/Makefile b/Makefile index 59121b93e7..307fc85590 100644 --- a/Makefile +++ b/Makefile @@ -39,11 +39,15 @@ 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 @@ -51,12 +55,16 @@ 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) . - @if [ "$(DOCKER_PUSH)" = "true" ]; then docker push $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION); fi +image: image-linux-amd64 +image-linux-amd64: dist/$(BINARY_NAME)-linux-amd64 + DOCKER_BUILDKIT=1 docker build -t $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-amd64 --target $(BINARY_NAME) -f $(DOCKERFILE) . + @if [ "$(DOCKER_PUSH)" = "true" ]; then docker push $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-amd64; fi +image-linux-arm64: dist/$(BINARY_NAME)-linux-arm64 + DOCKER_BUILDKIT=1 docker build -t $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-arm64 --target $(BINARY_NAME) -f $(DOCKERFILE) . + @if [ "$(DOCKER_PUSH)" = "true" ]; then docker push $(IMAGE_NAMESPACE)/$(BINARY_NAME):$(VERSION)-linux-arm64; fi test: go test $(shell go list ./... | grep -v /vendor/ | grep -v /test/e2e/) -race -short -v @@ -149,3 +157,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