Skip to content

Commit

Permalink
chore(infra): separate out docker builds and binary uploads to their … (
Browse files Browse the repository at this point in the history
#747)

* chore(infra): separate out docker builds and binary uploads to their own workflow, limit concurrency to 1
  • Loading branch information
talalashraf authored Aug 26, 2021
1 parent 3060d60 commit a51456a
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 56 deletions.
2 changes: 2 additions & 0 deletions .github/buildkit-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[worker.oci]
max-parallelism = 1
79 changes: 79 additions & 0 deletions .github/workflows/build-docker-image-and-binaries.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Upload Binaries and Docker Image

on:
workflow_dispatch:
inputs:
tag:
description: Github tag to release binaries for (reusing same tag will overwrite previously released binaries)
required: true
default: latest

jobs:
release:
strategy:
matrix:
os:
- ubuntu-18.04
runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: '0'
ref: ${{ github.event.inputs.tag }}
submodules: recursive

- name: Set up ssh agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.CICD_RSA_KEY }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
config: ./.github/buildkit-config.toml

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Build and push docker image for all platforms
run: |
make build-push-docker-images
env:
SEMVER: ${{ steps.release.outputs.new_tag }}

- name: Build Binaries for Linux/MacOS
env:
SEMVER: ${{ steps.release.outputs.new_tag }}
run: |
make build-binaries-in-docker
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./bin/*
tag: ${{ steps.release.outputs.new_tag }}
overwrite: true
file_glob: true

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2

- name: Upload binaries to S3
env:
S3_PATH: s3://axelar-releases/axelard/${{ steps.release.outputs.new_tag }}
run: |
aws s3 cp ./bin ${S3_PATH}/ --recursive
52 changes: 0 additions & 52 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,55 +80,3 @@ jobs:
TAG_CONTEXT: branch
RELEASE_BRANCHES: main,releases.*
WITH_V: true

- name: Set up ssh agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.CICD_RSA_KEY }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

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

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Build and push docker image for all platforms
run: |
make build-push-docker-images
env:
SEMVER: ${{ steps.release.outputs.new_tag }}

- name: Build Binaries for Linux/MacOS
env:
SEMVER: ${{ steps.release.outputs.new_tag }}
run: |
make build-binaries-in-docker
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./bin/*
tag: ${{ steps.release.outputs.new_tag }}
overwrite: true
file_glob: true

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2

- name: Upload binaries to S3
env:
S3_PATH: s3://axelar-releases/axelard/${{ steps.release.outputs.new_tag }}
run: |
aws s3 cp ./bin ${S3_PATH}/ --recursive
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ build-binaries: guard-SEMVER

.PHONY: build-binaries-in-docker
build-binaries-in-docker: guard-SEMVER
docker build \
DOCKER_BUILDKIT=1 docker build \
--ssh default \
--build-arg SEMVER=${SEMVER} \
-t axelar/core:binaries \
Expand All @@ -61,8 +61,8 @@ docker-image:

.PHONY: build-push-docker-image
build-push-docker-images: guard-SEMVER
DOCKER_BUILDKIT=1 docker buildx build \
--platform linux/amd64 \
@DOCKER_BUILDKIT=1 docker buildx build \
--platform linux/arm64,linux/amd64,linux/arm/v7,linux/arm/v6 \
--ssh default \
--output "type=image,push=${PUSH_DOCKER_IMAGE}" \
-t axelarnet/axelar-core:${SEMVER} .
Expand Down Expand Up @@ -192,4 +192,4 @@ proto-update-deps:
.PHONY: proto-all proto-gen proto-gen-any proto-swagger-gen proto-format proto-lint proto-check-breaking proto-update-deps

guard-%:
@ if [ -z '${${*}}' ]; then echo 'Environment variable $* not set' && exit 1; fi
@ if [ -z '${${*}}' ]; then echo 'Environment variable $* not set' && exit 1; fi

0 comments on commit a51456a

Please sign in to comment.