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

Add CI/CD pipelines for pushed tags #7

Merged
merged 13 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Automatically require code review from core-team.
* @sb-anderson @gts2030 @gazzua @syjn99 @qqqeck
* @overprotocol/protocol-dev
9 changes: 2 additions & 7 deletions .github/actions/gomodtidy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
FROM golang:alpine

RUN apk update
RUN apk add git
COPY entrypoint.sh /entrypoint.sh

ARG CACHEBUST=1
COPY . /github/workspace
COPY .github/actions/gomodtidy/entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/entrypoint.sh"]
16 changes: 4 additions & 12 deletions .github/actions/gomodtidy/action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
name: "Go mod tidy checker"
description: "Checks that `go mod tidy` has been applied."
on:
workflow_call:
inputs:
github_token:
required: true
type: string
name: 'Go mod tidy checker'
description: 'Checks that `go mod tidy` has been applied.'
runs:
using: "docker"
image: "Dockerfile"
args:
- ${{ inputs.github_token }}
using: 'docker'
image: 'Dockerfile'
8 changes: 2 additions & 6 deletions .github/actions/gomodtidy/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
#!/bin/sh -l
set -e

export PATH="$PATH:/usr/local/go/bin"

cd "/github/workspace"

go env -w GOPRIVATE=github.com/superblock-dev
git config --global url."https://$1@github.com/superblock-dev".insteadOf "https://github.com/superblock-dev"
cd "$GITHUB_WORKSPACE"

cp go.mod go.mod.orig
cp go.sum go.sum.orig

go mod tidy -compat=1.21
go mod tidy -compat=1.17

echo "Checking go.mod and go.sum:"
checks=0
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/_build-bazel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build binaries with Bazel

on:
workflow_call:
inputs:
build-type:
required: true
type: string
tag_name:
required: true
type: string
version_name:
required: true
type: string

jobs:
build-binaries:
runs-on: ubuntu-latest
container:
image: overfoundation/bazel-cross:latest
steps:
- uses: actions/checkout@v3
- name: Git config
run: |
git config --global --add safe.directory /__w/chronos/chronos

- name: Build ${{ inputs.build-type }}
run: |
bazel build \
--config=release \
--config=${{ inputs.build-type }} \
//cmd/beacon-chain \
//cmd/validator \
//cmd/prysmctl \
//tools/enr-calculator \
//tools/bootnode

- name: Make dist directory
run: |
mkdir -p dist
mkdir -p dist/${{ github.sha }}

- name: Zip artifact (Windows)
if: ${{ inputs.build-type == 'windows_amd64' }}
run: |
zip -j dist/${{ github.sha }}/chronos_${{ inputs.build-type }}.zip \
bazel-bin/cmd/beacon-chain/beacon-chain_/beacon-chain.exe \
bazel-bin/cmd/validator/validator_/validator.exe \
bazel-bin/cmd/prysmctl/prysmctl_/prysmctl.exe \
bazel-bin/tools/enr-calculator/enr-calculator_/enr-calculator.exe \
bazel-bin/tools/bootnode/bootnode_/bootnode.exe

- name: Zip artifact (Non-Windows)
if: ${{ inputs.build-type != 'windows_amd64' }}
run: |
zip -j dist/${{ github.sha }}/chronos_${{ inputs.build-type }}.zip \
bazel-bin/cmd/beacon-chain/beacon-chain_/beacon-chain \
bazel-bin/cmd/validator/validator_/validator \
bazel-bin/cmd/prysmctl/prysmctl_/prysmctl \
bazel-bin/tools/enr-calculator/enr-calculator_/enr-calculator \
bazel-bin/tools/bootnode/bootnode_/bootnode

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: chronos_${{ github.sha }}_${{ inputs.build-type }}
path: dist/${{ github.sha }}/chronos_${{ inputs.build-type }}.zip
78 changes: 78 additions & 0 deletions .github/workflows/_build-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build Docker images with Bazel and push to Docker Hub

on:
workflow_call:
inputs:
tag_name:
required: true
type: string
version_name:
required: true
type: string
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_TOKEN:
required: true

jobs:
build-and-push-images:
runs-on: ubuntu-latest
container:
image: overfoundation/bazel-cross:latest
outputs:
docker_tag: ${{ steps.set-docker-tag.outputs.docker_tag }}
steps:
- uses: actions/checkout@v3
- name: Git config
run: |
git config --global --add safe.directory /__w/chronos/chronos

- name: Set Docker Tag
id: set-docker-tag
run: |
echo "docker_tag=${{ inputs.version_name }}_${{ inputs.tag_name }}" >> $GITHUB_OUTPUT

- name: Login docker hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Run push_images for beacon-chain
run: |
echo "Run push_images(beacon-chain) for ${{ steps.set-docker-tag.outputs.docker_tag }}"
bazel run \
//cmd/beacon-chain:push_images \
--config=release \
-- \
--tag=${{ steps.set-docker-tag.outputs.docker_tag }} \
--repository=overfoundation/chronos-beacon-chain

- name: Run push_images for validator
run: |
echo "Run push_images(validator) for ${{ steps.set-docker-tag.outputs.docker_tag }}"
bazel run \
//cmd/validator:push_images \
--config=release \
-- \
--tag=${{ steps.set-docker-tag.outputs.docker_tag }} \
--repository=overfoundation/chronos-validator

- name: Run push_images for latest
if: ${{ inputs.tag_name == 'stable' }}
run: |
echo "Run push_images(latest) for ${{ steps.set-docker-tag.outputs.docker_tag }}"
bazel run \
//cmd/beacon-chain:push_images \
--config=release \
-- \
--tag=latest \
--repository=overfoundation/chronos-beacon-chain

bazel run \
//cmd/validator:push_images \
--config=release \
-- \
--tag=latest \
--repository=overfoundation/chronos-validator
169 changes: 0 additions & 169 deletions .github/workflows/cd.tags.yml

This file was deleted.

Loading
Loading