feat: add multi-arch Docker image builds (amd64 + arm64) #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| branches: [main] | |
| paths: [VERSION] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Read version | |
| id: version | |
| run: echo "version=$(cat VERSION | tr -d '[:space:]')" >> "$GITHUB_OUTPUT" | |
| - name: Check tag does not exist | |
| run: | | |
| if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then | |
| echo "::error::Tag v${{ steps.version.outputs.version }} already exists" | |
| exit 1 | |
| fi | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Run tests | |
| run: go test -race ./... | |
| - name: Build sidecar binary for Linux amd64 | |
| run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o bin/sidecar-linux-amd64 ./cmd/sidecar | |
| - name: Build sidecar binary for Linux arm64 | |
| run: CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -trimpath -o bin/sidecar-linux-arm64 ./cmd/sidecar | |
| - name: Set up QEMU for multi-arch builds | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push API image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: build/api/Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| provenance: false | |
| tags: | | |
| ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }} | |
| ghcr.io/${{ github.repository }}:latest | |
| labels: | | |
| org.opencontainers.image.source=https://github.com/${{ github.repository }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Prepare agent build contexts | |
| run: | | |
| cp bin/sidecar-linux-amd64 build/agent/sidecar-amd64 | |
| cp bin/sidecar-linux-arm64 build/agent/sidecar-arm64 | |
| cp bin/sidecar-linux-amd64 build/opencode-agent/sidecar-amd64 | |
| cp bin/sidecar-linux-arm64 build/opencode-agent/sidecar-arm64 | |
| - name: Build and push Agent image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: build/agent | |
| file: build/agent/Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| provenance: false | |
| tags: | | |
| ghcr.io/helmcode/agent_crew_agent:${{ steps.version.outputs.version }} | |
| ghcr.io/helmcode/agent_crew_agent:latest | |
| labels: | | |
| org.opencontainers.image.source=https://github.com/${{ github.repository }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Build and push OpenCode Agent image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: build/opencode-agent | |
| file: build/opencode-agent/Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| provenance: false | |
| tags: | | |
| ghcr.io/helmcode/agent_crew_opencode_agent:${{ steps.version.outputs.version }} | |
| ghcr.io/helmcode/agent_crew_opencode_agent:latest | |
| labels: | | |
| org.opencontainers.image.source=https://github.com/${{ github.repository }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Create git tag | |
| run: | | |
| git tag "v${{ steps.version.outputs.version }}" | |
| git push origin "v${{ steps.version.outputs.version }}" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| name: v${{ steps.version.outputs.version }} | |
| generate_release_notes: true |