Skip to content

Re-organize workflows and releasing process #202

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

Merged
merged 9 commits into from
May 10, 2025
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
57 changes: 57 additions & 0 deletions .github/workflows/deploy-avs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Manual AVS Deploy

on:
workflow_dispatch:
inputs:
environment:
description: 'Target environment for deployment'
required: true
type: choice
options:
- ethereum
- sepolia
- base
- base-sepolia

jobs:
aggregator:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.environment }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: SSH and Deploy
uses: appleboy/ssh-action@v0.1.5
with:
host: ${{ secrets.AVS_SERVER_HOST }}
username: ava
key: ${{ secrets.AVS_SSH_KEY }}
script: |
echo "Deploying to environment: ${{ inputs.environment }}"
cd $HOME/ap-aggregator-setup/${{ inputs.environment }}
docker compose pull
docker compose up -d --force-recreate

operator:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.environment }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: SSH and Deploy
uses: appleboy/ssh-action@v0.1.5
with:
host: ${{ secrets.AVS_SERVER_HOST }}
username: ava
key: ${{ secrets.AVS_SSH_KEY }}
script: |
echo "Deploying to environment: ${{ inputs.environment }}"
cd $HOME/ap-operator-setup/${{ inputs.environment == 'sepolia' && 'holesky' || inputs.environment }}
docker compose pull
docker compose up -d --force-recreate
140 changes: 140 additions & 0 deletions .github/workflows/prerelease-and-update-docker-on-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Build and Publish PR Pre-release Docker

on:
pull_request:
types:
- opened
- synchronize
branches:
- main

jobs:
build-and-publish-pr-docker:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout repository with full history
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for go-semantic-release

- name: Setup Go environment
uses: actions/setup-go@v4
with:
go-version: '1.22'

- name: Run Go linter
uses: golangci/golangci-lint-action@v3
with:
version: latest

- name: Run Go tests
run: go test -v ./...

