ci: migrate to canonical docker-build reusable (#1)

- Add docker.yml using hanzoai/.github/.github/workflows/docker-build.yml@main
- Add workflow-sanity.yml to enforce canonical CI contract
- Remove bespoke docker build steps from existing workflows

Refs: hanzoai/.github canonical Docker CI contract.
This commit is contained in:
2026-04-23 19:12:19 -07:00
committed by GitHub
parent b526b54c67
commit 7f27efe556
4 changed files with 148 additions and 221 deletions
+23 -56
View File
@@ -1,69 +1,36 @@
name: Build and Push
on:
workflow_dispatch:
workflow_dispatch: null
push:
branches: [main, hanzo-dev]
tags: ['v*']
branches:
- main
- hanzo-dev
tags:
- v*
pull_request:
branches: [main]
branches:
- main
env:
GO_VERSION: '1.26.1'
GO_VERSION: 1.26.1
REGISTRY: ghcr.io
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- run: go mod download
- run: go test -race -count=1 ./...
env:
CGO_ENABLED: 1
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- run: go mod download
- run: go test -race -count=1 ./...
env:
CGO_ENABLED: 1
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- run: go vet ./...
- run: test -z "$(gofmt -l .)"
docker:
runs-on: ubuntu-latest
needs: [test, lint]
if: github.event_name == 'push'
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/luxfi/indexer
tags: |
type=ref,event=branch
type=semver,pattern=v{{version}}
type=sha
- uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: VERSION=${{ github.ref_name }}
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- run: go vet ./...
- run: test -z "$(gofmt -l .)"
+99 -165
View File
@@ -1,197 +1,131 @@
name: CI
on:
push:
branches: [main]
tags: ['v*']
branches:
- main
tags:
- v*
pull_request:
branches: [main]
branches:
- main
env:
GO_VERSION: '1.25.5'
GO_VERSION: 1.25.5
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
permissions:
contents: read
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Download dependencies
run: go mod download
- name: Run tests
run: go test -v -race -coverprofile=coverage.out ./...
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
files: ./coverage.out
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Download dependencies
run: go mod download
- name: Run tests
run: go test -v -race -coverprofile=coverage.out ./...
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
files: ./coverage.out
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Run go vet
run: go vet ./...
- name: Check formatting
run: |
if [ -n "$(gofmt -l .)" ]; then
echo "Code is not formatted. Run 'go fmt ./...'"
gofmt -d .
exit 1
fi
- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- name: Run golangci-lint
run: golangci-lint run --timeout=10m || true
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Run go vet
run: go vet ./...
- name: Check formatting
run: |
if [ -n "$(gofmt -l .)" ]; then
echo "Code is not formatted. Run 'go fmt ./...'"
gofmt -d .
exit 1
fi
- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- name: Run golangci-lint
run: golangci-lint run --timeout=10m || true
build:
name: Build
runs-on: ubuntu-latest
needs: [test, lint]
needs:
- test
- lint
strategy:
matrix:
os: [linux, darwin, windows]
arch: [amd64, arm64]
os:
- linux
- darwin
- windows
arch:
- amd64
- arm64
exclude:
- os: windows
arch: arm64
- os: windows
arch: arm64
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Build
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: 0
run: |
EXT=""
if [ "${{ matrix.os }}" = "windows" ]; then
EXT=".exe"
fi
go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" \
-o indexer-${{ matrix.os }}-${{ matrix.arch }}${EXT} ./cmd/indexer
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: indexer-${{ matrix.os }}-${{ matrix.arch }}
path: indexer-${{ matrix.os }}-${{ matrix.arch }}*
docker:
name: Docker
runs-on: ubuntu-latest
needs: [test, lint]
if: github.event_name == 'push'
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
continue-on-error: true
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
luxfi/indexer
tags: |
type=ref,event=branch
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=sha
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
build-args: |
VERSION=${{ github.ref_name }}
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Build
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: 0
run: |
EXT=""
if [ "${{ matrix.os }}" = "windows" ]; then
EXT=".exe"
fi
go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" \
-o indexer-${{ matrix.os }}-${{ matrix.arch }}${EXT} ./cmd/indexer
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: indexer-${{ matrix.os }}-${{ matrix.arch }}
path: indexer-${{ matrix.os }}-${{ matrix.arch }}*
release:
name: Release
runs-on: ubuntu-latest
needs: [build, docker]
needs: build
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Prepare release files
run: |
mkdir -p release
for dir in indexer-*; do
if [ -d "$dir" ]; then
for file in "$dir"/*; do
cp "$file" release/
done
fi
done
ls -la release/
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: release/*
generate_release_notes: true
draft: false
prerelease: false
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Prepare release files
run: |
mkdir -p release
for dir in indexer-*; do
if [ -d "$dir" ]; then
for file in "$dir"/*; do
cp "$file" release/
done
fi
done
ls -la release/
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: release/*
generate_release_notes: true
draft: false
prerelease: false
+17
View File
@@ -0,0 +1,17 @@
name: Docker
on:
workflow_dispatch:
push:
branches: [main, dev, test]
tags: ['v*']
permissions:
contents: read
packages: write
jobs:
docker:
uses: hanzoai/.github/.github/workflows/docker-build.yml@main
with:
image: ghcr.io/luxfi/indexer
secrets: inherit
+9
View File
@@ -0,0 +1,9 @@
name: Workflow Sanity
on:
pull_request:
push:
branches: [main]
jobs:
sanity:
uses: hanzoai/.github/.github/workflows/workflow-sanity.yml@main