Skip to content

Add distributed rate limiting with Redis and latency breakdown metrics #8

Add distributed rate limiting with Redis and latency breakdown metrics

Add distributed rate limiting with Redis and latency breakdown metrics #8

Workflow file for this run

name: Build and Push Docker Image
on:
push:
tags:
- 'v*'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/taiji
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Extract version
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/}
VERSION_NO_V=${VERSION#v}
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "VERSION_NO_V=${VERSION_NO_V}" >> $GITHUB_OUTPUT
- name: Build binaries
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
# Build for linux/amd64
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build \
-ldflags="-s -w -extldflags '-static'" \
-o taiji-${VERSION}-linux-amd64 \
main.go
# Build for linux/arm64
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build \
-ldflags="-s -w -extldflags '-static'" \
-o taiji-${VERSION}-linux-arm64 \
main.go
# Build for darwin/amd64 (Intel Mac)
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build \
-ldflags="-s -w" \
-o taiji-${VERSION}-darwin-amd64 \
main.go
# Build for darwin/arm64 (Apple Silicon)
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build \
-ldflags="-s -w" \
-o taiji-${VERSION}-darwin-arm64 \
main.go
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Log in to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels)
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest
type=sha
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Extract tag annotation
id: tag_annotation
run: |
TAG_MESSAGE=$(git tag -l --format='%(contents)' ${{ steps.version.outputs.VERSION }})
# Use multiline output for GitHub Actions
{
echo 'TAG_MESSAGE<<EOF'
echo "$TAG_MESSAGE"
echo EOF
} >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/[email protected]
with:
generate_release_notes: true
files: |
taiji-${{ steps.version.outputs.VERSION }}-linux-amd64
taiji-${{ steps.version.outputs.VERSION }}-linux-arm64
taiji-${{ steps.version.outputs.VERSION }}-darwin-amd64
taiji-${{ steps.version.outputs.VERSION }}-darwin-arm64
body: |
${{ steps.tag_annotation.outputs.TAG_MESSAGE }}
---
## Docker Image
```bash
# Pull with version tag
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.VERSION_NO_V }}
# Or pull latest release
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
```
### Available tags:
${{ steps.meta.outputs.tags }}
### Platforms:
- linux/amd64
- linux/arm64
## Binaries
Download the pre-built binaries for your platform:
- **Linux (amd64)**: `taiji-${{ steps.version.outputs.VERSION }}-linux-amd64`
- **Linux (arm64)**: `taiji-${{ steps.version.outputs.VERSION }}-linux-arm64`
- **macOS (Intel)**: `taiji-${{ steps.version.outputs.VERSION }}-darwin-amd64`
- **macOS (Apple Silicon)**: `taiji-${{ steps.version.outputs.VERSION }}-darwin-arm64`