- name: Generate commit summary
id: git-summary
run: |
echo "## Summary" >> commit-summary.md
echo "" >> commit-summary.md
FEATURES=$(git log $(git describe --tags --abbrev=0 2>/dev/null || git rev-list --max-parents=0 HEAD)..HEAD --pretty=format:"%s" --no-merges | grep -i "^feat" | wc -l)
FIXES=$(git log $(git describe --tags --abbrev=0 2>/dev/null || git rev-list --max-parents=0 HEAD)..HEAD --pretty=format:"%s" --no-merges | grep -i "^fix" | wc -l)
DOCS=$(git log $(git describe --tags --abbrev=0 2>/dev/null || git rev-list --max-parents=0 HEAD)..HEAD --pretty=format:"%s" --no-merges | grep -i "^docs" | wc -l)
echo "* $FEATURES new features" >> commit-summary.md
echo "* $FIXES bug fixes" >> commit-summary.md
echo "* $DOCS documentation updates" >> commit-summary.md
echo "" >> commit-summary.md
echo "## Changes since last release" >> commit-summary.md
echo "" >> commit-summary.md
git log $(git describe --tags --abbrev=0 2>/dev/null || git rev-list --max-parents=0 HEAD)..HEAD --pretty=format:"* %s (%h)" --no-merges >> commit-summary.md
echo "COMMIT_SUMMARY<<EOF" >> $GITHUB_ENV
cat commit-summary.md >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- name: Run semantic versioning and create pre-release
id: semantic-release
uses: go-semantic-release/action@v1
with:
hooks: goreleaser
changelog: ${{ env.COMMIT_SUMMARY }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Format Pre-release Version for Docker Tag
id: formatted-version
if: steps.semantic-release.outputs.new_release_published == 'true'
run: |
SEMREL_VERSION="${{ steps.semantic-release.outputs.new_version }}"
# Extract base version (e.g., v1.2.3)
BASE_VERSION=$(echo "$SEMREL_VERSION" | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+')
# Extract the part after the base version and the first hyphen (the pre-release suffix)
ORIGINAL_SUFFIX=$(echo "$SEMREL_VERSION" | sed -E "s/^${BASE_VERSION}-?(.*)$/\1/")

if [[ -z "$BASE_VERSION" ]]; then # Should not happen with semantic versions
echo "Error: Could not parse base version from $SEMREL_VERSION"
exit 1
fi

if [[ -z "$ORIGINAL_SUFFIX" ]]; then # Not a pre-release, or unexpected format
# This case should ideally not occur for a PR pre-release workflow.
# Defaulting to base version with -rc.0 if suffix is missing.
FINAL_DOCKER_TAG="${BASE_VERSION}-rc.0"
elif [[ "$ORIGINAL_SUFFIX" == rc\.* ]]; then
# Already in the desired rc.N format (e.g., rc.1, rc.10)
FINAL_DOCKER_TAG="$SEMREL_VERSION"
else
# Extract trailing digits from the original suffix for the increment
INCREMENT=$(echo "$ORIGINAL_SUFFIX" | grep -oE '[0-9]+$' || echo "0")
FINAL_DOCKER_TAG="${BASE_VERSION}-rc.${INCREMENT}"
fi
echo "Original semantic-release version: $SEMREL_VERSION"
echo "Formatted Docker tag: $FINAL_DOCKER_TAG"
echo "docker_tag=${FINAL_DOCKER_TAG}" >> "$GITHUB_OUTPUT"
shell: bash

- name: Print Formatted Docker Tag (Debug)
if: steps.semantic-release.outputs.new_release_published == 'true'
run: |
echo "The formatted Docker tag that will be used is: ${{ steps.formatted-version.outputs.docker_tag }}"

- name: Login to Docker Hub
if: steps.semantic-release.outputs.new_release_published == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up QEMU
if: steps.semantic-release.outputs.new_release_published == 'true'
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
if: steps.semantic-release.outputs.new_release_published == 'true'
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
if: steps.semantic-release.outputs.new_release_published == 'true'
uses: docker/metadata-action@v5
with:
images: |
avaprotocol/ap-avs
tags: |
# Only tag with the formatted pre-release version number
type=raw,value=${{ steps.formatted-version.outputs.docker_tag }}

- name: Build and push Docker image
if: steps.semantic-release.outputs.new_release_published == 'true'
uses: docker/build-push-action@v6
with:
build-args: |
RELEASE_TAG=${{ steps.semantic-release.outputs.new_version }}
platforms: linux/amd64,linux/arm64
context: .
file: dockerfiles/operator.Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
47 changes: 33 additions & 14 deletions .github/workflows/publish-dev-docker-on-staging.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Publish Dev Docker image upon staging change

on:
push:
pull_request:
types: [closed]
branches:
- staging
paths:
Expand All @@ -12,8 +13,9 @@ on:
workflow_dispatch:

jobs:
publish-dev-build:
name: Publish dev build docker image to dockerhub
publish-staging-build:
if: github.event.pull_request.merged == true
name: Publish staging build docker image to dockerhub
runs-on: 'ubuntu-latest'
steps:
- name: Login to Docker Hub
Expand All @@ -24,6 +26,28 @@ jobs:

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure fetch-depth is 0 for git log

- name: Determine Tag Prefix from Source Branch
id: vars
run: |
RAW_BRANCH_NAME="${{ github.event.pull_request.head.ref }}" # Get source branch directly
TAG_PREFIX=""

if [[ -n "$RAW_BRANCH_NAME" ]]; then
# Sanitize the branch name for use in a Docker tag:
# 1. Replace '/' with '-'
# 2. Keep only alphanumeric characters, '.', and '-'
# 3. Replace sequences of invalid characters with a single '-'
# 4. Remove leading/trailing '-'
SANITIZED_NAME=$(echo "$RAW_BRANCH_NAME" | sed 's|/|-|g' | tr -cs 'a-zA-Z0-9.-' '-' | sed 's/--\\+/-/g' | sed 's/^-*//;s/-*$//')
if [[ -n "$SANITIZED_NAME" ]]; then
TAG_PREFIX="$SANITIZED_NAME"
fi
fi
echo "TAG_PREFIX=${TAG_PREFIX}" >> $GITHUB_OUTPUT
shell: bash

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand All @@ -35,26 +59,21 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
# This is a dedicated repository to house the development/preview build
images: |
avaprotocol/avs-dev
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value={{sha}}
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- name: Build and push avs-dev docker image
type=pr # Generates pr-123 from the PR number
type=raw,value={{sha}} # Full commit SHA

- name: Build and push staging docker image
uses: docker/build-push-action@v6
with:
build-args: |
RELEASE_TAG=${{ inputs.tag || github.sha || github.head_ref || github.ref_name }}
RELEASE_TAG=${{ steps.vars.outputs.TAG_PREFIX }}${{ steps.vars.outputs.TAG_PREFIX:+'-' }}${{ github.sha }}
COMMIT_SHA=${{ github.sha }}
platforms: linux/amd64,linux/arm64
context: .
file: dockerfiles/operator.Dockerfile
push: ${{ github.event_name != 'pull_request' }}
push: true # Always push when this job runs (merged PR to staging)
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Loading