Skip to content

sort valset first before accumulate #19

sort valset first before accumulate

sort valset first before accumulate #19

name: Build and Release
on:
push:
branches: [main, dev]
tags:
- "v*"
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
container:
image: golang:1.23.4-alpine
steps:
- name: Install Git and build tools
run: |
apk add --no-cache git make gcc musl-dev
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git safe directory
run: |
git config --global --add safe.directory "$(pwd)"
- name: Build
run: |
make build
- name: Test
run: |
make test
docker:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Check Docker login status
run: |
echo "Checking Docker Hub login status..."
docker info
echo "DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}"
echo "DOCKERHUB_TOKEN is set: ${{ secrets.DOCKERHUB_TOKEN != '' }}"
# 创建仓库(如果不存在)
echo "Creating repositories if they don't exist..."
docker buildx create --use
docker buildx build --platform linux/amd64 -t ${{ secrets.DOCKERHUB_USERNAME }}/checkpoint-dispatcher:latest -f ./docker/dispatcher/Dockerfile . --push || echo "Repository may already exist"
docker buildx build --platform linux/amd64 -t ${{ secrets.DOCKERHUB_USERNAME }}/checkpoint-validator:latest -f ./docker/validator/Dockerfile . --push || echo "Repository may already exist"
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/checkpoint-dispatcher,${{ secrets.DOCKERHUB_USERNAME }}/checkpoint-validator
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
latest
- name: Build and push dispatcher image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/dispatcher/Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/checkpoint-dispatcher:latest,${{ secrets.DOCKERHUB_USERNAME }}/checkpoint-dispatcher:${{ github.ref_name }}
platforms: linux/amd64
- name: Build and push validator image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/validator/Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/checkpoint-validator:latest,${{ secrets.DOCKERHUB_USERNAME }}/checkpoint-validator:${{ github.ref_name }}
platforms: linux/amd64
# release:
# needs: build
# if: startsWith(github.ref, 'refs/tags/v')
# runs-on: ubuntu-latest
# container:
# image: golang:1.23.4-alpine
# steps:
# - name: Install build tools
# run: |
# apk add --no-cache git make gcc musl-dev zip tar
# - name: Checkout code
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - name: Configure Git safe directory
# run: |
# git config --global --add safe.directory "$(pwd)"
# - name: Build binaries
# run: |
# # Build for multiple platforms
# mkdir -p build/linux/amd64
# # Linux amd64
# CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o build/linux/amd64/dispatcher ./cmd/dispatcher
# CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o build/linux/amd64/validator ./cmd/validator
# - name: Create release archives
# run: |
# mkdir -p release
# cd build/linux/amd64 && tar -czvf ../../../release/checkpoint-linux-amd64.tar.gz * && cd -
# # use GitHub CLI to replace actions/upload-artifact
# - name: Install GitHub CLI
# run: |
# apk add --no-cache github-cli
# - name: Create GitHub Release
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# VERSION=${GITHUB_REF#refs/tags/}
# gh release create $VERSION \
# --title "Release $VERSION" \
# --notes "Release $VERSION" \
# release/checkpoint-linux-amd64.tar.gz \