Skip to content
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
31 changes: 31 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
tags:
- 'v*'
branches:
- 'main'

jobs:
release:
Expand All @@ -23,6 +25,7 @@ jobs:
CGO_ENABLED=0 GOOS=linux go build -o caterpillar ./cmd/caterpillar/caterpillar.go

- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: caterpillar
Expand All @@ -31,3 +34,31 @@ jobs:
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

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

- name: Extract metadata for Docker
id: tagger
uses: docker/metadata-action@v5
with:
images: patternoss/caterpillar
tags: |
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=raw,value=main,enable=${{ github.ref == 'refs/heads/main' }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./build/Dockerfile
push: true
tags: ${{ steps.tagger.outputs.tags }}
platforms: linux/amd64,linux/arm64
13 changes: 13 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM golang:1.24.7-alpine AS builder

WORKDIR /go/src/github.com/patterninc/caterpillar

COPY . .

# build executable
RUN go build -o caterpillar ./cmd/caterpillar/caterpillar.go
RUN chmod 755 caterpillar

FROM alpine:3.20
RUN mkdir -p /output
COPY --from=builder /go/src/github.com/patterninc/caterpillar/caterpillar .
Loading