Skip to content

v1.0.8

v1.0.8 #8

Workflow file for this run

name: Release Multi-Arch Images
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
release_type:
description: 'Release type'
required: true
type: choice
options:
- staging
- production
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write # For OIDC
attestations: write # For provenance
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- 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.GHCR_TOKEN }}
- name: Extract version metadata
id: meta
run: |
# Get version from tag (strip 'v' prefix: v1.0.3 -> 1.0.3)
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
VERSION=${VERSION#v}
else
VERSION=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.0.0")
fi
COMMIT=$(git rev-parse --short HEAD)
BRANCH=$(git rev-parse --abbrev-ref HEAD)
BUILD_DATE=$(date +%s)
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "COMMIT=${COMMIT}" >> $GITHUB_OUTPUT
echo "BRANCH=${BRANCH}" >> $GITHUB_OUTPUT
echo "BUILD_DATE=${BUILD_DATE}" >> $GITHUB_OUTPUT
echo "📦 Building version: ${VERSION}"
- name: Generate Docker tags
id: tags
run: |
VERSION="${{ steps.meta.outputs.VERSION }}"
IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
TAGS="${IMAGE}:${VERSION},${IMAGE}:latest"
echo "TAGS=${TAGS}" >> $GITHUB_OUTPUT
echo "🏷️ Tags: ${TAGS}"
- name: Build and push multi-arch image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.tags.outputs.TAGS }}
build-args: |
VERSION=${{ steps.meta.outputs.VERSION }}
BUILD_DATE=${{ steps.meta.outputs.BUILD_DATE }}
COMMIT=${{ steps.meta.outputs.COMMIT }}
BRANCH=${{ steps.meta.outputs.BRANCH }}
RELEASE=1
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Generate build summary
run: |
cat >> $GITHUB_STEP_SUMMARY <<EOF
## 🚀 Release Summary
- **Version**: ${{ steps.meta.outputs.VERSION }}
- **Type**: ${{ steps.meta.outputs.RELEASE_TYPE }}
- **Commit**: ${{ steps.meta.outputs.COMMIT }}
- **Architectures**: amd64, arm64
- **Registry**: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- **Tags**:
- ${{ steps.tags.outputs.TAGS }}
### Installation
\`\`\`bash
# Pull the image
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.VERSION }}
# Or use in Kubernetes
kubectl set image deployment/smithy \\
smithy=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.VERSION }}
\`\`\`
EOF
- name: Test image (smoke test)
run: |
VERSION="${{ steps.meta.outputs.VERSION }}"
IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}$([[ "${{ steps.meta.outputs.RELEASE_TYPE }}" == "staging" ]] && echo "-staging" || echo "")"
echo "🧪 Testing image: ${IMAGE}"
docker pull ${IMAGE}
docker run --rm ${IMAGE} --version
promote-to-production:
runs-on: ubuntu-latest
needs: build-and-push
if: github.event.inputs.release_type == 'staging' && github.event_name == 'workflow_dispatch'
permissions:
packages: write
steps:
- name: Promote staging to production
run: |
echo "✨ Staging build complete. To promote to production:"
echo ""
echo " git tag v${{ needs.build-and-push.outputs.VERSION }}"
echo " git push origin v${{ needs.build-and-push.outputs.VERSION }}"
echo ""
echo "Or run: make release-publish VERSION=${{ needs.build-and-push.outputs.VERSION }}-staging"